# HUE Wall switch, simple on/off lightbulb

**URL:** <https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204>\
**Category:** General\
**Created:** [12 February 2022 10:14 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204 "2022-02-12T10:14:10Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rosenlunden](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rosenlunden/32/56269_2.png) [@Rosenlunden](https://discourse.nodered.org/u/Rosenlunden)\
**Post date:** [12 February 2022 10:14 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/1 "2022-02-12T10:14:10Z")

</div>

Hi'

I am a Nod-Red beginner, and kindly ask for som guidens for 'a simple light on/off' solution

 ![Skærmbillede 2022-02-12 kl. 11.01.32](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/f/af7e0b015342a7040f71f23c201a68e472ee85f5.png)

The wall switch is not given a simple out 'true/on', therefor it must 'through something' before my bulb can use it 🙂

Screendumps of how to, would be very appreciated 🙂

Thanks' in advance..... and for a lots of good topics in this forum

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [12 February 2022 16:26 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/2 "2022-02-12T16:26:47Z")

</div>

Hi @Rosenlunden

Welcome to the forums.

I don't use HUE in Node RED - but, after a quick glimpse into it:  
You can use the `toggle` command.

so...

Add a `function` node to check if the wall switch event is:

- `msg.payload.button === 2`
- `msg.payload.action === 'short_release'`

if so, send the `toggle` command, to your target light.  
You may be able to use the `switch` node instead of a function node, using JSONata to achieve the same thing.

Again, I don't use HUE in Node RED, so others might have a better approach.

---

<div class="post-metadata">

**Author:** ![Rosenlunden](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rosenlunden/32/56269_2.png) [@Rosenlunden](https://discourse.nodered.org/u/Rosenlunden)\
**Post date:** [12 February 2022 18:20 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/3 "2022-02-12T18:20:46Z")

</div>

Hi @marcus-j-davies

Thanks' for your effort, helping me on this one... 🙂

I am not sure that I am doing the right thing?

 ![Skærmbillede 2022-02-12 kl. 19.08.16](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/66c99e298926d99714119dcb4ce814e7c52bf200.png)

I have put this in 'On message':

 ![Skærmbillede 2022-02-12 kl. 19.09.16](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/3545a1c9e89edc7d7966ee406d629b6204f2c811.png)

But where/how to 'put' the toggle command?

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [12 February 2022 18:36 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/4 "2022-02-12T18:36:18Z")

</div>

Hi @Rosenlunden

Try this in your `function` node.  
What we are doing here, is checking what has been triggered on the wall switch and sending a `toggle` command to the light, based on your requirements.

make sure to connect this function node to the bulb.

```javascript
const Button = msg.payload.button;
const Action = msg.payload.action;

if(Button === 2 && Action === 'short_release'){
    return {payload:'toggle'}
}

```

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [12 February 2022 18:40 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/5 "2022-02-12T18:40:05Z")

</div>

Do you have a hue hub as well or just the bulb?

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [12 February 2022 18:43 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/6 "2022-02-12T18:43:21Z")

</div>

I believe this is the HUE Magic modules based on the nodes in the screenshot, which is for the HUB

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [12 February 2022 18:45 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/7 "2022-02-12T18:45:20Z")

</div>

I understand that but Philips makes a hub specifically to control their devices, I wonder if he has one of those as it can be used to control the bulb as well.  
[Edit] trying to understand fully his environment

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [12 February 2022 18:49 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/8 "2022-02-12T18:49:03Z")

</div>

I see.

Indeed! I do all my HUE stuff within the HUB its self.  
I'm pretty sure the HUE mobile app guides you in setting up the remote to control lights.

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [12 February 2022 18:53 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/9 "2022-02-12T18:53:21Z")

</div>

My other question would be: when is the last time that node was updated? I never found a hue node that was updated newer than 2 years ago. I also never got any nodes to work so I rolled my own.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [12 February 2022 18:57 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/10 "2022-02-12T18:57:14Z")

</div>

The latest HUE API does push notification (via HTTP multipart text streams)  
I was able to use it - but its a little cumbersome.

Could be handy for newer implementations.

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [12 February 2022 18:59 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/11 "2022-02-12T18:59:33Z")

</div>

That's the hue stuff. I question that even if he gets his code right whether the node he is using will work. He may be fighting multiple problems.

---

<div class="post-metadata">

**Author:** ![Rosenlunden](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rosenlunden/32/56269_2.png) [@Rosenlunden](https://discourse.nodered.org/u/Rosenlunden)\
**Post date:** [12 February 2022 19:10 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/12 "2022-02-12T19:10:52Z")

</div>

Correct, it is the HUE Magic modules that I am using  
Because I thought it would be the "best" native way to control the HUE switch's, bulb's ect.

@marcus-j-davies, I am getting close.. learning 🙂

 ![Skærmbillede 2022-02-12 kl. 19.51.10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/d/9d197b5a9827249ba1349f2a4fa3431026b71bca.png)

Last step.... How to 'toggle' -\> 'true' / 'false' to the bulb

If changing {payload:'toggle'} to {payload:true} I can direct, turn on the bulb

 ![Skærmbillede 2022-02-12 kl. 20.04.15](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/c/3c8029bc1bb72f5f72bb33382a7c3b8407d61210.png)

But... what to trigger the off command then? (I think it need to be 'toggle')

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [12 February 2022 19:13 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/13 "2022-02-12T19:13:02Z")

</div>

Payload:false. Works on the hub  
[edit] there is a developers web site by philips, need to sign up but it is free, has an absolute ton of info on their system. I signed up several years ago. They make it real easy to use their stuff and TOTALLY support those of us who roll our own code.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [12 February 2022 19:25 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/14 "2022-02-12T19:25:43Z")

</div>

In theory, the `toggle` command will switch it off/on based on _current_ state.  
At least that's my undertsanding.

By extension on @gerry's comment.

You could also store the current state of the light bulb, whenever the bulb node sends an update.  
then, when you see the wall switch event - send either` {payload:false}` or `{payload:true}`, based on the last status you captured.

storing data is fairly straight forward  
`flow.set("SomeName","SomeValue")`

Retrieving it also  
`flow.get("SomeName")`

As I do not use the HUE Nodes. - these are just best guesses.  
but I would have thought the `toggle` command will be good for you use.

---

<div class="post-metadata">

**Author:** ![Rosenlunden](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rosenlunden/32/56269_2.png) [@Rosenlunden](https://discourse.nodered.org/u/Rosenlunden)\
**Post date:** [12 February 2022 20:10 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/15 "2022-02-12T20:10:45Z")

</div>

Hi @marcus-j-davies and @gerry

Right now, this 'basic' solution works... not optimal, but for now.... I can turn on/off the bulb

 ![Skærmbillede 2022-02-12 kl. 20.55.17](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/f/2f3c13390e1026ffaac087636ab31b60a01e27ef.png)

(Had to drop the 'HUE Magic bulb' and go for the 'call service'.... then I could 'toggle')

 ![Skærmbillede 2022-02-12 kl. 20.57.59](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/7/f78b96954bf43e7657a04452d109af3daa350c0b.png)

I think I will just 'remove' the HUE Magic nodes.  
But before that, I have a second issue.... 🙂  
I am not able to "find" the HUE wall switch in the 'Entity ID' (call service)?

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [12 February 2022 20:15 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/16 "2022-02-12T20:15:32Z")

</div>

Hi @Rosenlunden

My HA know how is zero!  
Not many HA users around here - but i'm sure someone will know.

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [12 February 2022 21:52 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/17 "2022-02-12T21:52:05Z")

</div>

As stated before, I don't think that node has been updated for several years, I never got it to work so don't know what to say about that issue. Other than that you can get hue to work with node red and it works well. You have to program it up yourself though.

---

<div class="post-metadata">

**Author:** ![Rosenlunden](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rosenlunden/32/56269_2.png) [@Rosenlunden](https://discourse.nodered.org/u/Rosenlunden)\
**Post date:** [13 February 2022 01:22 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/18 "2022-02-13T01:22:02Z")

</div>

Hi' @marcus-j-davies and @gerry

Thanks' for your help.... much appreciated 🙂  
I will create another topic regarding the "missing" HUE wall switch in the 'Entity ID' (call service)

I think the HUEmagic is still alive:

> **[node-red-contrib-huemagic](https://www.npmjs.com/package/node-red-contrib-huemagic)**
>
> Philips Hue node to control bridges, lights, groups, scenes, rules, taps, switches, buttons, motion sensors, temperature sensors and Lux sensors using Node-RED.. Latest version: 4.1.0, last published: a month ago. Start using...

 ![Skærmbillede 2022-02-13 kl. 02.15.06](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/35dac9b13718b6eac8c9f1bbdecb2915a3b929f7.png)

---

<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:** [14 April 2022 01:22 UTC](https://discourse.nodered.org/t/hue-wall-switch-simple-on-off-lightbulb/58204/19 "2022-04-14T01:22:06Z")

</div>

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