Help Restoring Attributes for Light


#1

1) Give a description of the problem
Light attributes aren’t being restored properly

2) What is the expected behavior?
Wish to capture light attributes of color, temperature and brightness at beginning of piston and then restore at end to original state

3) What is happening/not happening?
Not going back to original state - if light was on before it does come back on at end and brightness doesn’t get restored

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
2/26/2018, 3:14:26 PM +345ms
+1ms ╔Received event [Security System].switch = off with a delay of 68ms
+114ms ║RunTime Analysis CS > 15ms > PS > 68ms > PE > 31ms > CE
+117ms ║Runtime (42123 bytes) successfully initialized in 68ms (v0.3.000.20180224) (114ms)
+118ms ║╔Execution stage started
+128ms ║║Comparison (enum) off is (string) on = false (1ms)
+129ms ║║Cancelling condition #2’s schedules…
+131ms ║║Cancelling statement #10’s schedules…
+176ms ║║Executed virtual command setLocationMode (42ms)
+192ms ║║Executed virtual command setAlarmSystemStatus (13ms)
+196ms ║║Executed virtual command setState (1ms)
+197ms ║║Condition #2 evaluated false (74ms)
+198ms ║║Cancelling condition #1’s schedules…
+199ms ║║Condition group #1 evaluated false (state changed) (76ms)
+201ms ║╚Execution stage complete. (84ms)
+203ms ╚Event processed successfully (202ms)
2/26/2018, 3:14:07 PM +98ms
+1ms ╔Received event [Security System].switch = on with a delay of 84ms
+122ms ║RunTime Analysis CS > 15ms > PS > 72ms > PE > 34ms > CE
+124ms ║Runtime (42102 bytes) successfully initialized in 72ms (v0.3.000.20180224) (122ms)
+125ms ║╔Execution stage started
+136ms ║║Comparison (enum) on is (string) on = true (2ms)
+138ms ║║Cancelling condition #2’s schedules…
+140ms ║║Cancelling statement #3’s schedules…
+164ms ║║Executed virtual command [Bedroom Lamp].saveStateLocally (16ms)
+182ms ║║Executed virtual command [Lamp].saveStateLocally (16ms)
+1661ms ║║Executed virtual command [Bedroom Lamp, Lamp].lifxScene (1474ms)
+1662ms ║║Waiting for 1500ms
+3225ms ║║Executed virtual command [Bedroom Lamp, Lamp].setLocationMode (58ms)
+3236ms ║║Executed virtual command [Bedroom Lamp, Lamp].setAlarmSystemStatus (9ms)
+3241ms ║║Skipped execution of physical command [Bedroom Lamp].off([]) because it would make no change to the device. (3ms)
+3241ms ║║Executed [Bedroom Lamp].off (4ms)
+4307ms ║║Executed physical command [Lamp].off() (1064ms)
+4308ms ║║Executed [Lamp].off (1065ms)
+4327ms ║║Restoring attribute ‘color’ to value ’ #7F7F7F’ using command setColor( #7F7F7F)
+4348ms ║║Executed physical command [Bedroom Lamp].setColor([ #7F7F7F]) (20ms)
+4358ms ║║Restoring attribute ‘colorTemperature’ to value ‘5500’ using command setColorTemperature(5500)
+4410ms ║║Executed physical command [Bedroom Lamp].setColorTemperature([5500]) (52ms)
+4420ms ║║Restoring attribute ‘hue’ to value ‘33.3333333333’ using command setHue(33.3333333333)
+4466ms ║║Executed physical command [Bedroom Lamp].setHue([33.3333333333]) (46ms)
+4476ms ║║Restoring attribute ‘infraredLevel’ to value ‘’ using command setInfraredLevel()
+4482ms ║║Skipped execution of physical command [Bedroom Lamp].setInfraredLevel([]) because it would make no change to the device. (5ms)
+4491ms ║║Restoring attribute ‘level’ to value ‘100’ using command setLevel(100)
+4497ms ║║Skipped execution of physical command [Bedroom Lamp].setLevel([100]) because it would make no change to the device. (5ms)
+4507ms ║║Restoring attribute ‘saturation’ to value ‘’ using command setSaturation()
+4532ms ║║Executed physical command [Bedroom Lamp].setSaturation([]) (25ms)
+4533ms ║║Executed virtual command [Bedroom Lamp].loadStateLocally (221ms)
+4543ms ║║Restoring attribute ‘color’ to value ’ #ffffff’ using command setColor( #ffffff)
+4563ms ║║Executed physical command [Lamp].setColor([ #ffffff]) (19ms)
+4572ms ║║Restoring attribute ‘colorTemperature’ to value ‘5500’ using command setColorTemperature(5500)
+4616ms ║║Executed physical command [Lamp].setColorTemperature([5500]) (43ms)
+4626ms ║║Restoring attribute ‘hue’ to value ‘61.4221408407721’ using command setHue(61.4221408407721)
+4847ms ║║Executed physical command [Lamp].setHue([61.4221408407721]) (221ms)
+4857ms ║║Restoring attribute ‘infraredLevel’ to value ‘’ using command setInfraredLevel()
+4863ms ║║Skipped execution of physical command [Lamp].setInfraredLevel([]) because it would make no change to the device. (5ms)
+4872ms ║║Restoring attribute ‘level’ to value ‘100’ using command setLevel(100)
+4879ms ║║Skipped execution of physical command [Lamp].setLevel([100]) because it would make no change to the device. (6ms)
+4888ms ║║Restoring attribute ‘saturation’ to value ‘’ using command setSaturation()


#2

At no point in your piston are you setting the bulbs to the value of the variable… I can only see you setting the variable to the value of the bulbs.

Are you aware of the ‘store attributes to local store’ action?


#3

My apologies I’d posted wrong snapshot. And yes I’m aware of those commands and am trying to use them, but obviously not the right way.


#4

Thought that might have been the case lol


#5

Without studying the logs I suspect you are storing the attributes but then immediately overwriting them with incorrect data following a second trigger (caused by the scene you are activating turning a bulb on maybe?)

There is an option in the store attributes command to only do so if the store is blank… that will prevent any overwrites.

And when you restore the attributes, there is an option to clear the store (ready for the next run)


#6

Do you mean this setting? What should I set it too?


#7

Not at my PC right now but I think you change the ‘nothing selected’ to ‘value’, you can then choose ‘true’


#8

When I go in and try to set that up it only allows me to select one attribute. What do you suggest?


#9

Use ‘value’ not physical device’


#10

Yup you’re set to true for both.


#11

True True :smile:


#12

Still not working the way expected.

2/26/2018, 6:47:41 PM +85ms
+1ms ╔Received event [Security System].switch = off with a delay of 64ms
+119ms ║RunTime Analysis CS > 16ms > PS > 71ms > PE > 33ms > CE
+122ms ║Runtime (41658 bytes) successfully initialized in 71ms (v0.3.000.20180224) (120ms)
+123ms ║╔Execution stage started
+133ms ║║Comparison (enum) off is (string) on = false (2ms)
+135ms ║║Cancelling condition #2’s schedules…
+137ms ║║Cancelling statement #10’s schedules…
+180ms ║║Executed virtual command setLocationMode (40ms)
+191ms ║║Executed virtual command setAlarmSystemStatus (8ms)
+195ms ║║Executed virtual command setState (1ms)
+196ms ║║Condition #2 evaluated false (67ms)
+197ms ║║Cancelling condition #1’s schedules…
+198ms ║║Condition group #1 evaluated false (state changed) (70ms)
+200ms ║╚Execution stage complete. (78ms)
+201ms ╚Event processed successfully (201ms)
2/26/2018, 6:47:20 PM +168ms
+1ms ╔Received event [Security System].switch = on with a delay of 72ms
+132ms ║RunTime Analysis CS > 23ms > PS > 71ms > PE > 37ms > CE
+134ms ║Runtime (42391 bytes) successfully initialized in 71ms (v0.3.000.20180224) (132ms)
+135ms ║╔Execution stage started
+145ms ║║Comparison (enum) on is (string) on = true (1ms)
+147ms ║║Cancelling condition #2’s schedules…
+149ms ║║Cancelling statement #3’s schedules…
+159ms ║║Executed virtual command [Bedroom Lamp].saveStateLocally (2ms)
+162ms ║║Executed virtual command [Lamp].saveStateLocally (1ms)
+2569ms ║║Executed virtual command [Bedroom Lamp, Lamp].lifxScene (2401ms)
+2570ms ║║Waiting for 1500ms
+4124ms ║║Executed virtual command [Bedroom Lamp, Lamp].setLocationMode (51ms)
+4136ms ║║Executed virtual command [Bedroom Lamp, Lamp].setAlarmSystemStatus (9ms)
+4141ms ║║Skipped execution of physical command [Bedroom Lamp].off([]) because it would make no change to the device. (4ms)
+4142ms ║║Executed [Bedroom Lamp].off (4ms)
+4146ms ║║Skipped execution of physical command [Lamp].off([]) because it would make no change to the device. (2ms)
+4146ms ║║Executed [Lamp].off (4ms)
+4163ms ║║Restoring attribute ‘color’ to value ’ #7F7F7F’ using command setColor( #7F7F7F)
+4274ms ║║Executed physical command [Bedroom Lamp].setColor([ #7F7F7F]) (111ms)
+4284ms ║║Restoring attribute ‘colorTemperature’ to value ‘5500’ using command setColorTemperature(5500)
+4340ms ║║Executed physical command [Bedroom Lamp].setColorTemperature([5500]) (56ms)
+4350ms ║║Restoring attribute ‘hue’ to value ‘33.3333333333’ using command setHue(33.3333333333)
+4400ms ║║Executed physical command [Bedroom Lamp].setHue([33.3333333333]) (48ms)
+4410ms ║║Restoring attribute ‘infraredLevel’ to value ‘’ using command setInfraredLevel()
+4416ms ║║Skipped execution of physical command [Bedroom Lamp].setInfraredLevel([]) because it would make no change to the device. (6ms)
+4426ms ║║Restoring attribute ‘level’ to value ‘100’ using command setLevel(100)
+4433ms ║║Skipped execution of physical command [Bedroom Lamp].setLevel([100]) because it would make no change to the device. (6ms)
+4443ms ║║Restoring attribute ‘saturation’ to value ‘’ using command setSaturation()
+4470ms ║║Executed physical command [Bedroom Lamp].setSaturation([]) (26ms)
+4471ms ║║Executed virtual command [Bedroom Lamp].loadStateLocally (318ms)
+4482ms ║║Restoring attribute ‘color’ to value ’ #ffffff’ using command setColor( #ffffff)
+4502ms ║║Executed physical command [Lamp].setColor([ #ffffff]) (19ms)
+4513ms ║║Restoring attribute ‘colorTemperature’ to value ‘5500’ using command setColorTemperature(5500)
+4559ms ║║Executed physical command [Lamp].setColorTemperature([5500]) (46ms)
+4569ms ║║Restoring attribute ‘hue’ to value ‘61.4221408407721’ using command setHue(61.4221408407721)
+4618ms ║║Executed physical command [Lamp].setHue([61.4221408407721]) (48ms)
+4628ms ║║Restoring attribute ‘infraredLevel’ to value ‘’ using command setInfraredLevel()
+4633ms ║║Skipped execution of physical command [Lamp].setInfraredLevel([]) because it would make no change to the device. (4ms)
+4643ms ║║Restoring attribute ‘level’ to value ‘100’ using command setLevel(100)
+4650ms ║║Skipped execution of physical command [Lamp].setLevel([100]) because it would make no change to the device. (5ms)
+4659ms ║║Restoring attribute ‘saturation’ to value ‘’ using command setSaturation()
+4685ms ║║Executed physical command [Lamp].setSaturation([]) (24ms)
+4685ms ║║Executed virtual command [Lamp].loadStateLocally (214ms)
+4689ms ║║Executed virtual command [Bedroom Lamp, Lamp].wait (1ms)
+4690ms ║║Waiting for 500ms
+5227ms ║║Executed physical command [Bedroom Lamp].off() (35ms)
+5228ms ║║Executed [Bedroom Lamp].off (37ms)
+5263ms ║║Executed physical command [Lamp].off() (34ms)
+5264ms ║║Executed [Lamp].off (35ms)
+5268ms ║║Executed virtual command [Bedroom Lamp, Lamp].setState (1ms)
+5269ms ║║Condition #2 evaluated true (5128ms)
+5270ms ║║Cancelling condition #1’s schedules…
+5271ms ║║Condition group #1 evaluated true (state changed) (5130ms)
+5273ms ║╚Execution stage complete. (5138ms)
+5274ms ╚Event processed successfully (5274ms)


#13

Looks like you may also need to save and restore attribute ‘switch’.


#14

Changed it up a bit because I’d thought there was a conflict someplace and am this point now but still the light does not turn back on if it was already on and does not go back to original color or level.


#15

Not sure why I missed this before (possibly coz I was watching walking dead lol), but you are restoring the state and then immediately turning the lights off, so the end result will always be off.

And what’s that 500ms about? ST can’t reliable space commands that accurately due to cloud and home mesh lag… I wouldn’t go below 3 seconds.

Not sure why color is restoring but it might be to do with the quick firing of the wait??


#16

Duh on the off command. My bad. So if I get rid of the off command then I really don’t need the wait command right? It’s interesting you bring up the time issue because I’ve always wondered what the best wait times are for when flashing lights. Sometimes it doesn’t even seem like they flash so maybe the time in between flashes has been too short too.


#17

When I actually had a smart home (:sob:) I could never get my decking lights to flash reliably at anything below 3 seconds… so I always recommended a minimum 3 second rule.

You don’t need the wait…


#18

So I removed the wait and off commands but still have issues. It’s the strangest thing too because after running the piston it does t always come back with the most consistent results. Generally when I turn the lights back (since they’re not coming back on by themself) they’re still pink and at 7%. But there’s been times where one would be 50% and another at 96%. Is boticed I had to refresh the device in SmartThings apps a couple times to get it to reflect accurate information.