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


#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.


#21

If it is still flickering multiple times with Color being the first command, then you are right.

The only reason it looked like it was remembering the old level is because you said:

Just to make sure we are using the same terminology, the command:
IF motion changes to active
will only trigger if the device goes from inactive to active.
(not when going from active to active)

In other words, if you “dance” in front of the motion sensor for 5 minutes straight, it will only trigger once at the beginning. (not each time you move)

Leaving the room for a couple then returning should bring the device to inactive if you need to test again…


#23

Yes. What I meant is. Now that the script is working, the light does turn on and initially sets to 100% and then immediately sets to 20%, which is fine, I can live with the level changing once.

Yes, I understand that if the sensor kept detecting movement, then nothing would happen.

To test it I was sitting very still and then throwing my arms around until the light came on! :slight_smile:


#24

That is hard to say for sure if you were sitting there.
I have seen sensors reset to inactive as quickly as 6 seconds, and some devices take up to 3 minutes before resetting.

The only rock solid test is to have everyone leave the room for 3 + minutes and then reenter. If it does not flash to 100%, then you are golden!


#25

I just did some testing with my Philips Hue bulbs, and:

  • Set Color to White will always jump to 100% level
  • Set Color to Cool White will always jump to 96% level
  • Set Color to Daylight White will always jump to 90% level
  • etc…

This leads me to believe that each color has a specific level associated with it.

I just remembered that with Philips Hue, I have always been disappointed with Set Color to a preset. When I want to change a color, I use only Set Hue & Set Saturation. (this method never touches the level)


Either of these two blocks should work for you:

temp

The second block looks like this in the popup:

temp


#26

it does appear that the “set color” includes a ‘set level’ command in it.
@WCmore’s suggestions are right on to just set HSL. Just did some testing, and the following works as expected:

@faze105, if you didn’t know this already, you can capture the current settings prior to changing them as shown in the above piston. Makes it easy to temporarily change then restore original settings.

Here’s an HSL calc: https://www.w3schools.com/colors/colors_hsl.asp


#27

Hi @allrak No I didn’t know about this. I did notice the HSL command but had no idea what it did/does.

I’ll have a look at this now and see if this is a better option.

Thanks for explaining the HSL Command

@WCmore I thought the SmartThings sensors motion stayed active for a couple of seconds and then changed to inactive. At least thats what it says in the SM Classic app. I didn’t realise they could stay active for much longer than that


#28

And with that, the issue is resolved! :slight_smile:

Whatever colour and level the light has been set to previously, when movement is detected, the colour and level is set and then the bulb turns on, which is exactly how it would work in the SM Classic App.

I’m still not totally sure on the commands Capture and Restore Attributes, I’m guessing that it captures what the bulb has been set to?

This is the script that makes it work perfectly

Thanks to @allrak and @WCmore for your help with this.


#29

“Capture” simply stores the HSL (hue, saturation, level) into a temporary variable. That way you can capture the original HSL prior to changing it, then restore it later on (if so desired).
Think of it as taking a snapshot of how the lights currently look BEFORE doing anything to them.


#30

Got it, yes that makes perfect sense.