Problems saving states in webcore with Lifx Bulbs

I am trying to make a sound with my aeon doorbell, and flash my lights when a contact opens. (for testing im using a motion sensor so i dont have to keep opening the fridge, the contact type is irreverent. (i think)

If the lightts are off when it starts, it will turn them off when its done.
howevevr if i had them set to another color and brightness, i want them to restore to that after the contact resets.

Any help appreciated. I tried this years ago with core. Gave up. Now i just installed webcore and love it. But still having issues.

2/4/2018, 1:30:36 PM +290ms
+1ms ╔Received event [Arlo Pro1].motion = inactive with a delay of 68ms
+93ms ║RunTime Analysis CS > 15ms > PS > 43ms > PE > 35ms > CE
+95ms ║Runtime (39857 bytes) successfully initialized in 43ms (v0.2.102.20180116) (93ms)
+96ms ║╔Execution stage started
+108ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+110ms ║║Cancelling condition #20’s schedules…
+111ms ║║Condition #20 evaluated false (8ms)
+112ms ║║Cancelling condition #1’s schedules…
+113ms ║║Condition group #1 evaluated false (state changed) (10ms)
+120ms ║║Comparison (enum) inactive is (string) inactive = true (2ms)
+122ms ║║Condition #19 evaluated true (7ms)
+123ms ║║Condition group #2 evaluated true (state did not change) (8ms)
+125ms ║║Cancelling statement #9’s schedules…
+283ms ║║Executed physical command [Speaker].stop() (154ms)
+284ms ║║Executed [Speaker].stop (156ms)
+287ms ║║Cancelling statement #12’s schedules…
+307ms ║║Restoring attribute ‘color’ to value ’ #FF0000’ using command setColor( #FF0000)
+338ms ║║Executed physical command [LIFX Bulb 1].setColor([ #FF0000]) (30ms)
+339ms ║║Executed virtual command [LIFX Bulb 1].loadStateLocally (43ms)
+353ms ║║Restoring attribute ‘color’ to value ’ #FF0000’ using command setColor( #FF0000)
+380ms ║║Executed physical command [LIFX Bulb 2].setColor([ #FF0000]) (25ms)
+381ms ║║Executed virtual command [LIFX Bulb 2].loadStateLocally (40ms)
+385ms ║║Executed virtual command [LIFX Bulb 1, LIFX Bulb 2].wait (1ms)
+391ms ║║Waiting for 1000ms
+1412ms ║║Restoring attribute ‘level’ to value ‘20’ using command setLevel(20)
+2204ms ║║Executed physical command [LIFX Bulb 1].setLevel([20]) (791ms)
+2205ms ║║Executed virtual command [LIFX Bulb 1].loadStateLocally (805ms)
+2218ms ║║Restoring attribute ‘level’ to value ‘20’ using command setLevel(20)
+2825ms ║║Executed physical command [LIFX Bulb 2].setLevel([20]) (606ms)
+2826ms ║║Executed virtual command [LIFX Bulb 2].loadStateLocally (620ms)
+2831ms ║║Executed virtual command [LIFX Bulb 1, LIFX Bulb 2].wait (1ms)
+2832ms ║║Waiting for 1000ms
+3842ms ║║Restoring attribute ‘switch’ to value ‘on’ using command on()
+3845ms ║║Skipped execution of physical command [LIFX Bulb 1].on([]) because it would make no change to the device. (2ms)
+3846ms ║║Executed virtual command [LIFX Bulb 1].loadStateLocally (8ms)
+3851ms ║║Restoring attribute ‘switch’ to value ‘on’ using command on()
+3855ms ║║Skipped execution of physical command [LIFX Bulb 2].on([]) because it would make no change to the device. (2ms)
+3855ms ║║Executed virtual command [LIFX Bulb 2].loadStateLocally (8ms)
+3859ms ║╚Execution stage complete. (3763ms)
+3861ms ╚Event processed successfully (3860ms)
2/4/2018, 1:30:06 PM +569ms
+1ms ╔Received event [Arlo Pro1].motion = active with a delay of 52ms
+100ms ║RunTime Analysis CS > 14ms > PS > 41ms > PE > 45ms > CE
+102ms ║Runtime (39575 bytes) successfully initialized in 41ms (v0.2.102.20180116) (100ms)
+104ms ║╔Execution stage started
+116ms ║║Comparison (enum) active is (string) active = true (2ms)
+117ms ║║Cancelling condition #20’s schedules…
+118ms ║║Condition #20 evaluated true (8ms)
+119ms ║║Cancelling condition #1’s schedules…
+120ms ║║Condition group #1 evaluated true (state changed) (10ms)
+123ms ║║Cancelling statement #3’s schedules…
+129ms ║║Executed virtual command [Speaker].wait (1ms)
+130ms ║║Waiting for 1000ms
+1251ms ║║Executed physical command [Speaker].play() (118ms)
+1252ms ║║Executed [Speaker].play (120ms)
+1255ms ║║Cancelling statement #14’s schedules…
+1271ms ║║Executed virtual command [LIFX Bulb 1].saveStateLocally (8ms)
+1281ms ║║Executed virtual command [LIFX Bulb 2].saveStateLocally (8ms)
+1286ms ║║Executed virtual command [LIFX Bulb 1, LIFX Bulb 2].wait (0ms)
+1286ms ║║Waiting for 2000ms
+4287ms ║║Executed physical command [LIFX Bulb 1].setLevel([50]) (779ms)
+4288ms ║║Executed [LIFX Bulb 1].setLevel (780ms)
+4979ms ║║Executed physical command [LIFX Bulb 2].setLevel([50]) (689ms)
+4979ms ║║Executed [LIFX Bulb 2].setLevel (690ms)
+5663ms ║║Executed physical command [LIFX Bulb 1].setColor([[hex: #FF0000, hue:0, saturation:100, level:50]]) (679ms)
+5664ms ║║Executed [LIFX Bulb 1].setColor (681ms)
+6314ms ║║Executed physical command [LIFX Bulb 2].setColor([[hex: #FF0000, hue:0, saturation:100, level:50]]) (648ms)
+6315ms ║║Executed [LIFX Bulb 2].setColor (651ms)
+6318ms ║╚Execution stage complete. (6215ms)
+6319ms ╚Event processed successfully (6319ms)

If the lights are white when it starts they do not return to White. They stay red. basically if the lights were on none of the restore features works. When they are off when it starts they seem turn off again when it’s over but I’m not sure that’s because of the restore states part… Or default behavior.

As part of your webCoRE Pistons, you could define the Scenes in your Native LIFX app for different color schemes for a specific group of lights and then when lights are turned on/off you can set the actual LIFX Scene within your Piston so that the next time they are turned on, they are the correct color.

This would give you the same equivalent restore/return to type of capability.

Thank you for this information. THough I dont think it sovles my issue, I am going to try and make use of this.

The reason it does not solve the issue is because, what if the lights were on when the alert triggered? what if they were off? Thats why i wanted to save the current states. Ill try the webcore community as suggestion above.

You have a couple of different things here:

  1. If the lights are already on and motion is triggered, I’m assuming you want nothing to happen with your lights set the way they are, correct? If that’s the case, then I would make your Piston NOT fire unless Motion is Active and the Lights are currently off (If they are on do nothing).

  2. if 1 above is correct, then your Piston fires only when Motion changes to Active and the Lights are off. Included in this Piston, you always want your lights to come on in a specific color and brightness, correct? If so, by replacing Turn on Lights with your DO function, use Set LIFX scene you have predefined in LIFX instead, and then with a wait x minutes and then turn off.

If you want them to be another predefined color when they are manually switched on, you could add a different LIFX scene just before the lights turn off in that Piston, so that if someone turns the lights on from a switch (manually) then they will be that color/brightness when turning them on. Otherwise if #2 fires again, it will set to the default Motion scene with color and brightness stored in that scene.

With Motion detected, I’m assuming there is a set standard color and brightness of all the lights, like pulsing ALL red for 30 seconds or bright white for 2 minutes.

I might be missing something in your use case and I apologize if I am, but this should get you pretty close to doing exactly what you want without the lights actually going back to a previous saved state. :slight_smile:

As for previous state, you might be able to store values of the current color and brightness in variables within webCoRE and then recall that as a restorable set of values. I haven’t done that, so not sure if it’s possible to do.

My kids love to use the lights to set their current mood for the day and whatever weird color they’re into that day. The trigger is the refrigerator door. It has a bad closer so I put a sensor on it to monitor when it’s not fully closed. If it was open more than 20 seconds I wanted to flash red lights and then restore to whatever the current state was say pink or white during the else statement.
So yes the lights may already be on and a set color. Often white but not always. These lights are my kitchen island pendant lights.

Perfect! Thanks for the explanation. Ya, so I would put out the question as to whether you are able to capture both the color (hex value) and the brightness level in stored variables whenever the lights turn on or when they change color, brightness. If that were possible, you could then use those values to restore to the previous defined color / brightness. Not sure if that is information that can be captured though. Post a follow up when you get the answer I hope you find :slight_smile:

FYI. Here’s one topic on returning to previous state.

It looks like capture/restore will be your friend in what you want to accomplish :slight_smile:

Thanks for your help. i will let you know how it goes.

I think its fixed. It appears to have been using the color vs hue saturation level. Below works.

1 Like