NEWS
Was ist an dem Switch Node falsch?
-
Der >= Zweig soll den Wert von {(node-red.0.UserData.MaxBat)} annehmen.
[ { "id": "5fcf69d9.6b13b", "type": "switch", "z": "cd8dce56.ce8c28", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "lte", "v": "76", "vt": "num" }, { "t": "gte", "v": "{(node-red.0.UserData.MaxBat)}", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 450, "y": 200, "wires": [ [], [] ] } ]
Mod-Edit: Code/Log in Code Tags gepackt. Bitte benutzt die Code Tags Funktion -> </>
Hier gehts zur Hilfe. -
@Theo56 wat..
punkt 1 : Code gehört inden code tag
punkt 2: geht die Beschreibung deines begehren auch umfangreicher alssoll den Wert annhemen
-
Du schreibst etwas an Ausgang 1 wenn es 76 ist - weitere Verarbeitung nicht sichtbar, sonst willst Du einen Datenpunkt unter Ausgang 2 schreiben.
Dann musst da aber nicht den Pfad angeben, sondern Ausgang 2 mit einer iobroker out Node verbinden. Und als Bedingung für Ausgang 2 nimmst Du "Anderenfalls".
-
@mickym sagte in Was ist an dem Switch Node falsch?:
Du schreibst etwas an Ausgang 1 wenn es 76 ist - weitere Verarbeitung nicht sichtbar, sonst willst Du einen Datenpunkt unter Ausgang 2 schreiben.
Dann musst da aber nicht den Pfad angeben, sondern Ausgang 2 mit einer iobroker out Node verbinden. Und als Bedingung für Ausgang 2 nimmst Du "Anderenfalls".
Sorry, ich habe das ganze etwas reduziert wegen der Übersicht.
Ich habe einen Datenpunkt der mir die ist Akkuladung in Prozent angibt,
des weiteren habe ich zwei Datenpunkte die ich verändern kann zwischen
denen sich die Akkuladung bewegen soll. Beim Überschreiten von "MaxBat"
soll "3306" ausgeschaltet werden und beim unterschreiten von "MinBat" entsprechend an.Hier noch mal der komplette Flow.
code_text [ { "id": "cd8dce56.ce8c28", "type": "tab", "label": "Flow 3", "disabled": false, "info": "" }, { "id": "4cafdbe0.9ef7cc", "type": "ui_numeric", "z": "cd8dce56.ce8c28", "name": "MinBat", "label": "MinBat", "tooltip": "", "group": "3b2f020e.416706", "order": 7, "width": 3, "height": 1, "wrap": true, "passthru": true, "topic": "node-red.0.UserData.MinBat", "format": "{{value}}", "min": "20", "max": "90", "step": 1, "x": 90, "y": 380, "wires": [ [ "9e4ac02d.46ca4" ] ] }, { "id": "a81f2015.e1eca", "type": "ui_numeric", "z": "cd8dce56.ce8c28", "name": "", "label": "MaxBat", "tooltip": "", "group": "3b2f020e.416706", "order": 8, "width": 3, "height": 1, "wrap": true, "passthru": true, "topic": "node-red.0.UserData.MaxBat", "format": "{{value}}", "min": "50", "max": "90", "step": 1, "x": 100, "y": 440, "wires": [ [ "292800ad.98fe48" ] ] }, { "id": "292800ad.98fe48", "type": "ioBroker out", "z": "cd8dce56.ce8c28", "name": "", "topic": "node-red.0.UserData.MaxBat", "ack": "true", "autoCreate": "true", "stateName": "MaxBat", "role": "", "payloadType": "number", "readonly": "", "stateUnit": "", "stateMin": "", "stateMax": "", "x": 380, "y": 440, "wires": [] }, { "id": "9e4ac02d.46ca4", "type": "ioBroker out", "z": "cd8dce56.ce8c28", "name": "", "topic": "node-red.0.UserData.MinBat", "ack": "true", "autoCreate": "true", "stateName": "MinBat", "role": "", "payloadType": "number", "readonly": "", "stateUnit": "", "stateMin": "", "stateMax": "", "x": 380, "y": 380, "wires": [] }, { "id": "87795df4.fd4298", "type": "ioBroker in", "z": "cd8dce56.ce8c28", "name": "mqtt.0.stat.3306.POWER", "topic": "mqtt.0.stat.3306.POWER", "payloadType": "value", "onlyack": false, "func": "all", "gap": "", "fireOnStart": "false", "x": 150, "y": 320, "wires": [ [ "222ae420.e96f3c" ] ] }, { "id": "a8675bc8.c0dce", "type": "ioBroker out", "z": "cd8dce56.ce8c28", "name": "mqtt.0.cmnd.3306.POWER", "topic": "mqtt.0.cmnd.3306.POWER", "ack": "false", "autoCreate": "false", "stateName": "", "role": "", "payloadType": "", "readonly": "", "stateUnit": "", "stateMin": "", "stateMax": "", "x": 660, "y": 320, "wires": [] }, { "id": "222ae420.e96f3c", "type": "ui_switch", "z": "cd8dce56.ce8c28", "name": "Switch 3306", "label": "3306", "tooltip": "", "group": "3b2f020e.416706", "order": 5, "width": 3, "height": 1, "passthru": false, "decouple": "true", "topic": "mqtt.0.cmnd.3306.POWER", "style": "", "onvalue": "ON", "onvalueType": "str", "onicon": "", "oncolor": "", "offvalue": "OFF", "offvalueType": "str", "officon": "", "offcolor": "", "x": 390, "y": 320, "wires": [ [ "a8675bc8.c0dce" ] ] }, { "id": "527a9c03.28c3a4", "type": "switch", "z": "cd8dce56.ce8c28", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "lte", "v": "(node-red.0.UserData.MinBat)", "vt": "num" }, { "t": "gte", "v": "(node-red.0.UserData.MaxBat)", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 130, "y": 100, "wires": [ [ "27a49a26.83bf6e" ], [ "cc52ab3e.a8508" ] ] }, { "id": "4924f6f2.ceae9", "type": "ui_text", "z": "cd8dce56.ce8c28", "group": "3b2f020e.416706", "order": 4, "width": 3, "height": 1, "name": "", "label": "Ladegerät: ", "format": "{{msg.payload}}", "layout": "row-left", "x": 610, "y": 80, "wires": [] }, { "id": "f6251bb0.fd2c4", "type": "debug", "z": "cd8dce56.ce8c28", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 610, "y": 40, "wires": [] }, { "id": "65aef069.8bb1b", "type": "debug", "z": "cd8dce56.ce8c28", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 610, "y": 180, "wires": [] }, { "id": "27a49a26.83bf6e", "type": "change", "z": "cd8dce56.ce8c28", "name": "", "rules": [ { "t": "change", "p": "payload", "pt": "msg", "from": "payload", "fromt": "msg", "to": "ON", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 320, "y": 80, "wires": [ [ "f6251bb0.fd2c4", "4924f6f2.ceae9", "f5255751.c74908" ] ] }, { "id": "cc52ab3e.a8508", "type": "change", "z": "cd8dce56.ce8c28", "name": "", "rules": [ { "t": "change", "p": "payload", "pt": "msg", "from": "payload", "fromt": "msg", "to": "OFF", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 320, "y": 120, "wires": [ [ "4924f6f2.ceae9", "65aef069.8bb1b", "f5255751.c74908" ] ] }, { "id": "b69bcb8b.3a09e", "type": "ioBroker in", "z": "cd8dce56.ce8c28", "name": "", "topic": "mqtt.0.batterie", "payloadType": "object", "onlyack": "", "func": "all", "gap": "", "fireOnStart": "false", "x": 110, "y": 240, "wires": [ [ "cad5f9b6.6aeaa" ] ] }, { "id": "cad5f9b6.6aeaa", "type": "change", "z": "cd8dce56.ce8c28", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload.val", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 370, "y": 240, "wires": [ [ "527a9c03.28c3a4" ] ] }, { "id": "f5255751.c74908", "type": "ioBroker out", "z": "cd8dce56.ce8c28", "name": "mqtt.0.cmnd.3306.POWER", "topic": "mqtt.0.cmnd.3306.POWER", "ack": "false", "autoCreate": "false", "stateName": "", "role": "", "payloadType": "", "readonly": "", "stateUnit": "", "stateMin": "", "stateMax": "", "x": 660, "y": 120, "wires": [] }, { "id": "3b2f020e.416706", "type": "ui_group", "z": "", "name": "Batterie", "tab": "1bcc7a46.432a96", "order": 2, "disp": true, "width": "7", "collapse": false }, { "id": "1bcc7a46.432a96", "type": "ui_tab", "z": "", "name": "Handy Test", "icon": "dashboard", "order": 12, "disabled": false, "hidden": false } ]
-
So ich habs nun verstanden.
Das was Du willst ist nun klarer.
Zum einen ist mir aufgefallen, dass Du aus mqtt.0 das Objekt rausliest, anstelle des Wertes und dann aus dem Objekt den Wert wieder in die payload schreibst. Was für einen Sinn gibt das?Warum Du glaubst, dass Dir der Pfad in Klammern im Switch Node Dir etwas aus iobroker ausliest - ist mir nicht begreiflich. Dann bräuchte man ja gar keine iobroker Nodes mehr.
Speichere Dir die iobroker Werte in Flow Variablen und gut ist.Ausserdem musst Du alles in numersiche Werte umwandeln.
Die Pfade in den iobroker Nodes - ggf. nochmal über den Selektor auswählen - ich würde die Daten nicht unter dem node-red Ast speichern - sondern wirklich unter user-data.
In Deinen Change Node - nach dem Switch willst Du die payload nicht "ändern" sondern "festlegen". Ich habs mal geändert.
Ohne dass ich das nun nachprüfen kann - sollte es so einigermaßen funktionieren:
[ { "id": "1167d472.5e682c", "type": "tab", "label": "Flow 3", "disabled": false, "info": "" }, { "id": "b683b024.d8c0f", "type": "ui_numeric", "z": "1167d472.5e682c", "name": "MinBat", "label": "MinBat", "tooltip": "", "group": "75d76f4d.fd23f", "order": 7, "width": 3, "height": 1, "wrap": true, "passthru": true, "topic": "node-red.0.UserData.MinBat", "format": "{{value}}", "min": "20", "max": "90", "step": 1, "x": 90, "y": 380, "wires": [ [ "a14b691d.5f0ff8" ] ] }, { "id": "545f3468.4ad25c", "type": "ui_numeric", "z": "1167d472.5e682c", "name": "", "label": "MaxBat", "tooltip": "", "group": "75d76f4d.fd23f", "order": 8, "width": 3, "height": 1, "wrap": true, "passthru": true, "topic": "node-red.0.UserData.MaxBat", "format": "{{value}}", "min": "50", "max": "90", "step": 1, "x": 100, "y": 440, "wires": [ [ "7b946733.158fa8" ] ] }, { "id": "7b946733.158fa8", "type": "ioBroker out", "z": "1167d472.5e682c", "name": "", "topic": "node-red.0.UserData.MaxBat", "ack": "true", "autoCreate": "true", "stateName": "MaxBat", "role": "", "payloadType": "number", "readonly": "", "stateUnit": "", "stateMin": "", "stateMax": "", "x": 380, "y": 440, "wires": [] }, { "id": "a14b691d.5f0ff8", "type": "ioBroker out", "z": "1167d472.5e682c", "name": "", "topic": "node-red.0.UserData.MinBat", "ack": "true", "autoCreate": "true", "stateName": "MinBat", "role": "", "payloadType": "number", "readonly": "", "stateUnit": "", "stateMin": "", "stateMax": "", "x": 380, "y": 380, "wires": [] }, { "id": "2da6ebef.c56a14", "type": "ioBroker in", "z": "1167d472.5e682c", "name": "mqtt.0.stat.3306.POWER", "topic": "mqtt.0.stat.3306.POWER", "payloadType": "value", "onlyack": false, "func": "all", "gap": "", "fireOnStart": "false", "x": 150, "y": 320, "wires": [ [ "2e186847.b79c28" ] ] }, { "id": "20cc5f59.226b4", "type": "ioBroker out", "z": "1167d472.5e682c", "name": "mqtt.0.cmnd.3306.POWER", "topic": "mqtt.0.cmnd.3306.POWER", "ack": "false", "autoCreate": "false", "stateName": "", "role": "", "payloadType": "", "readonly": "", "stateUnit": "", "stateMin": "", "stateMax": "", "x": 660, "y": 320, "wires": [] }, { "id": "2e186847.b79c28", "type": "ui_switch", "z": "1167d472.5e682c", "name": "Switch 3306", "label": "3306", "tooltip": "", "group": "75d76f4d.fd23f", "order": 5, "width": 3, "height": 1, "passthru": false, "decouple": "true", "topic": "mqtt.0.cmnd.3306.POWER", "style": "", "onvalue": "ON", "onvalueType": "str", "onicon": "", "oncolor": "", "offvalue": "OFF", "offvalueType": "str", "officon": "", "offcolor": "", "x": 390, "y": 320, "wires": [ [ "20cc5f59.226b4" ] ] }, { "id": "9fb0e323.29f5d", "type": "switch", "z": "1167d472.5e682c", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "lte", "v": "fMin", "vt": "flow" }, { "t": "gte", "v": "fMax", "vt": "flow" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 490, "y": 180, "wires": [ [ "139cc624.798dca" ], [ "a5fb183e.1610a8" ] ] }, { "id": "350be30a.11554c", "type": "ui_text", "z": "1167d472.5e682c", "group": "75d76f4d.fd23f", "order": 4, "width": 3, "height": 1, "name": "", "label": "Ladegerät: ", "format": "{{msg.payload}}", "layout": "row-left", "x": 970, "y": 160, "wires": [] }, { "id": "aae3d401.061f18", "type": "debug", "z": "1167d472.5e682c", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 970, "y": 120, "wires": [] }, { "id": "a8b9866e.fb43e8", "type": "debug", "z": "1167d472.5e682c", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 970, "y": 260, "wires": [] }, { "id": "139cc624.798dca", "type": "change", "z": "1167d472.5e682c", "name": "setze ON", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "ON", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 640, "y": 160, "wires": [ [ "aae3d401.061f18", "350be30a.11554c", "d7605406.224268" ] ] }, { "id": "a5fb183e.1610a8", "type": "change", "z": "1167d472.5e682c", "name": "setze OFF", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "OFF", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 650, "y": 200, "wires": [ [ "350be30a.11554c", "a8b9866e.fb43e8", "d7605406.224268" ] ] }, { "id": "7067f78c.907d18", "type": "ioBroker in", "z": "1167d472.5e682c", "name": "", "topic": "mqtt.0.batterie", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "fireOnStart": "false", "x": 130, "y": 180, "wires": [ [ "f4d496a7.b1f898" ] ] }, { "id": "d7605406.224268", "type": "ioBroker out", "z": "1167d472.5e682c", "name": "mqtt.0.cmnd.3306.POWER", "topic": "mqtt.0.cmnd.3306.POWER", "ack": "false", "autoCreate": "false", "stateName": "", "role": "", "payloadType": "", "readonly": "", "stateUnit": "", "stateMin": "", "stateMax": "", "x": 1020, "y": 200, "wires": [] }, { "id": "f4d496a7.b1f898", "type": "change", "z": "1167d472.5e682c", "name": "to Number", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "$number(msg.payload)\t", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 330, "y": 180, "wires": [ [ "9fb0e323.29f5d" ] ] }, { "id": "b402a72f.b8e628", "type": "ioBroker in", "z": "1167d472.5e682c", "name": "", "topic": "node-red.0.UserData.MinBat", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "fireOnStart": "true", "x": 160, "y": 540, "wires": [ [ "d7bb12ea.1b636" ] ] }, { "id": "7404e46a.31e65c", "type": "ioBroker in", "z": "1167d472.5e682c", "name": "", "topic": "node-red.0.UserData.MaxBat", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "fireOnStart": "true", "x": 160, "y": 600, "wires": [ [ "d746282e.a8d0b8" ] ] }, { "id": "d746282e.a8d0b8", "type": "change", "z": "1167d472.5e682c", "name": "to Number", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "$number(msg.payload)\t", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 430, "y": 600, "wires": [ [ "c82be5a4.0f5c18" ] ] }, { "id": "d7bb12ea.1b636", "type": "change", "z": "1167d472.5e682c", "name": "to Number", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "$number(msg.payload)\t", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 430, "y": 540, "wires": [ [ "ce7b3f9d.3d8ee" ] ] }, { "id": "ce7b3f9d.3d8ee", "type": "change", "z": "1167d472.5e682c", "name": "", "rules": [ { "t": "set", "p": "fMin", "pt": "flow", "to": "payload", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 660, "y": 540, "wires": [ [] ] }, { "id": "c82be5a4.0f5c18", "type": "change", "z": "1167d472.5e682c", "name": "", "rules": [ { "t": "set", "p": "fMax", "pt": "flow", "to": "payload", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 660, "y": 600, "wires": [ [] ] }, { "id": "75d76f4d.fd23f", "type": "ui_group", "z": "", "name": "Batterie", "tab": "d1132f6b.7638f", "order": 2, "disp": true, "width": "7", "collapse": false }, { "id": "d1132f6b.7638f", "type": "ui_tab", "z": "", "name": "Handy Test", "icon": "dashboard", "order": 12, "disabled": false, "hidden": false } ]
-
@mickym Erst einmal ein Dickes Danke.
Ich muss dazu sagen das ich erst seit einer Woche mit Node-Red und IoBroker was mache,
ich bin ein absoluter Beginner.
Der Hinweis mit den Flow-Variablen war der entscheidende Hinweis (ich wusste nicht mal das es die gibt).
Jetzt funktioniert es so wie es soll.MfG Theo
-
@Theo56 schön, dass es klappt. Den aktuellen Inhalt der Variablen findest Du rechts im Menü unter Kontextdaten
-
@mickym Noch mal Danke.
Das mit den Kontextdaten habe ich schon gefunden,
ich bin noch am experimentieren und entdecke ständig neues.
Ich hoffe das ich mich bei weiteren Fragen wieder melden darf.
MfG Theo