Simple node Problem

Hi,

i am a very new user with node-red.

i tried to create an easy flow.
Plan:
if the lamp is on, the energy switch go on, the lamp is of, the switch go off.

[{"id":"74f43ebb.4b4358","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"46fe5dd8.25e8ec","type":"hue-light","z":"74f43ebb.4b4358","name":"Büro Deckenlampe","bridge":"f70f5ac6.7c46e8","lightid":"9","colornamer":true,"skipevents":false,"x":130,"y":80,"wires":[["a617d743.cea4c8","47fcaf07.62706"]]},{"id":"47fcaf07.62706","type":"debug","z":"74f43ebb.4b4358","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1210,"y":360,"wires":[]},{"id":"a617d743.cea4c8","type":"switch","z":"74f43ebb.4b4358","name":"","property":"payload:on","propertyType":"msg","rules":[{"t":"eq","v":"payload.on:true","vt":"msg"},{"t":"neq","v":"payload.on:true","vt":"msg"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":80,"wires":[["ef0ba2c2.c38b1"],["2eb9d865.05de68"]]},{"id":"f6af3d17.3c813","type":"mqtt out","z":"74f43ebb.4b4358","name":"","topic":"buero-sonoffvaleshi1/cmnd/POWER","qos":"0","retain":"false","broker":"d50c9ad0.bf34","x":1090,"y":120,"wires":[]},{"id":"ef0ba2c2.c38b1","type":"change","z":"74f43ebb.4b4358","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":40,"wires":[["47fcaf07.62706","aefdbed2.d4b788"]]},{"id":"2eb9d865.05de68","type":"change","z":"74f43ebb.4b4358","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":120,"wires":[["f6af3d17.3c813","47fcaf07.62706"]]},{"id":"aefdbed2.d4b788","type":"mqtt out","z":"74f43ebb.4b4358","name":"","topic":"buero-sonoffvaleshi1/cmnd/POWER","qos":"0","retain":"false","broker":"d50c9ad0.bf34","x":1090,"y":40,"wires":[]},{"id":"f70f5ac6.7c46e8","type":"hue-bridge","z":"","name":"Philips hue","bridge":"10.0.0.32","key":"pueds3jjUWZ1pP4UTho85HFwTirFWjpwbJnpDrac","interval":"3000","disableupdates":false},{"id":"d50c9ad0.bf34","type":"mqtt-broker","z":"","name":"Mosquitto","broker":"10.0.0.18","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

i switch the lamp on, "ON" returns, i switch off, "ON" returns...
it dont work :confused:

Hi, welcome to the forum.
I see that you are using 2 nodes which do not form part of the default installation, so that means that other members would need to install them in their own installation so that they could load & test your flow. This discourages members from offering help, therefore it is always better (if possible) just to post the part of the flow which you are having trouble with.

PS we call that a 'flow', as it's a collection of nodes that are joined together.

hi,

i changed the name.

i can upload screenshots if it helps.
Flow:


Switch:
2020-01-16 20_17_17-Window

Change nodes are only delete payload and add a new with "on and off" for mqtt switches.

Log:
This part runs correct:
16.1.2020, 20:16:24[node: 47fcaf07.62706]
msg.payload : Object
{ on: true, brightness: 44, reachable: true, rgb: array[3], hex: "ffbb5c" … }
16.1.2020, 20:16:24[node: 47fcaf07.62706]msg.payload : string[2]
"ON"

This part doesnt run correct:
16.1.2020, 20:16:30[node: 47fcaf07.62706]msg.payload : Object
{ on: false, brightness: 0, reachable: true, rgb: array[3], hex: "ffbb5c" … }
16.1.2020, 20:16:30[node: 47fcaf07.62706]
msg.payload : string[2]
"ON"

Have you tried setting the second switch rule to 'otherwise' (instead of !=), so it tests for rule number one first, and if it does not match, then it will use rule number two.

or

== msg.payload.on:false

If i change to "otherwise" all is similar.

if i change to " == msg.payload.on:false " i have doubleswitch on off:
2020-01-16 21_17_07-Window

both (on and off) move by switch lamp on or off.

it make no sense for me. why the switch dont work like a switch?!?!

Can you try;

switch

Now the switch dont move
grafik

Oh hang on, they are boolean values, and not strings!!
Sorry, I've made hard work of this!!

switch

it works!!!
Thank you!

1 Like