Flash Light (Color) interferes with Capture/Restore state?


#1

1) Give a description of the problem
I am trying to have a light flash a certain color/s when motion is detected, or when another trigger happens. If the light is already on, I expect it to flash the color(s) and then return to the same color it was before being triggered. It is randomly selecting the color on restore, and the flash is never consistent.

2) What is the expected behaviour?
When a trigger is set off (motion currently), a multicolor (sengled) light bulb should flash color to my choosing and return to the color it was before. Or if off, then turn off.

3) What is happening/not happening?
The bulb is not restoring to the proper color and instead picking one of the colors that was part of the flash. Also, the flash is inconsistent with timing between flashes of color.

**4) Post a Green Snapshot of the piston!

5) Attach logs after turning logging level to Full

8/18/2020, 9:15:01 PM +17ms
+0ms ╔Received event [My home].ifttt = Hallway_Motion_Detected with a delay of 54ms
+96ms ║RunTime Analysis CS > 18ms > PS > 44ms > PE > 34ms > CE
+99ms ║Runtime (39758 bytes) successfully initialized in 44ms (v0.3.110.20191009) (97ms)
+99ms ║╔Execution stage started
+106ms ║║Comparison (string) Hallway_Motion_Detected executes (string) Hallway_Motion_Detected = true (2ms)
+107ms ║║Cancelling condition #6's schedules...
+108ms ║║Condition #6 evaluated true (5ms)
+120ms ║║Comparison (enum) on is (string) on = true (1ms)
+121ms ║║Condition #7 evaluated true (12ms)
+122ms ║║Cancelling condition #1's schedules...
+122ms ║║Condition group #1 evaluated true (state changed) (19ms)
+124ms ║║Cancelling statement #4's schedules...
+134ms ║║Executed virtual command [Office Light].saveStateLocally (6ms)
+137ms ║║Executed virtual command [Office Light].wait (1ms)
+138ms ║║Waiting for 1000ms
+1163ms ║║Executed physical command [Office Light].setColor([[hex: #800080, hue:83, saturation:100, level:25]]) (12ms)
+1168ms ║║Executed physical command [Office Light].setColor([[hex: #FFD700, hue:14, saturation:100, level:50]], [delay: 250]) (5ms)
+1173ms ║║Executed physical command [Office Light].setColor([[hex: #800080, hue:83, saturation:100, level:25]], [delay: 500]) (3ms)
+1179ms ║║Executed physical command [Office Light].setColor([[hex: #FFD700, hue:14, saturation:100, level:50]], [delay: 750]) (5ms)
+1185ms ║║Executed physical command [Office Light].on([delay: 1099]) (6ms)
+1186ms ║║Executed virtual command [Office Light].flashColor (42ms)
+1186ms ║║Waiting for 1100ms
+2290ms ║║Executed virtual command [Office Light].wait (0ms)
+2291ms ║║Waiting for 1000ms
+3303ms ║║Restoring attribute 'color' to value '' using command setColor()
+3310ms ║║Executed physical command [Office Light].setColor([]) (5ms)
+3311ms ║║Executed virtual command [Office Light].loadStateLocally (16ms)
+3313ms ║╚Execution stage complete. (3213ms)
+3314ms ╚Event processed successfully (3313ms)
8/18/2020, 9:14:42 PM +23ms
+1ms ╔Received event [My home].test = 1597803282023 with a delay of 0ms
+95ms ║RunTime Analysis CS > 17ms > PS > 37ms > PE > 41ms > CE
+98ms ║Runtime (39743 bytes) successfully initialized in 37ms (v0.3.110.20191009) (96ms)
+99ms ║╔Execution stage started
+107ms ║║Comparison (string) null executes (string) Hallway_Motion_Detected = false (2ms)
+109ms ║║Condition #6 evaluated false (4ms)
+110ms ║║Condition group #1 evaluated false (state did not change) (7ms)
+112ms ║╚Execution stage complete. (13ms)
+113ms ╚Event processed successfully (113ms)
8/18/2020, 9:14:27 PM +15ms
+0ms ╔Starting piston... (v0.3.110.20191009)
+409ms ║╔Subscribing to devices...
+418ms ║║Subscribing to My home.ifttt.Hallway_Motion_Detected...
+483ms ║║Subscribing to Office Light...
+484ms ║╚Finished subscribing (89ms)
+537ms ╚Piston successfully started (537ms)
8/18/2020, 9:13:39 PM +708ms
+0ms ╔Received event [My home].ifttt = Hallway_Motion_Detected with a delay of 40ms
+75ms ║Runtime (39674 bytes) successfully initialized in 27ms (v0.3.110.20191009) (73ms)
+75ms ║╔Execution stage started
+100ms ║║Executed virtual command [Office Light].saveStateLocally (5ms)
+103ms ║║Executed virtual command [Office Light].wait (1ms)
+104ms ║║Waiting for 1000ms
+1158ms ║║Executed virtual command [Office Light].flashColor (49ms)
+1159ms ║║Waiting for 1100ms
+2262ms ║║Executed virtual command [Office Light].wait (0ms)
+2263ms ║║Waiting for 1000ms
+3280ms ║║Executed virtual command [Office Light].loadStateLocally (13ms)
+3282ms ║╚Execution stage complete. (3207ms)
+3283ms ╚Event processed successfully (3283ms)
8/18/2020, 9:13:30 PM +950ms
+0ms ╔Starting piston... (v0.3.110.20191009)
+400ms ║╔Subscribing to devices...
+409ms ║║Subscribing to My home.ifttt.Hallway_Motion_Detected...
+470ms ║║Subscribing to Office Light...
+471ms ║╚Finished subscribing (82ms)
+516ms ╚Piston successfully started (516ms)
8/18/2020, 9:12:43 PM +293ms
+1ms ╔Received event [My home].ifttt = Hallway_Motion_Detected with a delay of 58ms
+104ms ║Runtime (39770 bytes) successfully initialized in 41ms (v0.3.110.20191009) (102ms)
+105ms ║╔Execution stage started
+149ms ║║Executed virtual command [Office Light].saveStateLocally (18ms)
+153ms ║║Executed virtual command [Office Light].wait (1ms)
+154ms ║║Waiting for 1000ms
+1201ms ║║Executed virtual command [Office Light].flashColor (40ms)
+1202ms ║║Waiting for 1100ms
+2306ms ║║Executed virtual command [Office Light].wait (1ms)
+2307ms ║║Waiting for 1000ms
+3372ms ║║Executed virtual command [Office Light].loadStateLocally (60ms)
+3375ms ║╚Execution stage complete. (3271ms)
+3377ms ╚Event processed successfully (3377ms)
8/18/2020, 9:12:32 PM +178ms
+0ms ╔Starting piston... (v0.3.110.20191009)
+475ms ║╔Subscribing to devices...
+485ms ║║Subscribing to My home.ifttt.Hallway_Motion_Detected...
+548ms ║║Subscribing to Office Light...
+549ms ║╚Finished subscribing (88ms)
+593ms ╚Piston successfully started (593ms)
8/18/2020, 9:09:26 PM +635ms
+0ms ╔Received event [My home].ifttt = Hallway_Motion_Detected with a delay of 43ms
+80ms ║Runtime (39808 bytes) successfully initialized in 31ms (v0.3.110.20191009) (79ms)
+81ms ║╔Execution stage started
+120ms ║║Executed virtual command [Office Light].saveStateLocally (18ms)
+123ms ║║Executed virtual command [Office Light].wait (1ms)
+124ms ║║Waiting for 1000ms
+1162ms ║║Executed virtual command [Office Light].flashColor (31ms)
+1163ms ║║Waiting for 1100ms
+2266ms ║║Executed virtual command [Office Light].wait (1ms)
+2267ms ║║Waiting for 1000ms
+3330ms ║║Executed virtual command [Office Light].loadStateLocally (59ms)
+3332ms ║╚Execution stage complete. (3251ms)
+3333ms ╚Event processed successfully (3333ms)
8/18/2020, 9:09:17 PM +587ms
+0ms ╔Starting piston... (v0.3.110.20191009)
+418ms ║╔Subscribing to devices...
+426ms ║║Subscribing to My home.ifttt.Hallway_Motion_Detected...
+490ms ║║Subscribing to Office Light...
+491ms ║╚Finished subscribing (85ms)
+537ms ╚Piston successfully started (536ms)
8/18/2020, 9:08:41 PM +244ms
+0ms ╔Received event [My home].ifttt = Hallway_Motion_Detected with a delay of 56ms
+103ms ║Runtime (39808 bytes) successfully initialized in 46ms (v0.3.110.20191009) (101ms)
+103ms ║╔Execution stage started
+151ms ║║Executed virtual command [Office Light].saveStateLocally (25ms)
+154ms ║║Executed virtual command [Office Light].wait (0ms)
+155ms ║║Waiting for 2000ms
+2206ms ║║Executed virtual command [Office Light].flashColor (45ms)
+2207ms ║║Waiting for 1100ms
+3310ms ║║Executed virtual command [Office Light].wait (1ms)
+3311ms ║║Waiting for 2000ms
+5385ms ║║Executed virtual command [Office Light].loadStateLocally (71ms)
+5387ms ║╚Execution stage complete. (5284ms)
+5388ms ╚Event processed successfully (5389ms)
8/18/2020, 9:08:16 PM +688ms
+1ms ╔Starting piston... (v0.3.110.20191009)
+428ms ║╔Subscribing to devices...
+463ms ║║Subscribing to My home.ifttt.Hallway_Motion_Detected...
+543ms ║║Subscribing to Office Light...
+544ms ║╚Finished subscribing (127ms)
+591ms ╚Piston successfully started (590ms)
8/18/2020, 9:05:48 PM +225ms
+0ms ╔Received event [My home].time = 1597802748025 with a delay of 199ms
+102ms ║Runtime (40005 bytes) successfully initialized in 46ms (v0.3.110.20191009) (101ms)
+103ms ║╔Execution stage started
+124ms ║║Executed virtual command [Office Light].flashColor (7ms)
+127ms ║║Executed virtual command [Office Light].wait (1ms)
+129ms ║║Waiting for 2000ms
+2204ms ║║Executed virtual command [Office Light].loadStateLocally (71ms)
+2206ms ║╚Execution stage complete. (2103ms)
+2207ms ╚Event processed successfully (2207ms)
8/18/2020, 9:05:36 PM +60ms
+1ms ╔Received event [My home].ifttt = Hallway_Motion_Detected with a delay of 56ms
+9915ms ║Piston waited at a semaphore for 9827ms
+9917ms ║Runtime (39896 bytes) successfully initialized in 9864ms (v0.3.110.20191009) (9916ms)
+9918ms ║╔Execution stage started
+9961ms ║║Executed virtual command [Office Light].saveStateLocally (22ms)
+9964ms ║║Executed virtual command [Office Light].wait (0ms)
+9965ms ║║Requesting a wake up for Tue, Aug 18 2020 @ 9:05:48 PM CDT (in 2.0s)
+9968ms ║╚Execution stage complete. (50ms)
+9969ms ║Setting up scheduled job for Tue, Aug 18 2020 @ 9:05:48 PM CDT (in 1.996s)
+10003ms ╚Event processed successfully (10003ms)
8/18/2020, 9:05:35 PM +767ms
+0ms ╔Received event [My home].ifttt = Hallway_Motion_Detected with a delay of 51ms
+95ms ║Runtime (39825 bytes) successfully initialized in 41ms (v0.3.110.20191009) (94ms)
+96ms ║╔Execution stage started
+141ms ║║Executed virtual command [Office Light].saveStateLocally (22ms)
+144ms ║║Executed virtual command [Office Light].wait (1ms)
+145ms ║║Waiting for 2000ms
+2159ms ║║Executed virtual command [Office Light].flashColor (7ms)
+2162ms ║║Executed virtual command [Office Light].wait (1ms)
+2163ms ║║Waiting for 2000ms
+4241ms ║║Executed virtual command [Office Light].loadStateLocally (74ms)
+4243ms ║╚Execution stage complete. (4147ms)
+4244ms ╚Event processed successfully (4244ms)
8/18/2020, 9:05:08 PM +937ms
+0ms ╔Received event [My home].ifttt = Hallway_Motion_Detected with a delay of 48ms
+82ms ║Runtime (39808 bytes) successfully initialized in 31ms (v0.3.110.20191009) (81ms)
+83ms ║╔Execution stage started
+123ms ║║Executed virtual command [Office Light].saveStateLocally (18ms)
+126ms ║║Executed virtual command [Office Light].wait (1ms)
+127ms ║║Waiting for 2000ms
+2140ms ║║Executed virtual command [Office Light].flashColor (6ms)
+2142ms ║║Executed virtual command [Office Light].wait (0ms)
+2143ms ║║Waiting for 2000ms
+4220ms ║║Executed virtual command [Office Light].loadStateLocally (72ms)
+4222ms ║╚Execution stage complete. (4139ms)
+4224ms ╚Event processed successfully (4224ms)
8/18/2020, 9:04:45 PM +711ms
+0ms ╔Starting piston... (v0.3.110.20191009)
+539ms ║╔Subscribing to devices...
+548ms ║║Subscribing to My home.ifttt.Hallway_Motion_Detected...
+625ms ║║Subscribing to Office Light...
+626ms ║╚Finished subscribing (101ms)
+674ms ╚Piston successfully started (674ms)
8/18/2020, 8:57:56 PM +185ms
+0ms ╔Received event [My home].ifttt = Hallway_Motion_Detected with a delay of 57ms
+105ms ║Runtime (40015 bytes) successfully initialized in 39ms (v0.3.110.20191009) (104ms)
+106ms ║╔Execution stage started
+132ms ║║Executed virtual command [Office Light].saveStateLocally (1ms)
+135ms ║║Executed virtual command [Office Light].wait (1ms)
+136ms ║║Waiting for 500ms
+650ms ║║Executed virtual command [Office Light].flashColor (8ms)
+653ms ║║Executed virtual command [Office Light].wait (0ms)
+654ms ║║Waiting for 500ms
+1228ms ║║Executed virtual command [Office Light].loadStateLocally (70ms)
+1231ms ║╚Execution stage complete. (1124ms)
+1232ms ╚Event processed successfully (1231ms)

#2

Very new to this forum, apologies if format is wrong/weird. I have searched the internet for a solution to this problem, and tried everything I can think of to get this to work. No results yet.

  • I have used variables instead of restore state
  • I have tried using “set color” with waits between to simulate a flash
  • I have tried lots of combinations of color, hue, saturation, level in the restore/variable
  • I have changed the time to wait from half a second to 3

Nothing seems to work. I really only wanted webcore for this flash light for notifications, and I’m super bummed that I’ve spent days on this and can’t get it to work. I’m using sengled multicolor bulbs.


#3

I would try capturing & restoring HSL (Hue, Saturation, and Level) only. (no color)
Personally, instead of capture/restore, I store those 3 in integer variables

I would also increase the flash to at least 500ms. I typically use 1500-3000
(SmartThings is not so good at spamming commands)


No problem. For future reference, you can upload pics by using this icon:

pic


#4

Okay, so I tried your changes, and it flashes… albeit not consistently, so nothing I haven’t seen before. My biggest problem is the fact that the colors all get mixed up. For example, if it’s white/blue before the flash happens and the flash is set to purple/orange then I get:

Blue/White -> Purple (substantially longer of time than the rest) -> Orange -> Blue/White -> Purple -> Stays Purple

Honestly, minus the first two, the rest of the colors in that order are just a toss up, and very rarely does it ever go back to the color it was originally, but usually the last color in the flash series.


#5

A normal flash (starting with blue) usually goes something like:

Blue > Purple > Orange > Purple > Orange > Purple > Orange

(If you add extra “restore” code to the piston, the last step could switch back to Blue)


Or another way to say all of this…

Starting with ColorX, a flash of ColorY should never ever return to ColorX in the middle of the flashing. If you have seen this, it means you are testing too quickly, and residual code was lingering from a previous execution.

I can’t really see your external image, so all I can respond with would be a reiteration of what I said before.

I would start VERY slow, (3000 ms?), and only speed it up once you are happy with it.
(If your bulb / device handler cannot reliably process two commands in 3 sec, we can’t expect it to handle commands coming in six times faster)


It might also be worth pointing out:

When testing smart home logic, there should be gaps / breaks between each test.
Typically, the space between tests should be at least:

Total piston duration (including any waits & loops)
PLUS 5-10 secs

This should allow time for the previous logs to be written, and the piston to “settle-down” to prepare for another clean test.

This means, if you follow my advice, you will have 4+3+3+3+3+4+10 = 30 seconds
So when testing this piston, there should be at least 30 sec between each trigger.


#6

Hey! I’m really sorry for the late reply. I have gotten busy these past few days and had little time to mess with webcore again. I made some of the changes that you talked about and it appears as though it actually works better to use “Set Color” to the variable saved for the light color instead of HSL.

I guess the only thing now that I’m still trying to fix is that the flashing isn’t always consistent between the two colors as far as time is concerned. Like the first color of the flash always stays for a bit longer than the rest.


#7

This makes sense to me, since it is one command versus three.
(the main thing is to not use both color and HSL)


This is somewhat normal, and typically only noticed when the delays are short.


#8

Ahh, I see. Okay. Well that’s that then. Question though - now that I have it working for when the light is on, I tried to add extremely similar logic to when it’s off. Only difference is to turn off the light when it’s done flashing. The odd thing is, with this new code it’s now duplicating the flashes, almost like it’s doing both conditionals, even though one is in an “if” and one is in an “else if”.


#9

I would need to see your current piston & log…
(preferably with Trace turned on)


#10

There is the picture. Also, with further testing, it appears as though if the light is on and a color other than white is selected, it just resets it to white. Not the color it was before the flash.

8/21/2020, 5:51:34 PM +439ms
+1ms ╔Received event [My home].ifttt = Hallway_Motion_Detected with a delay of 46ms
+82ms ║RunTime Analysis CS > 18ms > PS > 39ms > PE > 24ms > CE
+84ms ║Runtime (42259 bytes) successfully initialized in 39ms (v0.3.110.20191009) (83ms)
+85ms ║╔Execution stage started
+92ms ║║Comparison (string) Hallway_Motion_Detected executes (string) Hallway_Motion_Detected = true (1ms)
+93ms ║║Condition #6 evaluated true (4ms)
+103ms ║║Comparison (enum) on is (string) on = true (1ms)
+104ms ║║Condition #34 evaluated true (10ms)
+105ms ║║Condition group #1 evaluated true (state did not change) (16ms)
+107ms ║║Cancelling statement #4's schedules...
+110ms ║║Executed virtual command [Office Light].wait (0ms)
+111ms ║║Waiting for 2000ms
+2138ms ║║Executed physical command [Office Light].setColor([[hex: #FF8C00, hue:9, saturation:100, level:50]]) (10ms)
+2144ms ║║Executed physical command [Office Light].setColor([[hex: #9932CC, hue:78, saturation:61, level:50]], [delay: 1200]) (6ms)
+2151ms ║║Executed physical command [Office Light].setColor([[hex: #FF8C00, hue:9, saturation:100, level:50]], [delay: 2400]) (6ms)
+2157ms ║║Executed physical command [Office Light].setColor([[hex: #9932CC, hue:78, saturation:61, level:50]], [delay: 3600]) (5ms)
+2163ms ║║Executed physical command [Office Light].on([delay: 4899]) (5ms)
+2164ms ║║Executed virtual command [Office Light].flashColor (44ms)
+2164ms ║║Waiting for 4900ms
+7068ms ║║Executed virtual command [Office Light].wait (1ms)
+7069ms ║║Waiting for 2000ms
+9094ms ║║Executed physical command [Office Light].setColor([[hex: #000000, hue:0, saturation:0, level:0]]) (5ms)
+9095ms ║║Executed [Office Light].setColor (7ms)
+9096ms ║╚Execution stage complete. (9011ms)
+9097ms ╚Event processed successfully (9097ms)

#11

I would not expect setting Bulb 5’s color to Bulb 5’s color to change anything…

This is due to the hard coding of data up in the “define” section…

I normally leave variables (no value set) up top, and then in the body of the piston, I write to, and read from those variables.


I would avoid using ELSE IF, and combine the logic into a single trigger.

IF IFFFF executes "Detected"
Then
    IF Bulb 5's switch is on
    Then
        Store current (color or HSL) into variables
        Flash
        Return to previous level & color
    Else
        Flash
        Turn off
    END IF
END IF