# Turn on/ off with switch node a zigbee device

**URL:** <https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881>\
**Category:** General\
**Created:** [24 June 2020 11:23 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881 "2020-06-24T11:23:14Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![get-command](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/get-command/32/25038_2.png) [@get-command](https://discourse.nodered.org/u/get-command)\
**Post date:** [24 June 2020 11:23 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/1 "2020-06-24T11:23:14Z")

</div>

Hello

I need your help again 🙂

I have built e simple flow. Inject-node -\> switch-node -\> Action (e.g. light on/off). this function very well:

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/55368cdf8b34726f5f0ca51d8eab06bb5dddeffb.png)

but i change the nodes lights with a "osram zigbee light", then function this not:

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/c/9c4f801991ce3ad231174cdfc53ff51c496ae31a.png)

I understand this not. is a inject-node, then can i start the osram zigbee light without problem

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/9/4951b519fe803729e565f7e3c78b6dfce7c08c88.png)

can someone please explain that to me?? Thank

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [24 June 2020 21:58 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/2 "2020-06-24T21:58:25Z")

</div>

After the `smartbutton zigbee` node put a `debug` node.

See what it is sending.

There is a possibility it is sending a _text_ 1 rather than a _number_ 1.  
And so the `switch` node won't know what to do with the signal.

 ![blah](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1a6fb6186c81708eafd1bb95e8a4a64b32343a60.png)

---

<div class="post-metadata">

**Author:** ![get-command](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/get-command/32/25038_2.png) [@get-command](https://discourse.nodered.org/u/get-command)\
**Post date:** [24 June 2020 22:15 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/3 "2020-06-24T22:15:33Z")

</div>

> [@Trying\_to\_learn](#):
>
> After the `smartbutton zigbee` node put a `debug` node

Hi, thanks for reply.  
Right. It is a zigbee device is a button. This is not the Problem. The Problem is the Interface between Switch and light. When i use e.g. a Non zigbee light, Then function well

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [24 June 2020 22:18 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/4 "2020-06-24T22:18:32Z")

</div>

I think you are really missing what I am asking you to do.

You are saying the `switch` node isn't _working_.

I'm pretty sure it is. You just don't have something set correctly.

Again: Put a `debug` node where I showed you, make it show **all** the message. `deploy` and get the _zigbee_ thing to send a message.

What appears in the `debug` output?

Oh, and I don't think this is helping:

![blah](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/8/88af52dd885485f04c94ed3050d4d1c95cb83ca6.png)

But until you have the `debug` node and show the output, I can't be 100% sure.

---

<div class="post-metadata">

**Author:** ![get-command](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/get-command/32/25038_2.png) [@get-command](https://discourse.nodered.org/u/get-command)\
**Post date:** [25 June 2020 06:51 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/5 "2020-06-25T06:51:21Z")

</div>

Hi,

I had done that. When i click the button, then i get the fellows output in the debug window:

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/e/de5fc564412c4abfa7e195e6e77fecb1fc1d4844.png)

---

<div class="post-metadata">

**Author:** ![DamianosS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/damianoss/32/16990_2.png) [@DamianosS](https://discourse.nodered.org/u/DamianosS)\
**Post date:** [25 June 2020 07:02 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/6 "2020-06-25T07:02:14Z")

</div>

I think, @Trying_to_learn means that:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/0/101a411956724cfc28462a21c9e51aa3bbc97e7a.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [25 June 2020 07:20 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/7 "2020-06-25T07:20:38Z")

</div>

Sorry, no @DamianosS. I wanted to see the raw output from the `zigbee` node.

But, looking at the `debug` node, I concur is isn't a simple `0` or `1` output.

Alas I am not smart enough to confirm that it is `msg.payload.onOff`

I was suspicious that the `switch` node wasn't seeing the correct information in the message.

Someone else is going to have to help you why it isn't working. But I feel it is the `switch` node and what you have in the `msg......` part.

What you could try is click where I indicate (expand the tree)

 ![blah](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/a/9a13d4a42b82168d976e8f7bcf380c454c1cee15.png)

Then you can find out what the correct `path` is.  
That will be selectable to the right with the `>_` icon (copy path).

Then you paste it in the `msg......` part of the `switch` node.

Well, that's what I think you need to do.

Though I shall (now) admit it would be a good idea to do what @DamianosS did suggest also.  
That way you see the message coming out of the `zigbee` node and then the message/s going to the other (purple) nodes.

---

<div class="post-metadata">

**Author:** ![get-command](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/get-command/32/25038_2.png) [@get-command](https://discourse.nodered.org/u/get-command)\
**Post date:** [25 June 2020 07:31 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/8 "2020-06-25T07:31:05Z")

</div>

thank you DamianosS for reply

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c0c12fe505075eaff41151dc00bbfaef040ea304.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [25 June 2020 07:35 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/9 "2020-06-25T07:35:45Z")

</div>

Ok, so we have moved on a bit quicker.

All is good.

But there is now a problem with the `payloads`.

**one** fix is to do this:

Put a `change` node between the `switch` and the `debug` node. (Two in total)

So the flow would look like this:

 ![Screenshot from 2020-06-25 17-33-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b9bb6b2b28808058ff02c7005f893184524e680a.png)

Then each `change` node would be:

 ![Screenshot from 2020-06-25 17-34-10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f9f9de43d153464e2f60b12626ed58bb71d60017.png)

Of course one would be `1` and the other be a `0`.

That will fix the problem with the _wrong_ `payload`. you just feed that output into the _purple_ nodes to switch the light on/off.

---

<div class="post-metadata">

**Author:** ![get-command](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/get-command/32/25038_2.png) [@get-command](https://discourse.nodered.org/u/get-command)\
**Post date:** [25 June 2020 07:48 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/10 "2020-06-25T07:48:30Z")

</div>

> [@Trying\_to\_learn](#):
>
> What you could try is click where I indicate (expand the tree)

thanks for help...

Here the screenshot:

![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/c/ace67d782208eab3ee108ca74a3fd88f884837e6.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [25 June 2020 07:50 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/11 "2020-06-25T07:50:38Z")

</div>

Yeah, so you move the mouse to the `onOff` line and look to the right you will see the `>_` icon.

But that is by the by. Stick a `change` node as I showed above and set them as I showed and they will convert the `msg.payload` to either `0` or `1`.

---

<div class="post-metadata">

**Author:** ![get-command](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/get-command/32/25038_2.png) [@get-command](https://discourse.nodered.org/u/get-command)\
**Post date:** [25 June 2020 07:54 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/12 "2020-06-25T07:54:54Z")

</div>

> [@Trying\_to\_learn](#):
>
> Yeah, so you move the mouse to the `onOff` line and look to the right you will see the `>_` icon.

![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/e/5e91f792db0adc64e96fe67d2dc52b15ade93879.png)

result:  
payload.onOff

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [25 June 2020 07:56 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/13 "2020-06-25T07:56:10Z")

</div>

Correct. That is/was just FYI.

But to get the bulb to turn on or off as you want, you will need to use the `change` nodes.

---

<div class="post-metadata">

**Author:** ![get-command](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/get-command/32/25038_2.png) [@get-command](https://discourse.nodered.org/u/get-command)\
**Post date:** [25 June 2020 09:34 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/14 "2020-06-25T09:34:32Z")

</div>

thank you for your great efforts. but unfortunately that doesn't work with a switch node either. I'm starting to despair. if I replace the switch node with an inject not, then I can switch the lamp on and off. when i change the zigbee-light-node with a RF433 light/bulb then function this very well. this is a sign that the switch node is set correctly. the command is passed on.

now i even get an error message

Error: Command 0x00158d0XXXXXXXX/1 genOnOff.on({"onOff":0}, {"timeout":6000,"manufacturerCode":null,"disableDefaultResponse":false}) failed (Error: Timeout - 40061 - 1 - 210 - 6 - 11 after 6000ms)

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/b/eb2fca44689ce028dd692cc923bd171e513a9571.png)

if you manually click the button, it works too

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/873059f46e252777bd15a801389cb5c92d97aabb.png)

difficult thing ☹ 😩 😫 😤

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [25 June 2020 09:42 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/15 "2020-06-25T09:42:13Z")

</div>

> [@get-command](#):
>
> but unfortunately that doesn't work with a switch node either. I'm starting to despair.

So why did you include it in your posts? You (basically) stuck it there in your examples so much as to say "But this works!".

I would suggest you forget the `zigbee` part until you get the turning the lights on/off working.  
Once you can see you can turn them on/off (or what ever it is you want to do) **then** you start putting things at the input to do it _automagically_.

Alas it is kind of going backwards. But there is good reason for this.

At the end you want something to happen. (That is at the _end_ of the code. Therefore at the right of the screen.)

Once you get that working with an `inject` node sending **simple** messages, you then start to build the flow (program/code) from right to left.

If something stops working, you can then establish where it stopped working.

This way you are really throwing yourself in the deep end and there are a lot of unknowns.

By all means do it. (I have done it a lot.) But there are limits to what people can (and will) do to help you.

I also have a whole lot of other problems I am trying to work out for myself. (See my name?)

Good luck.

---

<div class="post-metadata">

**Author:** ![get-command](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/get-command/32/25038_2.png) [@get-command](https://discourse.nodered.org/u/get-command)\
**Post date:** [27 June 2020 13:24 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/16 "2020-06-27T13:24:09Z")

</div>

I found the solution with help from Developer this Nodes.

The Problem was, the ZigBee-Smartbutton sends own Attributes and overwrite/delete the attributtes from the Zigbee Bulb. With a function node between bulb and switch reset the Attributs from zigbee smartbutton. This function now !

The Content of the function node:

msg = {};  
msg.payload = true;  
return msg;

this reset all information from the zigbee smartbutton. great thanks for help!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 July 2020 13:24 UTC](https://discourse.nodered.org/t/turn-on-off-with-switch-node-a-zigbee-device/28881/17 "2020-07-11T13:24:12Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
