Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Node-Red
    5. [gelöst] Lampe nur einschalten wenn...

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    [gelöst] Lampe nur einschalten wenn...

    This topic has been deleted. Only users with topic management privileges can see it.
    • mickym
      mickym Most Active @Matt77CHE last edited by

      @matt77che Ok dann mach ich Dir mal einen Flow mit diesen Datenpunkten

      ec1e755c-7462-4347-9ee7-b58ebcd12ff1-image.png

      M 1 Reply Last reply Reply Quote 0
      • mickym
        mickym Most Active @Matt77CHE last edited by

        @matt77che

        @matt77che sagte in Lampe nur einschalten wenn...:

        Sonst jedoch nicht - Das Nachtlicht ist jedoch nicht der Datenpunkt "Licht im Wohnzimmer", sondern ein anderes.

        Das spielt keine Rolle - es kommt true für Einschalten und false für Ausschalten aus dem Flow und das schickst Du dann in den Datenpunkt der das Nachtlicht ein-/ausschaltet.

        1 Reply Last reply Reply Quote 0
        • M
          Matt77CHE @mickym last edited by

          @mickym

          Es sind insgesamt drei Objekte

          Ist dunkel?
          Licht im Wohnzimmer
          Nachtlicht > soll brennen wenn es dunkel ist und im Wohnzimmer kein Licht brennt

          mickym 1 Reply Last reply Reply Quote 0
          • mickym
            mickym Most Active @Matt77CHE last edited by mickym

            @matt77che Ja schon verstanden.

            45715aee-c043-4a5f-8031-82a60ab635f7-image.png

            M 1 Reply Last reply Reply Quote 0
            • M
              Matt77CHE @mickym last edited by

              @mickym
              genau

              1 Reply Last reply Reply Quote 0
              • M
                Matt77CHE last edited by

                @mickym
                für einen solchen Flow wäre ich dir dankbar

                mickym 1 Reply Last reply Reply Quote 0
                • mickym
                  mickym Most Active @Matt77CHE last edited by mickym

                  @matt77che

                  e1c9764d-0e7d-46fd-a517-c71e3a01b710-image.png

                  Hier zum Import - die Debug Nodes kannst natürlich wieder löschen - dienen nur zur Illustration. Ich habs mit einer Change Node direkt ohne switch Node gemacht.

                  Hier zum Import:

                  [
                     {
                         "id": "c6ef0f95e6107c9d",
                         "type": "ioBroker in",
                         "z": "289f539dcc33814e",
                         "name": "Licht Wohnzimmer",
                         "topic": "0_userdata.0.Test.Licht.an",
                         "payloadType": "value",
                         "onlyack": "",
                         "func": "all",
                         "gap": "",
                         "fireOnStart": "true",
                         "outFormat": "MQTT",
                         "x": 3210,
                         "y": 4380,
                         "wires": [
                             [
                                 "ce013750d76f19f2"
                             ]
                         ]
                     },
                     {
                         "id": "02af5d243f1cdff2",
                         "type": "ioBroker in",
                         "z": "289f539dcc33814e",
                         "name": "Ist es dunkel?",
                         "topic": "0_userdata.0.Test.Licht.dunkel",
                         "payloadType": "value",
                         "onlyack": "",
                         "func": "all",
                         "gap": "",
                         "fireOnStart": "true",
                         "outFormat": "MQTT",
                         "x": 3230,
                         "y": 4440,
                         "wires": [
                             [
                                 "5441cb4d36c6c103"
                             ]
                         ]
                     },
                     {
                         "id": "ce013750d76f19f2",
                         "type": "change",
                         "z": "289f539dcc33814e",
                         "name": "verschiebe payload nach licht",
                         "rules": [
                             {
                                 "t": "move",
                                 "p": "payload",
                                 "pt": "msg",
                                 "to": "licht",
                                 "tot": "msg"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 3470,
                         "y": 4380,
                         "wires": [
                             [
                                 "435677eebedefdda"
                             ]
                         ]
                     },
                     {
                         "id": "5441cb4d36c6c103",
                         "type": "change",
                         "z": "289f539dcc33814e",
                         "name": "verschiebe payload nach dunkel",
                         "rules": [
                             {
                                 "t": "move",
                                 "p": "payload",
                                 "pt": "msg",
                                 "to": "dunkel",
                                 "tot": "msg"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 3470,
                         "y": 4440,
                         "wires": [
                             [
                                 "e4d5d47dbdc5a358"
                             ]
                         ]
                     },
                     {
                         "id": "435677eebedefdda",
                         "type": "ioBroker get",
                         "z": "289f539dcc33814e",
                         "name": "schaue, ob es dunkel ist",
                         "topic": "0_userdata.0.Test.Licht.dunkel",
                         "attrname": "dunkel",
                         "payloadType": "value",
                         "errOnInvalidState": "nothing",
                         "x": 3750,
                         "y": 4380,
                         "wires": [
                             [
                                 "44a0b5a56e945fe6"
                             ]
                         ]
                     },
                     {
                         "id": "e4d5d47dbdc5a358",
                         "type": "ioBroker get",
                         "z": "289f539dcc33814e",
                         "name": "schaue, ob Licht brennt",
                         "topic": "0_userdata.0.Test.Licht.an",
                         "attrname": "licht",
                         "payloadType": "value",
                         "errOnInvalidState": "nothing",
                         "x": 3750,
                         "y": 4440,
                         "wires": [
                             [
                                 "44a0b5a56e945fe6"
                             ]
                         ]
                     },
                     {
                         "id": "8f61b42771a996bb",
                         "type": "debug",
                         "z": "289f539dcc33814e",
                         "name": "Status der beiden Eigenschaften",
                         "active": true,
                         "tosidebar": true,
                         "console": false,
                         "tostatus": false,
                         "complete": "{\t   \"Licht an\": licht,\t   \"Es ist dunkel\": dunkel\t}",
                         "targetType": "jsonata",
                         "statusVal": "",
                         "statusType": "auto",
                         "x": 4130,
                         "y": 4340,
                         "wires": []
                     },
                     {
                         "id": "99f4d1cd12809cc2",
                         "type": "change",
                         "z": "289f539dcc33814e",
                         "name": "Setze payload wenn dunkel und kein Licht",
                         "rules": [
                             {
                                 "t": "set",
                                 "p": "payload",
                                 "pt": "msg",
                                 "to": "$not(licht) and dunkel",
                                 "tot": "jsonata"
                             }
                         ],
                         "action": "",
                         "property": "",
                         "from": "",
                         "to": "",
                         "reg": false,
                         "x": 4140,
                         "y": 4400,
                         "wires": [
                             [
                                 "f4bca42f9cbc2173",
                                 "c93a76d68ed1e296"
                             ]
                         ]
                     },
                     {
                         "id": "f4bca42f9cbc2173",
                         "type": "ioBroker out",
                         "z": "289f539dcc33814e",
                         "name": "Nachtlicht",
                         "topic": "0_userdata.0.Test.Licht.Nachtlicht",
                         "ack": "false",
                         "autoCreate": "false",
                         "stateName": "",
                         "role": "",
                         "payloadType": "",
                         "readonly": "",
                         "stateUnit": "",
                         "stateMin": "",
                         "stateMax": "",
                         "x": 4400,
                         "y": 4400,
                         "wires": []
                     },
                     {
                         "id": "c93a76d68ed1e296",
                         "type": "debug",
                         "z": "289f539dcc33814e",
                         "name": "payload = Nachtlicht",
                         "active": true,
                         "tosidebar": true,
                         "console": false,
                         "tostatus": false,
                         "complete": "payload",
                         "targetType": "msg",
                         "statusVal": "",
                         "statusType": "auto",
                         "x": 4440,
                         "y": 4480,
                         "wires": []
                     },
                     {
                         "id": "44a0b5a56e945fe6",
                         "type": "junction",
                         "z": "289f539dcc33814e",
                         "x": 3917,
                         "y": 4403.5,
                         "wires": [
                             [
                                 "8f61b42771a996bb",
                                 "99f4d1cd12809cc2"
                             ]
                         ]
                     }
                  ]
                  

                  Ausserdem habe ich versucht die Nodes entsprechend aussagekräftig zu benennen.

                  Die payload zum Schalten des Nachtlichts wird also direkt über die Verknüpfung der beiden Nachrichteneigenschaften dunkel und licht erstellt (die dann wenn licht aus und dunkel ist, true ist - sonst false).

                  Wenn Du kein JSONATA verwenden willst - sondern nur über die Logik der Nodes steuern willst dann musst Du halt in einzelne Nodes auflösen - nur zur Demo.

                  M 1 Reply Last reply Reply Quote 0
                  • M
                    Matt77CHE @mickym last edited by

                    @mickym
                    super - vielen Dank dafür, funktioniert genau so wie es soll.

                    Schaue mir die einzelnen nodes noch an, wie du es gemacht hast & vielen Dank für deine Erklärungen!
                    👍 👍 👍

                    mickym 1 Reply Last reply Reply Quote 0
                    • mickym
                      mickym Most Active @Matt77CHE last edited by mickym

                      @matt77che So falls Du kein JSONATA nutzen willst - hier mal eine Version - in der die Logik rein mit setzen der payload und filtern der verschiedenen Fälle über switch Nodes realisiert ist:

                      cec7cf4a-f396-47f1-9650-5a7d447b45ae-image.png

                      Auch hier habe ich versucht über die Namen, das einigermassen verständlich zu erklären
                      hier der Import:

                      [
                         {
                             "id": "c6ef0f95e6107c9d",
                             "type": "ioBroker in",
                             "z": "289f539dcc33814e",
                             "name": "Licht Wohnzimmer",
                             "topic": "0_userdata.0.Test.Licht.an",
                             "payloadType": "value",
                             "onlyack": "",
                             "func": "all",
                             "gap": "",
                             "fireOnStart": "true",
                             "outFormat": "MQTT",
                             "x": 2950,
                             "y": 4360,
                             "wires": [
                                 [
                                     "ce013750d76f19f2"
                                 ]
                             ]
                         },
                         {
                             "id": "02af5d243f1cdff2",
                             "type": "ioBroker in",
                             "z": "289f539dcc33814e",
                             "name": "Ist es dunkel?",
                             "topic": "0_userdata.0.Test.Licht.dunkel",
                             "payloadType": "value",
                             "onlyack": "",
                             "func": "all",
                             "gap": "",
                             "fireOnStart": "true",
                             "outFormat": "MQTT",
                             "x": 2970,
                             "y": 4440,
                             "wires": [
                                 [
                                     "5441cb4d36c6c103"
                                 ]
                             ]
                         },
                         {
                             "id": "ce013750d76f19f2",
                             "type": "change",
                             "z": "289f539dcc33814e",
                             "name": "verschiebe payload nach licht",
                             "rules": [
                                 {
                                     "t": "move",
                                     "p": "payload",
                                     "pt": "msg",
                                     "to": "licht",
                                     "tot": "msg"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 3210,
                             "y": 4360,
                             "wires": [
                                 [
                                     "435677eebedefdda"
                                 ]
                             ]
                         },
                         {
                             "id": "5441cb4d36c6c103",
                             "type": "change",
                             "z": "289f539dcc33814e",
                             "name": "verschiebe payload nach dunkel",
                             "rules": [
                                 {
                                     "t": "move",
                                     "p": "payload",
                                     "pt": "msg",
                                     "to": "dunkel",
                                     "tot": "msg"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 3210,
                             "y": 4440,
                             "wires": [
                                 [
                                     "e4d5d47dbdc5a358"
                                 ]
                             ]
                         },
                         {
                             "id": "435677eebedefdda",
                             "type": "ioBroker get",
                             "z": "289f539dcc33814e",
                             "name": "schaue, ob es dunkel ist",
                             "topic": "0_userdata.0.Test.Licht.dunkel",
                             "attrname": "dunkel",
                             "payloadType": "value",
                             "errOnInvalidState": "nothing",
                             "x": 3490,
                             "y": 4360,
                             "wires": [
                                 [
                                     "44a0b5a56e945fe6"
                                 ]
                             ]
                         },
                         {
                             "id": "e4d5d47dbdc5a358",
                             "type": "ioBroker get",
                             "z": "289f539dcc33814e",
                             "name": "schaue, ob Licht brennt",
                             "topic": "0_userdata.0.Test.Licht.an",
                             "attrname": "licht",
                             "payloadType": "value",
                             "errOnInvalidState": "nothing",
                             "x": 3490,
                             "y": 4440,
                             "wires": [
                                 [
                                     "44a0b5a56e945fe6"
                                 ]
                             ]
                         },
                         {
                             "id": "f4bca42f9cbc2173",
                             "type": "ioBroker out",
                             "z": "289f539dcc33814e",
                             "name": "Nachtlicht",
                             "topic": "0_userdata.0.Test.Licht.Nachtlicht",
                             "ack": "false",
                             "autoCreate": "false",
                             "stateName": "",
                             "role": "",
                             "payloadType": "",
                             "readonly": "",
                             "stateUnit": "",
                             "stateMin": "",
                             "stateMax": "",
                             "x": 4760,
                             "y": 4380,
                             "wires": []
                         },
                         {
                             "id": "c93a76d68ed1e296",
                             "type": "debug",
                             "z": "289f539dcc33814e",
                             "name": "payload = Nachtlicht",
                             "active": true,
                             "tosidebar": true,
                             "console": false,
                             "tostatus": false,
                             "complete": "payload",
                             "targetType": "msg",
                             "statusVal": "",
                             "statusType": "auto",
                             "x": 4800,
                             "y": 4440,
                             "wires": []
                         },
                         {
                             "id": "cbb5a412bcf60ab0",
                             "type": "switch",
                             "z": "289f539dcc33814e",
                             "name": "Ist Licht an/aus?",
                             "property": "licht",
                             "propertyType": "msg",
                             "rules": [
                                 {
                                     "t": "false"
                                 },
                                 {
                                     "t": "true"
                                 }
                             ],
                             "checkall": "true",
                             "repair": false,
                             "outputs": 2,
                             "x": 3740,
                             "y": 4400,
                             "wires": [
                                 [
                                     "a501f770071798a7"
                                 ],
                                 [
                                     "9d5467df431a8fec"
                                 ]
                             ]
                         },
                         {
                             "id": "9d5467df431a8fec",
                             "type": "change",
                             "z": "289f539dcc33814e",
                             "name": "Wenn Licht an - dann payload false",
                             "rules": [
                                 {
                                     "t": "set",
                                     "p": "payload",
                                     "pt": "msg",
                                     "to": "false",
                                     "tot": "bool"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 4480,
                             "y": 4440,
                             "wires": [
                                 [
                                     "f92109c326f3e098"
                                 ]
                             ]
                         },
                         {
                             "id": "a501f770071798a7",
                             "type": "switch",
                             "z": "289f539dcc33814e",
                             "name": "Wenn Licht aus - dann prüfe ob dunkel ist?",
                             "property": "dunkel",
                             "propertyType": "msg",
                             "rules": [
                                 {
                                     "t": "true"
                                 },
                                 {
                                     "t": "false"
                                 }
                             ],
                             "checkall": "true",
                             "repair": false,
                             "outputs": 2,
                             "x": 4030,
                             "y": 4360,
                             "wires": [
                                 [
                                     "c4bbadd7a7b95d8d"
                                 ],
                                 [
                                     "0277bbdf129cf5ae"
                                 ]
                             ]
                         },
                         {
                             "id": "c4bbadd7a7b95d8d",
                             "type": "change",
                             "z": "289f539dcc33814e",
                             "name": "Es ist dunkel und Licht ist aus, also payload = true",
                             "rules": [
                                 {
                                     "t": "set",
                                     "p": "payload",
                                     "pt": "msg",
                                     "to": "true",
                                     "tot": "bool"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 4430,
                             "y": 4320,
                             "wires": [
                                 [
                                     "f92109c326f3e098"
                                 ]
                             ]
                         },
                         {
                             "id": "0277bbdf129cf5ae",
                             "type": "change",
                             "z": "289f539dcc33814e",
                             "name": "Es ist hell und Licht ist aus, also payload = false",
                             "rules": [
                                 {
                                     "t": "set",
                                     "p": "payload",
                                     "pt": "msg",
                                     "to": "false",
                                     "tot": "bool"
                                 }
                             ],
                             "action": "",
                             "property": "",
                             "from": "",
                             "to": "",
                             "reg": false,
                             "x": 4420,
                             "y": 4380,
                             "wires": [
                                 [
                                     "f92109c326f3e098"
                                 ]
                             ]
                         },
                         {
                             "id": "44a0b5a56e945fe6",
                             "type": "junction",
                             "z": "289f539dcc33814e",
                             "x": 3640,
                             "y": 4400,
                             "wires": [
                                 [
                                     "cbb5a412bcf60ab0"
                                 ]
                             ]
                         },
                         {
                             "id": "f92109c326f3e098",
                             "type": "junction",
                             "z": "289f539dcc33814e",
                             "x": 4660,
                             "y": 4380,
                             "wires": [
                                 [
                                     "c93a76d68ed1e296",
                                     "f4bca42f9cbc2173"
                                 ]
                             ]
                         }
                      ]
                      

                      M 1 Reply Last reply Reply Quote 0
                      • M
                        Matt77CHE @mickym last edited by

                        @mickym

                        Vielen Dank - ist doch irgendwie ganz was anderes als die Blockly im Java-Scripte adapter 😊

                        Danke dass du dir die Zeit genommen hast um mir weiterzuhelfen!

                        mickym 1 Reply Last reply Reply Quote 0
                        • mickym
                          mickym Most Active @Matt77CHE last edited by

                          @matt77che Na ich hoffe Du bist positiv überzeugt. 😉 - Ich verstehe ja auch nicht, warum gerade Anfänger immer alle zum Puzzeln überredet werden.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          Support us

                          ioBroker
                          Community Adapters
                          Donate

                          787
                          Online

                          31.7k
                          Users

                          79.8k
                          Topics

                          1.3m
                          Posts

                          2
                          16
                          639
                          Loading More Posts
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes
                          Reply
                          • Reply as topic
                          Log in to reply
                          Community
                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                          The ioBroker Community 2014-2023
                          logo