# Simple node Problem

**URL:** <https://discourse.nodered.org/t/simple-node-problem/20471>\
**Category:** General\
**Created:** [16 January 2020 19:36 UTC](https://discourse.nodered.org/t/simple-node-problem/20471 "2020-01-16T19:36:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![corin.corvus](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@corin.corvus](https://discourse.nodered.org/u/corin.corvus)\
**Post date:** [16 January 2020 19:36 UTC](https://discourse.nodered.org/t/simple-node-problem/20471/1 "2020-01-16T19:36:34Z")

</div>

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.

```auto
[{"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 😕

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [16 January 2020 19:54 UTC](https://discourse.nodered.org/t/simple-node-problem/20471/2 "2020-01-16T19:54:35Z")

</div>

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.

> [@corin.corvus](#):
>
> i tried to create an easy node.

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

---

<div class="post-metadata">

**Author:** ![corin.corvus](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@corin.corvus](https://discourse.nodered.org/u/corin.corvus)\
**Post date:** [16 January 2020 20:01 UTC](https://discourse.nodered.org/t/simple-node-problem/20471/3 "2020-01-16T20:01:28Z")

</div>

hi,

i changed the name.

i can upload screenshots if it helps.  
Flow:

 ![2020-01-16 20_17_24-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/b/0b82759051f52f9b4c2cf3bf19add2106377d4f7.jpeg)  
Switch:  
 ![2020-01-16 20_17_17-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c78ff7432d4934a2e8c754bd6df24362f01e6673.jpeg)

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"**

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [16 January 2020 20:09 UTC](https://discourse.nodered.org/t/simple-node-problem/20471/4 "2020-01-16T20:09:19Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![corin.corvus](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@corin.corvus](https://discourse.nodered.org/u/corin.corvus)\
**Post date:** [16 January 2020 20:18 UTC](https://discourse.nodered.org/t/simple-node-problem/20471/5 "2020-01-16T20:18:02Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/f/df6ff9cc9ab22ed34d355cccac26036dd27659d2.jpeg)

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?!?!

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [16 January 2020 20:37 UTC](https://discourse.nodered.org/t/simple-node-problem/20471/6 "2020-01-16T20:37:03Z")

</div>

Can you try;

![switch](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/08e454b6b66797ca988ceb150342b8453f122e2d.jpeg)

---

<div class="post-metadata">

**Author:** ![corin.corvus](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@corin.corvus](https://discourse.nodered.org/u/corin.corvus)\
**Post date:** [16 January 2020 20:44 UTC](https://discourse.nodered.org/t/simple-node-problem/20471/7 "2020-01-16T20:44:07Z")

</div>

Now the switch dont move  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/4/440c5cbf44d536ddb827e70a0a07007b48965dfc.png)

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [16 January 2020 20:44 UTC](https://discourse.nodered.org/t/simple-node-problem/20471/8 "2020-01-16T20:44:48Z")

</div>

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

![switch](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/ef373086c4c38d2fef991bf925b06faba83bfcd9.jpeg)

---

<div class="post-metadata">

**Author:** ![corin.corvus](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@corin.corvus](https://discourse.nodered.org/u/corin.corvus)\
**Post date:** [16 January 2020 20:47 UTC](https://discourse.nodered.org/t/simple-node-problem/20471/9 "2020-01-16T20:47:48Z")

</div>

it works!!!  
Thank you!
