- Home
- Deutsch
- Skripten / Logik
- Node-Red
- Eine Lampe mit 4 Türkontakten visuell darstellen
Eine Lampe mit 4 Türkontakten visuell darstellen
-
Hallo Zusammen,
versuche über Node Red meine Türüberwachung visuell über eine Lampeanzuzeigen.
Aufbau: 1 Lampe 4 Türkontakte. Sobald ein Türkontakt auf ist soll die Lampe leuchten. Wenn kein Türkontakt mehr auf ist sollen die Lampe wieder ausgehen.
Habe es hinbekommen das die Lampe ahngeht. Jetzt besteht aber das Problem, wenn ich ein zweiten Türkontakt öffne leuchtet die Lampe immer noch, ist ja auch richtig so. Doch schließe ich jetzt einen der beiden Türkontakte geht die Lampe aber aus, obwohl ein Türkontakt noch offen ist. Heißt ich bräuchte eine Art "AND" Schaltung aus der Elektrik für den Schließvorgang. Hat da vielleicht jemand mit soetwas Erfahrung oder so etwas schon mal gebaut?
Danke schon einmal für die Hilfe.
-
hallo,
gibt es "npm install node-red-contrib-boolean-logic"
lg.
Stefan -
@Neonfive geht auch mit Boardmitteln. Fasse einfach alle Türkontakte in ein Objekt zusammen und dann habe ich mir eine kleine Function Node mit folgendem Code erstellt:
var x; var obj = msg.payload; var bIsBoolean=true; for (x in obj) { bIsBoolean = bIsBoolean && obj[x]; } msg.payload=bIsBoolean; return msg;
Also kein Hexenwerk. Diese Node gibt nur true aus, wenn alle Elemente des Objektes true sind. Zu einem Objekt zusammenfassen kann man es mit einer Join Node.
-
Ich habe es auch mit dem boolean-logic gelöst:
[ { "id": "46be0da5.a468e4", "type": "tab", "label": "Flow 1", "disabled": false, "info": "" }, { "id": "ac4475ec.52d5b8", "type": "ioBroker in", "z": "46be0da5.a468e4", "name": "Wohnzimmertür.opened", "topic": "zigbee.0.00158d0004a043ca.opened", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "x": 160, "y": 180, "wires": [ [ "3ca48315.b37b84" ] ] }, { "id": "2c3bb2a0.5bb72e", "type": "ioBroker get", "z": "46be0da5.a468e4", "name": "Handy-Rene.active", "topic": "tr-064.0.devices.Handy-Rene.active", "attrname": "payload", "payloadType": "value", "x": 590, "y": 140, "wires": [ [ "be8dc7a.5a85b38" ] ] }, { "id": "69504c53.9b6ccc", "type": "ioBroker get", "z": "46be0da5.a468e4", "name": "Handy-Sarah.active", "topic": "tr-064.0.devices.Handy-Sarah.active", "attrname": "payload", "payloadType": "value", "x": 600, "y": 220, "wires": [ [ "8b809486.69942" ] ] }, { "id": "be8dc7a.5a85b38", "type": "change", "z": "46be0da5.a468e4", "name": "msg.topic to name", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "Handy-Rene.active", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 830, "y": 140, "wires": [ [ "f52cb15f.91e898" ] ] }, { "id": "8b809486.69942", "type": "change", "z": "46be0da5.a468e4", "name": "msg.topic to name", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "Handy-Sarah.active", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 830, "y": 220, "wires": [ [ "f52cb15f.91e898" ] ] }, { "id": "3ca48315.b37b84", "type": "delay", "z": "46be0da5.a468e4", "name": "", "pauseType": "delay", "timeout": "15", "timeoutUnits": "minutes", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "x": 370, "y": 180, "wires": [ [ "2c3bb2a0.5bb72e", "69504c53.9b6ccc" ] ] }, { "id": "f52cb15f.91e898", "type": "BooleanLogic", "z": "46be0da5.a468e4", "name": "", "operation": "OR", "inputCount": 2, "topic": "result", "x": 1030, "y": 180, "wires": [ [ "ed571c8f.9a158" ] ] }, { "id": "3260cc40.51b344", "type": "switch", "z": "46be0da5.a468e4", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 1270, "y": 180, "wires": [ [], [] ] }, { "id": "ed571c8f.9a158", "type": "rbe", "z": "46be0da5.a468e4", "name": "", "func": "rbe", "gap": "", "start": "", "inout": "out", "property": "payload", "x": 1150, "y": 180, "wires": [ [ "3260cc40.51b344" ] ] }, { "id": "9c62aa96.b725f", "type": "change", "z": "46be0da5.a468e4", "name": "5", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "5", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1430, "y": 220, "wires": [ [ "962c1490.94aab" ] ] }, { "id": "e6a2e0e1.3ab168", "type": "change", "z": "46be0da5.a468e4", "name": "19", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "19", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1430, "y": 140, "wires": [ [ "962c1490.94aab" ] ] }, { "id": "962c1490.94aab", "type": "ioBroker out", "z": "46be0da5.a468e4", "name": "Arbeitszimmer_Heizung_manual", "topic": "hm-rpc.0.PEQ1316506.4.SET_TEMPERATURE", "ack": "false", "autoCreate": "false", "x": 1650, "y": 180, "wires": [] }, { "id": "7ca4ad58.b223ac", "type": "ioBroker in", "z": "46be0da5.a468e4", "name": "Esszimmer_Fensterkontakt_rechts", "topic": "zigbee.0.00158d0004a04457.opened", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "x": 340, "y": 600, "wires": [ [ "bff2ca9.3d12238", "9eb9a72.1c72058", "38f9f14d.89e7de", "5e68f2b.d53928c", "7713bf1e.07af18" ] ] }, { "id": "9da66146.aba9f", "type": "ioBroker out", "z": "46be0da5.a468e4", "name": "Wohnzimmer_Heizung_manual", "topic": "hm-rpc.1.INT0000002.1.SET_TEMPERATURE", "ack": "false", "autoCreate": "false", "x": 1850, "y": 720, "wires": [] }, { "id": "abf22127.54912", "type": "change", "z": "46be0da5.a468e4", "name": "5", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "5", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1370, "y": 720, "wires": [ [ "9da66146.aba9f" ] ] }, { "id": "640bf8e7.d8397", "type": "ioBroker in", "z": "46be0da5.a468e4", "name": "Esszimmer_Fensterkontakt_links", "topic": "zigbee.0.00158d00042cbb68.opened", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "x": 330, "y": 660, "wires": [ [ "bff2ca9.3d12238", "9eb9a72.1c72058", "38f9f14d.89e7de", "5e68f2b.d53928c", "7713bf1e.07af18" ] ] }, { "id": "bff2ca9.3d12238", "type": "ioBroker get", "z": "46be0da5.a468e4", "name": "Esszimmer_Fensterkontakt_rechts_abfrage", "topic": "zigbee.0.00158d0004a04457.contact", "attrname": "payload", "payloadType": "value", "x": 710, "y": 600, "wires": [ [ "44a5fc51.cd2d44" ] ] }, { "id": "9eb9a72.1c72058", "type": "ioBroker get", "z": "46be0da5.a468e4", "name": "Esszimmer_Fensterkontakt_links_abfrage", "topic": "zigbee.0.00158d00042cbb68.contact", "attrname": "payload", "payloadType": "value", "x": 700, "y": 660, "wires": [ [ "eefc2ef4.616fa8" ] ] }, { "id": "44a5fc51.cd2d44", "type": "change", "z": "46be0da5.a468e4", "name": "msg.topic to name", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "Esszimmer_Fensterkontakt_rechts_abfrage", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 990, "y": 600, "wires": [ [ "877d9625.91655" ] ] }, { "id": "eefc2ef4.616fa8", "type": "change", "z": "46be0da5.a468e4", "name": "msg.topic to name", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "Esszimmer_Fensterkontakt_links_abfrage", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 990, "y": 660, "wires": [ [ "877d9625.91655" ] ] }, { "id": "80245c49.6e76b8", "type": "ioBroker in", "z": "46be0da5.a468e4", "name": "Küche_Fensterkontakt_groß", "topic": "zigbee.0.00158d0004a019d0.opened", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "x": 320, "y": 720, "wires": [ [ "bff2ca9.3d12238", "9eb9a72.1c72058", "38f9f14d.89e7de", "5e68f2b.d53928c", "7713bf1e.07af18" ] ] }, { "id": "1813a3b4.dd7f24", "type": "ioBroker in", "z": "46be0da5.a468e4", "name": "Wohnzimmer_Türkontakt", "topic": "zigbee.0.00158d0004a01a68.opened", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "x": 310, "y": 780, "wires": [ [ "bff2ca9.3d12238", "9eb9a72.1c72058", "38f9f14d.89e7de", "5e68f2b.d53928c", "7713bf1e.07af18" ] ] }, { "id": "bba041cb.16ae68", "type": "ioBroker in", "z": "46be0da5.a468e4", "name": "Küche_Fensterkontakt_klein", "topic": "zigbee.0.00158d0004a043f6.opened", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "x": 320, "y": 840, "wires": [ [ "7713bf1e.07af18", "5e68f2b.d53928c", "38f9f14d.89e7de", "9eb9a72.1c72058", "bff2ca9.3d12238" ] ] }, { "id": "38f9f14d.89e7de", "type": "ioBroker get", "z": "46be0da5.a468e4", "name": "Küche_Fensterkontakt_groß", "topic": "zigbee.0.00158d0004a019d0.contact", "attrname": "payload", "payloadType": "value", "x": 660, "y": 720, "wires": [ [ "c6e2d7ae.a72a5" ] ] }, { "id": "5e68f2b.d53928c", "type": "ioBroker get", "z": "46be0da5.a468e4", "name": "Wohnzimmer_Türkontakt_abfrage", "topic": "zigbee.0.00158d0004a01a68.contact", "attrname": "payload", "payloadType": "value", "x": 680, "y": 780, "wires": [ [ "9fbe0c00.f779b8" ] ] }, { "id": "7713bf1e.07af18", "type": "ioBroker get", "z": "46be0da5.a468e4", "name": "Küche_Fensterkontakt_klein_abfrage", "topic": "zigbee.0.00158d0004a043f6.contact", "attrname": "payload", "payloadType": "value", "x": 690, "y": 840, "wires": [ [ "c091f0f0.8940a8" ] ] }, { "id": "c6e2d7ae.a72a5", "type": "change", "z": "46be0da5.a468e4", "name": "msg.topic to name", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "Küche_Fensterkontakt_groß", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 990, "y": 720, "wires": [ [ "877d9625.91655" ] ] }, { "id": "9fbe0c00.f779b8", "type": "change", "z": "46be0da5.a468e4", "name": "msg.topic to name", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "Wohnzimmer_Türkontakt_abfrage", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 990, "y": 780, "wires": [ [ "877d9625.91655" ] ] }, { "id": "c091f0f0.8940a8", "type": "change", "z": "46be0da5.a468e4", "name": "msg.topic to name", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "Küche_Fensterkontakt_klein_abfrage", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 990, "y": 840, "wires": [ [] ] }, { "id": "1ed8257f.5b258b", "type": "comment", "z": "46be0da5.a468e4", "name": "Heizung", "info": "", "x": 250, "y": 540, "wires": [] }, { "id": "e68cd62f.9ac398", "type": "change", "z": "46be0da5.a468e4", "name": "21", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "21", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1630, "y": 600, "wires": [ [ "9da66146.aba9f" ] ] }, { "id": "877d9625.91655", "type": "BooleanLogic", "z": "46be0da5.a468e4", "name": "", "operation": "AND", "inputCount": "4", "topic": "result", "x": 1180, "y": 720, "wires": [ [ "2c2704ee.a7c6fc" ] ] }, { "id": "99622141.ef89", "type": "switch", "z": "46be0da5.a468e4", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 1190, "y": 600, "wires": [ [ "344081a4.4bdac6", "b8457c2.8d484" ], [ "abf22127.54912", "6f15a171.b6f9c8" ] ] }, { "id": "2c2704ee.a7c6fc", "type": "rbe", "z": "46be0da5.a468e4", "name": "", "func": "rbe", "gap": "", "start": "", "inout": "out", "property": "payload", "x": 1190, "y": 660, "wires": [ [ "99622141.ef89" ] ] }, { "id": "344081a4.4bdac6", "type": "ioBroker get", "z": "46be0da5.a468e4", "name": "Tageszeit", "topic": "javascript.0.Tageszeit", "attrname": "payload", "payloadType": "value", "x": 1380, "y": 640, "wires": [ [ "785921b4.432218" ] ] }, { "id": "7d496be2.bd96ac", "type": "change", "z": "46be0da5.a468e4", "name": "17", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "17", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1630, "y": 680, "wires": [ [ "9da66146.aba9f" ] ] }, { "id": "785921b4.432218", "type": "switch", "z": "46be0da5.a468e4", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "neq", "v": "Nacht", "vt": "str" }, { "t": "eq", "v": "Nacht", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 1510, "y": 640, "wires": [ [ "e68cd62f.9ac398" ], [ "7d496be2.bd96ac" ] ] }, { "id": "b8457c2.8d484", "type": "change", "z": "46be0da5.a468e4", "name": "0", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "0", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1370, "y": 780, "wires": [ [ "9b7c7c48.4b461" ] ] }, { "id": "9b7c7c48.4b461", "type": "ioBroker out", "z": "46be0da5.a468e4", "name": "ownStates.wohnzimmer_fenster", "topic": "0_userdata.0.ownStates.wohnzimmer_fenster", "ack": "false", "autoCreate": "false", "stateName": "", "role": "", "stateUnit": "", "stateMin": "", "stateMax": "", "x": 1870, "y": 800, "wires": [] }, { "id": "6f15a171.b6f9c8", "type": "change", "z": "46be0da5.a468e4", "name": "35", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "35", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1370, "y": 840, "wires": [ [ "9b7c7c48.4b461" ] ] } ]
MOD-Edit: Code in code-tags und Spoiler gesetzt!