Restoring state values not working quite right. Can you help?


#1

1) Give a description of the problem
Sometimes all of my lights don’t go back to original color, which 99% of the time is soft white and they get stuck at the arriving color

2) What is the expected behaviour?
When someone comes home, the lights change to their particular color. After a few minutes, they revert to their previous color

3) What is happening/not happening?
They don’t always go back to the original color. Often, multiple people come home at the same time. For instance, if they are riding in the same car. Not sure if that is causing the problem or not or how to solve it if so. I’m not an expert at this and sure the code could be more efficient, but I’d like it to at least be right if anyone can see what I’m doing wrong here.

**4) Post a Green Snapshot of the piston

5) Attach logs after turning logging level to Full
1/26/2021, 4:27:28 PM +260ms
+0ms ╔Received event [Home].time = 1611700049547 with a delay of -1288ms
+113ms ║RunTime Analysis CS > 38ms > PS > 7ms > PE > 69ms > CE
+117ms ║Runtime (62551 bytes) successfully initialized in 7ms (v0.3.110.20191009) (116ms)
+118ms ║╔Execution stage started
+183ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+191ms ║║Executed physical command [Sengled-den].setColor([]) (7ms)
+200ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+205ms ║║Executed physical command [Sengled-den].setColorTemperature([2700]) (4ms)
+206ms ║║Executed virtual command [Sengled-den].loadStateLocally (34ms)
+208ms ║╚Execution stage complete. (91ms)
+209ms ╚Event processed successfully (209ms)
1/26/2021, 4:26:28 PM +208ms
+1ms ╔Received event [Home].time = 1611699989309 with a delay of -1101ms
+105ms ║RunTime Analysis CS > 26ms > PS > 6ms > PE > 73ms > CE
+109ms ║Runtime (62551 bytes) successfully initialized in 6ms (v0.3.110.20191009) (108ms)
+110ms ║╔Execution stage started
+167ms ║║Restoring attribute ‘hue’ to value ‘33.0’ using command setHue(33.0)
+178ms ║║Executed physical command [Office Lantern].setHue([33.0]) (10ms)
+187ms ║║Restoring attribute ‘level’ to value ‘18’ using command setLevel(18)
+199ms ║║Skipped execution of physical command [Office Lantern].setLevel([18]) because it would make no change to the device. (11ms)
+207ms ║║Restoring attribute ‘saturation’ to value ‘100’ using command setSaturation(100)
+214ms ║║Executed physical command [Office Lantern].setSaturation([100]) (6ms)
+217ms ║║Restoring attribute ‘switch’ to value ‘on’ using command on()
+224ms ║║Skipped execution of physical command [Office Lantern].on([]) because it would make no change to the device. (5ms)
+224ms ║║Executed virtual command [Office Lantern].loadStateLocally (66ms)
+227ms ║║Fast executing schedules, waiting for 1201ms to sync up
+1491ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+1501ms ║║Executed physical command [Master sylv color].setColor([]) (9ms)
+1510ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+1518ms ║║Executed physical command [Master sylv color].setColorTemperature([2700]) (7ms)
+1519ms ║║Executed virtual command [Master sylv color].loadStateLocally (36ms)
+1521ms ║║Fast executing schedules, waiting for 1ms to sync up
+1589ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+1598ms ║║Executed physical command [gamerm-sylv].setColor([]) (9ms)
+1607ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+1613ms ║║Executed physical command [gamerm-sylv].setColorTemperature([2700]) (5ms)
+1614ms ║║Executed virtual command [gamerm-sylv].loadStateLocally (34ms)
+1616ms ║╚Execution stage complete. (1506ms)
+1617ms ║Setting up scheduled job for Tue, Jan 26 2021 @ 4:27:29 PM CST (in 59.722s)
+1625ms ╚Event processed successfully (1625ms)
1/26/2021, 4:26:22 PM +101ms
+0ms ╔Received event [Home].time = 1611699983522 with a delay of -1421ms
+90ms ║RunTime Analysis CS > 19ms > PS > 5ms > PE > 65ms > CE
+93ms ║Runtime (62553 bytes) successfully initialized in 5ms (v0.3.110.20191009) (92ms)
+94ms ║╔Execution stage started
+161ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+167ms ║║Executed physical command [Bathroom].setColor([]) (4ms)
+175ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+178ms ║║Executed physical command [Bathroom].setColorTemperature([2700]) (3ms)
+181ms ║║Restoring attribute ‘switch’ to value ‘on’ using command on()
+185ms ║║Skipped execution of physical command [Bathroom].on([]) because it would make no change to the device. (4ms)
+186ms ║║Executed virtual command [Bathroom].loadStateLocally (33ms)
+191ms ║║Comparison (string) 1 is (integer) 0 = false (1ms)
+192ms ║║Cancelling condition #114’s schedules…
+193ms ║║Condition #114 evaluated false (5ms)
+194ms ║║Cancelling condition #113’s schedules…
+195ms ║║Condition group #113 evaluated false (state changed) (7ms)
+197ms ║║Cancelling statement #218’s schedules…
+201ms ║║Executed virtual command setVariable (3ms)
+205ms ║║Executed virtual command setVariable (2ms)
+208ms ║║Executed virtual command setVariable (1ms)
+211ms ║║Executed virtual command setVariable (2ms)
+214ms ║║Executed virtual command setVariable (2ms)
+218ms ║║Executed virtual command setVariable (2ms)
+235ms ║╚Execution stage complete. (142ms)
+237ms ║Setting up scheduled job for Tue, Jan 26 2021 @ 4:26:29 PM CST (in 6.972s), with 3 more jobs pending
+249ms ╚Event processed successfully (249ms)
1/26/2021, 4:24:29 PM +159ms
+0ms ╔Received event [Home].time = 1611699869404 with a delay of -246ms
+89ms ║RunTime Analysis CS > 18ms > PS > 5ms > PE > 67ms > CE
+93ms ║Runtime (62552 bytes) successfully initialized in 5ms (v0.3.110.20191009) (91ms)
+94ms ║╔Execution stage started
+145ms ║║Executed physical command [Office Lantern].setColor([[hex: #FF69B4, hue:92, saturation:100, level:71]]) (5ms)
+146ms ║║Executed [Office Lantern].setColor (7ms)
+149ms ║║Executed virtual command [Office Lantern].wait (1ms)
+150ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:26:29 PM CST (in 120.0s)
+154ms ║║Fast executing schedules, waiting for 175ms to sync up
+382ms ║║Executed physical command [Sengled-den].setColor([[hex: #FF69B4, hue:92, saturation:100, level:71]]) (4ms)
+383ms ║║Executed [Sengled-den].setColor (6ms)
+386ms ║║Executed virtual command [Sengled-den].wait (1ms)
+387ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:27:29 PM CST (in 180.0s)
+391ms ║║Fast executing schedules, waiting for 24ms to sync up
+472ms ║║Executed physical command [Master sylv color].setColor([[hex: #FF69B4, hue:92, saturation:100, level:71]]) (3ms)
+473ms ║║Executed [Master sylv color].setColor (5ms)
+475ms ║║Executed virtual command [Master sylv color].wait (0ms)
+476ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:26:29 PM CST (in 120.0s)
+480ms ║║Fast executing schedules, waiting for 25ms to sync up
+566ms ║║Executed physical command [gamerm-sylv].setColor([[hex: #FF69B4, hue:92, saturation:100, level:71]]) (4ms)
+566ms ║║Executed [gamerm-sylv].setColor (5ms)
+569ms ║║Executed virtual command [gamerm-sylv].wait (0ms)
+570ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:26:29 PM CST (in 120.0s)
+574ms ║╚Execution stage complete. (481ms)
+576ms ║Setting up scheduled job for Tue, Jan 26 2021 @ 4:26:23 PM CST (in 113.787s), with 4 more jobs pending
+584ms ╚Event processed successfully (584ms)
1/26/2021, 4:24:26 PM +198ms
+0ms ╔Received event [Home].time = 1611699863371 with a delay of 2827ms
+103ms ║RunTime Analysis CS > 26ms > PS > 6ms > PE > 71ms > CE
+107ms ║Runtime (62553 bytes) successfully initialized in 6ms (v0.3.110.20191009) (105ms)
+107ms ║╔Execution stage started
+161ms ║║Restoring attribute ‘hue’ to value ‘33.0’ using command setHue(33.0)
+170ms ║║Executed physical command [Office Lantern].setHue([33.0]) (8ms)
+178ms ║║Restoring attribute ‘level’ to value ‘18’ using command setLevel(18)
+187ms ║║Skipped execution of physical command [Office Lantern].setLevel([18]) because it would make no change to the device. (8ms)
+196ms ║║Restoring attribute ‘saturation’ to value ‘100’ using command setSaturation(100)
+201ms ║║Executed physical command [Office Lantern].setSaturation([100]) (5ms)
+202ms ║║Executed virtual command [Office Lantern].loadStateLocally (49ms)
+205ms ║║Executed virtual command [Office Lantern].wait (0ms)
+206ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:29 PM CST (in 3.0s)
+265ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+272ms ║║Executed physical command [Sengled-den].setColor([]) (6ms)
+280ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+284ms ║║Executed physical command [Sengled-den].setColorTemperature([2700]) (3ms)
+285ms ║║Executed virtual command [Sengled-den].loadStateLocally (29ms)
+288ms ║║Executed virtual command [Sengled-den].wait (0ms)
+289ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:29 PM CST (in 3.0s)
+351ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+358ms ║║Executed physical command [Master sylv color].setColor([]) (6ms)
+367ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+371ms ║║Executed physical command [Master sylv color].setColorTemperature([2700]) (4ms)
+372ms ║║Executed virtual command [Master sylv color].loadStateLocally (28ms)
+374ms ║║Executed virtual command [Master sylv color].wait (0ms)
+375ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:29 PM CST (in 3.0s)
+441ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+449ms ║║Executed physical command [gamerm-sylv].setColor([]) (6ms)
+457ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+461ms ║║Executed physical command [gamerm-sylv].setColorTemperature([2700]) (4ms)
+462ms ║║Executed virtual command [gamerm-sylv].loadStateLocally (29ms)
+465ms ║║Executed virtual command [gamerm-sylv].wait (0ms)
+466ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:29 PM CST (in 3.0s)
+470ms ║╚Execution stage complete. (363ms)
+472ms ║Setting up scheduled job for Tue, Jan 26 2021 @ 4:24:29 PM CST (in 2.735s), with 4 more jobs pending
+478ms ╚Event processed successfully (478ms)
1/26/2021, 4:24:18 PM +202ms
+1ms ╔Received event [Home].time = 1611699858521 with a delay of -319ms
+107ms ║RunTime Analysis CS > 27ms > PS > 5ms > PE > 75ms > CE
+110ms ║Runtime (62553 bytes) successfully initialized in 5ms (v0.3.110.20191009) (109ms)
+111ms ║╔Execution stage started
+163ms ║║Executed physical command [Office Lantern].setColor([[hex: #FF69B4, hue:92, saturation:100, level:71]]) (5ms)
+164ms ║║Executed [Office Lantern].setColor (7ms)
+167ms ║║Executed virtual command [Office Lantern].wait (1ms)
+168ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:23 PM CST (in 5.0s)
+172ms ║║Fast executing schedules, waiting for 231ms to sync up
+455ms ║║Executed physical command [Sengled-den].setColor([[hex: #FF69B4, hue:92, saturation:100, level:71]]) (4ms)
+456ms ║║Executed [Sengled-den].setColor (6ms)
+459ms ║║Executed virtual command [Sengled-den].wait (0ms)
+461ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:23 PM CST (in 5.0s)
+465ms ║║Fast executing schedules, waiting for 26ms to sync up
+546ms ║║Executed physical command [Master sylv color].setColor([[hex: #FF69B4, hue:92, saturation:100, level:71]]) (4ms)
+547ms ║║Executed [Master sylv color].setColor (6ms)
+550ms ║║Executed virtual command [Master sylv color].wait (1ms)
+551ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:23 PM CST (in 5.0s)
+555ms ║║Fast executing schedules, waiting for 25ms to sync up
+638ms ║║Executed physical command [gamerm-sylv].setColor([[hex: #FF69B4, hue:92, saturation:100, level:71]]) (4ms)
+639ms ║║Executed [gamerm-sylv].setColor (6ms)
+642ms ║║Executed virtual command [gamerm-sylv].wait (1ms)
+643ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:23 PM CST (in 5.0s)
+647ms ║║Fast executing schedules, waiting for 1567ms to sync up
+2283ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+2288ms ║║Executed physical command [Bathroom].setColor([]) (4ms)
+2297ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+2302ms ║║Executed physical command [Bathroom].setColorTemperature([2700]) (3ms)
+2302ms ║║Executed virtual command [Bathroom].loadStateLocally (28ms)
+2305ms ║║Executed virtual command [Bathroom].wait (0ms)
+2306ms ║║Waiting for 3000ms
+5315ms ║║Executed physical command [Bathroom].setColor([[hex: #FF69B4, hue:92, saturation:100, level:71]]) (4ms)
+5316ms ║║Executed [Bathroom].setColor (6ms)
+5318ms ║║Executed virtual command [Bathroom].wait (0ms)
+5320ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:26:23 PM CST (in 120.0s)
+5323ms ║╚Execution stage complete. (5212ms)
+5325ms ║Setting up scheduled job for Tue, Jan 26 2021 @ 4:24:23 PM CST (in 1s), with 4 more jobs pending
+5333ms ╚Event processed successfully (5332ms)
1/26/2021, 4:24:12 PM +192ms
+0ms ╔Received event [Home].time = 1611699853655 with a delay of -1463ms
+98ms ║RunTime Analysis CS > 21ms > PS > 6ms > PE > 71ms > CE
+102ms ║Runtime (62553 bytes) successfully initialized in 6ms (v0.3.110.20191009) (100ms)
+103ms ║╔Execution stage started
+174ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+185ms ║║Executed physical command [Bathroom].setColor([]) (10ms)
+193ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+201ms ║║Executed physical command [Bathroom].setColorTemperature([2700]) (7ms)
+202ms ║║Executed virtual command [Bathroom].loadStateLocally (37ms)
+205ms ║║Executed virtual command [Bathroom].wait (1ms)
+206ms ║║Waiting for 3000ms
+3217ms ║║Executed physical command [Bathroom].setColor([[hex: #FF69B4, hue:92, saturation:100, level:71]]) (7ms)
+3218ms ║║Executed [Bathroom].setColor (9ms)
+3221ms ║║Executed virtual command [Bathroom].wait (1ms)
+3222ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:20 PM CST (in 5.0s)
+3280ms ║║Restoring attribute ‘hue’ to value ‘33.0’ using command setHue(33.0)
+3289ms ║║Executed physical command [Office Lantern].setHue([33.0]) (8ms)
+3299ms ║║Restoring attribute ‘level’ to value ‘18’ using command setLevel(18)
+3309ms ║║Skipped execution of physical command [Office Lantern].setLevel([18]) because it would make no change to the device. (9ms)
+3317ms ║║Restoring attribute ‘saturation’ to value ‘100’ using command setSaturation(100)
+3324ms ║║Executed physical command [Office Lantern].setSaturation([100]) (5ms)
+3324ms ║║Executed virtual command [Office Lantern].loadStateLocally (53ms)
+3327ms ║║Executed virtual command [Office Lantern].wait (0ms)
+3328ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:18 PM CST (in 3.0s)
+3388ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+3395ms ║║Executed physical command [Sengled-den].setColor([]) (7ms)
+3403ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+3408ms ║║Executed physical command [Sengled-den].setColorTemperature([2700]) (4ms)
+3409ms ║║Executed virtual command [Sengled-den].loadStateLocally (30ms)
+3412ms ║║Executed virtual command [Sengled-den].wait (0ms)
+3413ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:18 PM CST (in 3.0s)
+3475ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+3483ms ║║Executed physical command [Master sylv color].setColor([]) (6ms)
+3491ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+3495ms ║║Executed physical command [Master sylv color].setColorTemperature([2700]) (3ms)
+3496ms ║║Executed virtual command [Master sylv color].loadStateLocally (29ms)
+3499ms ║║Executed virtual command [Master sylv color].wait (0ms)
+3500ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:18 PM CST (in 3.0s)
+3565ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+3572ms ║║Executed physical command [gamerm-sylv].setColor([]) (6ms)
+3580ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+3585ms ║║Executed physical command [gamerm-sylv].setColorTemperature([2700]) (3ms)
+3585ms ║║Executed virtual command [gamerm-sylv].loadStateLocally (28ms)
+3588ms ║║Executed virtual command [gamerm-sylv].wait (1ms)
+3589ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:18 PM CST (in 3.0s)
+3593ms ║╚Execution stage complete. (3491ms)
+3595ms ║Setting up scheduled job for Tue, Jan 26 2021 @ 4:24:18 PM CST (in 2.734s), with 4 more jobs pending
+3605ms ╚Event processed successfully (3604ms)
1/26/2021, 4:24:04 PM +106ms
+1ms ╔Received event [Home].time = 1611699845247 with a delay of -1141ms
+104ms ║RunTime Analysis CS > 21ms > PS > 6ms > PE > 76ms > CE
+107ms ║Runtime (62554 bytes) successfully initialized in 6ms (v0.3.110.20191009) (106ms)
+108ms ║╔Execution stage started
+165ms ║║Restoring attribute ‘hue’ to value ‘33.0’ using command setHue(33.0)
+175ms ║║Executed physical command [Office Lantern].setHue([33.0]) (10ms)
+184ms ║║Restoring attribute ‘level’ to value ‘18’ using command setLevel(18)
+193ms ║║Skipped execution of physical command [Office Lantern].setLevel([18]) because it would make no change to the device. (8ms)
+202ms ║║Restoring attribute ‘saturation’ to value ‘100’ using command setSaturation(100)
+208ms ║║Executed physical command [Office Lantern].setSaturation([100]) (5ms)
+209ms ║║Executed virtual command [Office Lantern].loadStateLocally (54ms)
+212ms ║║Executed virtual command [Office Lantern].wait (1ms)
+213ms ║║Requesting a wake up for Tue, Jan 26 2021 @ 4:24:07 PM CST (in 3.0s)
+217ms ║║Fast executing schedules, waiting for 942ms to sync up
+1220ms ║║Restoring attribute ‘color’ to value ‘’ using command setColor()
+1228ms ║║Executed physical command [Sengled-den].setColor([]) (8ms)
+1237ms ║║Restoring attribute ‘colorTemperature’ to value ‘2700’ using command setColorTemperature(2700)
+1242ms ║║Executed physical command [Sengled-den].setColorTemperature([2700]) (4ms)
+1243ms ║║Executed virtual command [Sengled-den].loadStateLocally (33ms)
+1246ms ║║Executed virtual command [Sengled-den].wait (0ms)


#2

Anyone have any ideas?


#3

That is quite a long piston and I do agree with you that it’s possible that multiple arrivals will throw off restoring of colors especially if the bulb you’re interacting with is the same for all the presence sensors arriving.

There are also multiple timers firing off with short duration. Maybe time to build another one from scratch with different alert instead of bulb colors.


#4

I suspect the problem is probably the capture rather than the restore. When someone arrives the piston captures the current state of the lights, but they may already be in the arrival sequence for someone else so that person’s colour may be captured.