Set Colour setting Hue bulb level to 100% when movement detected


#1

1) Give a description of the problem
First time poster here, learning to use WebCoRE. Trying to create a Piston that turns on one Hue bulb when movement detected overnight. If the colour is already set to white then just set the level to 20%. if the colour is not white, then set the colour to White or #FFFFFF and then sets the level to 20%.

2) What is the expected behavior?
To turn on one bulb when movement detected and either set the level to 20%. Changes to white or #FFFFFF if bulb has been set to another colour previously, then dims to 20%

3) What is happening/not happening?
Whenever movement is detected, the level of the bulb is set to 100% and then dims to 20%, every time movement is sensed. I note in the Logs below that if a Set Colour command is used, part of that command, sets the level to 100%. I tried using the ELSE however it still appears to set the colour and then dim.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)

+2ms â•”Received event [Living Room Sensor].motion = inactive with a delay of 543ms
+137ms â•‘RunTime Analysis CS > 17ms > PS > 57ms > PE > 63ms > CE
+140ms â•‘Runtime (38622 bytes) successfully initialized in 57ms (v0.3.108.20180906) (137ms)
+141ms â•‘â•”Execution stage started
+162ms ║║Comparison (time) 36773859 is_between (time) 4500000 … (time) 23340000 = false (12ms)
+164ms â•‘â•‘Condition #3 evaluated false (17ms)
+166ms â•‘â•‘Condition group #1 evaluated false (state did not change) (18ms)
+169ms ║║Cancelling statement #4’s schedules…
+177ms â•‘â•‘Skipped execution of physical command [Couch Lamp].on([]) because it would make no change to the device. (3ms)
+178ms â•‘â•‘Executed [Couch Lamp].on (5ms)
+196ms â•‘â•‘Executed physical command [Couch Lamp].setColor([[hex: #ffffff, hue:0, saturation:0, level:100]]) (13ms)
+197ms â•‘â•‘Executed [Couch Lamp].setColor (16ms)
+202ms â•‘â•‘Executed virtual command [Couch Lamp].wait (0ms)
+203ms â•‘â•‘Waiting for 1000ms
+1221ms â•‘â•‘Executed physical command [Couch Lamp].setLevel([20]) (14ms)
+1222ms â•‘â•‘Executed [Couch Lamp].setLevel (15ms)
+1225ms ║╚Execution stage complete. (1084ms)
+1227ms ╚Event processed successfully (1226ms)

#2

Try to remove the turn on command. Some bulbs, when you set level, will turn on too. If you set level to 0 they will turn off. Not sure if this will help, just a thought


#3

Tested and working with a phillips hue bulb:


edit: Obviously change your color to “white” or whatever you want
double-edit: Use the set-level command AFTER setting the color.


#4

Hello,

thanks for the replies.

@allrak I will try this, this evening when I finish in work. I’m thinking I will replace Switch 13 with my motion sensor?

I’m still concerned that when the Motion Sensor detects movement, it will run the Set Colour command and Set the level of the bulb to 100% and then reduce to 20%.

Thanks for your help.


#5

Yes, change Switch13 to your motion sensor (I was using a virtual switch just for testing purposes).
I just tested it again on my Hue bulb with an initial bulb state set to off and it didn’t bump to 100% first… it went directly to 20%, so it should work as expected.


#6

I agree with @allrak. Setting the color has no bearing on the levels.

With that being said, if the bulb was previously turned off at 100% brightness, it will briefly return to that level when the bulb comes on, before quickly changing to the correct level. (less than a half second in total)


#7

I tested that starting with the bulb off (last on at %100) and executing the piston. I did not see an increase to 100% level, or maybe it happened so fast I didn’t notice.


#8

I have to admit, I am pleasantly surprised that Hue accepts the color command while the bulb is still off. This must be a new change to their API. It makes me wonder what other commands it will accept while the bulb is off…

How long have we been waiting for this feature?


#9

yep, I agree. Last time I remember trying this, you definitely would see the 100% on followed by the dimming. I agree something must have changed… for the better! (which is unusual, but I’ll take it!)


#10

Holy Smokes Batman, Philips Hue now accepts level changes while the bulbs are OFF!!!
(it does turn the bulb on in the process, but it goes right to the new level)

:balloon::tada::confetti_ball::beer::beer:

This will streamline many of my pistons!!


#11

I agree, @WCmore I couldn’t figure out why it would set to 100% and then dim to 20%.

It was in the logs that I noticed that that when setting the colour, it seems to be part of the Set Colour command:
+196ms â•‘â•‘Executed physical command [Couch Lamp].setColor([[hex: #ffffff, hue:0, saturation:0, level:100]]) (13ms)

I will try @allrak 's solution later on and confirm

Thanks again for everyone’s help :slight_smile:


#12

That didn’t work. What is now happening is, when movement is active, it toggles between 100% and 20%.

These are the logs that occurred when the bulb sets itself to 100%:

+1ms â•”Received event [Living Room Sensor].motion = active with a delay of 539ms
+67ms â•‘RunTime Analysis CS > 16ms > PS > 43ms > PE > 9ms > CE
+70ms â•‘Runtime (37352 bytes) successfully initialized in 43ms (v0.3.108.20180906) (68ms)
+71ms â•‘â•”Execution stage started
+92ms ║║Comparison (time) 907690 is_between (time) 600000 … (time) 37740000 = true (11ms)
+94ms â•‘â•‘Time restriction check passed
+96ms â•‘â•‘Condition #11 evaluated true (18ms)
+97ms ║║Cancelling condition #1’s schedules…
+98ms â•‘â•‘Condition group #1 evaluated true (state changed) (21ms)
+105ms â•‘â•‘Comparison (enum) active changes_to (string) active = true (1ms)
+107ms ║║Cancelling condition #2’s schedules…
+108ms â•‘â•‘Condition #2 evaluated true (7ms)
+109ms â•‘â•‘Condition group #1 evaluated true (state did not change) (10ms)
+112ms ║║Cancelling statement #8’s schedules…
+127ms â•‘â•‘Executed physical command [Couch Lamp].setColor([[hex: #FFFFFF, hue:0, saturation:0, level:100]]) (10ms)
+128ms â•‘â•‘Executed [Couch Lamp].setColor (12ms)
+141ms â•‘â•‘Skipped execution of physical command [Couch Lamp].setLevel([20]) because it would make no change to the device. (7ms)
+142ms â•‘â•‘Executed [Couch Lamp].setLevel (9ms)
+145ms ║╚Execution stage complete. (75ms)
+147ms ╚Event processed successfully (147ms)

I have also tried disabling Command Optimisation. When movement is detected, the bulb goes up to 100% and then immediately down to 20%, like a flicker.


#13

It looks like the Color command sends a level command as well…

What if you moved the color command right below the Set level to 20%?


#14

I think I have figured it out, I added a extra line to @allrak 's piston; If light is not on, turn it on.

It now appears to work. It still goes up to 100% and then down to 20%, however it just does it the once rather than every time the motion sensor, senses movement.

Here is the script:


#15

I have never noticed that the Color command also sends a level command. Thankfully, once the level has changed, it does not send the old level any longer.

Thanks for the update. I swear I learn something new about webCoRE every day!!


#16

Yes, I believe that is what is causing the light to set to 100% and then dim.

I move the Set colour command below the Set Level and the light stays at 100%

+1192ms â•‘â•‘Executed physical command [Couch Lamp].setLevel([20]) (15ms)
+1194ms â•‘â•‘Executed [Couch Lamp].setLevel (16ms)
+1213ms â•‘â•‘Executed physical command [Couch Lamp].setColor([[hex: #FFFFFF, hue:0, saturation:0, level:100]]) (16ms)

#17

My hunch is if there is a 1 sec pause between it will not do that.

IE:
Set level to 20%
Wait 1 sec
Set Color to White


#18

Unfortunately not, the level starts at 20% and then goes to 100% where it stays

I’m thinking it is related to Set Colour command.

+167ms â•‘â•‘Executed physical command [Couch Lamp].setLevel([20]) (11ms)
+168ms â•‘â•‘Executed [Couch Lamp].setLevel (13ms)
+172ms â•‘â•‘Executed virtual command [Couch Lamp].wait (1ms)
+173ms â•‘â•‘Waiting for 1000ms
+1188ms â•‘â•‘Executed physical command [Couch Lamp].setColor([[hex: #FFFFFF, hue:0, saturation:0, level:100]]) (10ms)

I have a solution which is great, the light will only turn to 100% once when it is turned on. I would like to think there is a technical reason as to why the bulb has to set to 100%, but its frustrating when all I want to do is set the colour.

Thank you @WCmore for your help.


#19

I have no idea why the color command is sending this:
[hex: #FFFFFF, hue:0, saturation:0, level:100]

but I am especially baffled as to why it still remembers the old level once the level changes.


#20

I’m not sure its “remembering” the old level as such, the Set colour command brings the bulb upto 100% and then I have to manually reduce it to 20%. Add in the many movements a motion sensor activates and its like the bulb is flickering.

I originally wanted the script to go along the lines of:
If
Bulb is White
Turn on
Set Level 20%

If
Bulb is not White
Set to White
Turn on
Set Level 20%

However this didn’t work, it ran through the script regardless and set the level to 100% and then to 20%

One for the developers of webCoRE maybe as to why Set Colour needs to set the level as well.