Making Sure a Hue command actually reaches a Hue Light


#1

1) Give a description of the problem
So, as most found out, when you have a Hue light, which in my case is a Lightstrip Plus, and you power it on (aka plug it in), it comes on to a preset color and level and you (apparently) can’t change that default. Hue would tell you to just use a Hue switch such that the light controller is always on and when toggled it will turn the light on to the last setpoint. So, I’m trying to achieve the same by forcing the light to a desired color when it turns on from the power off state.

Through webCoRE, I can easily check to see if the light switch is on and then check to see if the Hue light is online and then check to see if the Hue light is actually on and finally issue a command but it seems that the command is not received always. Basically, I think I have a race condition and the Hue light isn’t quite ready to receive commands from the Hue base or possibly some sort of cloud-induced latency.

What can I use to detect if the light is actually responsive? I wasn’t able to find a do…while loop or similar.

Also, what does “DeviceWatch-DeviceStatus” really do? Somehow I was not able to figure out where the docs were on that despite a few minutes of searching the Wiki.

Here is the simple piston as it stands now. I first check to see if the wall switch is on, then I (assume) check to see that the Hue bulb is online, and finally I check to see if the Hue bulb is switched on.

Hue Piston

About 25-50% of the time when the wall switch is turned on, the light never changes to the “white” color but in ALL cases, a trace reveals that all three of the IF statements evaluate as true. I of course started out with a much simpler piston but the results are the same if I simplify it to “if wall switch is on, set hue color to white”.

Ideas?


#2

As you are using ‘changes to’ in the first IF after about 10 seconds this will become false and therefore the piston will become false and stop.
This may be your issue.
Can you change the second IF TCP policy to NEVER and see if that works.
EDIT: It might also be worthwhile changing your second IF to:-
IF Hue Lights…
AND
HUE Lights switch is ON.
THEN
.
.
.
.


#3

I personally don’t like nested ifs. They should all be top level is possible. I rewrote this and think I accomplished what you are looking for. Try this, I have not tested though. You can adjust or remove the wait command as needed


#4

I don’t have Hues but surely if the bulb is able to report that it is ‘on’ then it must already be online… so why check?

Maybe a better approach would be to trigger from ‘changes to online’… that way you are not triggering every time you turn the bulb on from the app, just when it gets powered up.


#5

Ok, sorry for the delay - just got sidetracked over the holidays.

@Robin I think the reason I did not do that is there isn’t an “online” variable for the Hue objects as far as I can tell. There is the DeviceWatch-DeviceSatus object but despite its name, I noticed that it seems to never trigger in this case. Likewise, when powering on the Hue, the hue device’s switch doesn’t trigger an on when it turns on (so it seems).

It’s not perfect but it seems to work most of the time if I just check to see if the wall switch turns on and then send the command. This is what I initially tried but found it was unreliable but at least it does trigger. The only add I made was to do a if X and Y to check both the wall switch and the Hue’s switch are on. Seems nuts since checking the Hue’s device’s switch directly doesn’t trigger and checking just the wall switch doesn’t always trigger but I am guessing it’s a race condition and checking both somehow delays just enough to make it more reliable - at least with some limited testing.

Really, the Hue devices need something that tell you it powered up so you can trigger on that. Or Phillips could have just implemented a small feature to change the :“default on” and this would all be unnecessary.

execute

if
Any of Hue Kitchen Task Lights’ or Kitchen Task Lights’ switch changes to on
then
with
Hue Kitchen Task Lights
do
Set color to White;
end with;
end if;

end execute;