Controlling several groups of hue light

#1

Hi there,

My target is to change brightness of Hue lights in several groups simultanuously back and forth when motion is detected.

At first I tried using the alert functionality, but the problem was that light state changes were often indicated even when the alert was already stopped due to which I losted the original states of the lights and was not able to return lights back to the states they were before the alert started.

Then I decided to do the alert functionality manually. I soon noticed that the system fails to receive every commands sent if they were sent too close to each other. I solved this by defining 2s transition time for the change of brightness and adding 2200ms delay before the next command. I also defined a new light group that contains all the lights (in multiple rooms) I want to control so that only one command is needed at a time.

The remaining problem is that when the motion is over I need to recover the light states to the time before the motion started and I cannot do that with just one command because the states of different lights were not originally the same. So several commands are needed and the problem is again the same: the system seems to lost some of the commands sent simultanuously. This is seen so that some of the lights do not return to the original state.

Does anyone know any workaround for this?

I’m running Hassio in RaspberryPi connected to Philips Hue bridge. Hue Magic is used for controlling the lights from Node-Red.

0 Likes

#2

Upon motion, store the states in flow/global context variables.
Use those to return back to the original states. You can do that in 1 go with a function node and a loop.
Can you post your flow ?

0 Likes

#3

To build on @bakman2 reply there’s an example in the cookbook about storing context values
https://cookbook.nodered.org/basic/route-on-context

0 Likes

#4

Yes, I have got the original states already stored, but I may do something wrong when setting them back. I currently set them back parallel, it should probably be done in loop as suggested. Setting them parallel seem to cause problems in the system and some of the commands wont go through.

When using a loop, how do I know when the previous command has been sent? Should the light node be part of the loop or should there be just an input line to the light node from a loop node? That is the way I have done it currently...

0 Likes