Need Help with fading lights and restoring state


#1

1) Give a description of the problem
Questioning how to best code fading of light and restoration of dim level not working.

2) What is the expected behavior?
Want lights to go back to original dim level

3) What is happening/not happening?
Lights come back on at 20% which is last state set in piston

**4) Post a Green Snapshot

5) Attach any logs (From ST IDE and by turning logging level to Full)
`3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace ║╔ Execution stage complete. (2564ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Restoring attribute ‘level’ to value ‘50’ using command setLevel(50)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Skipped execution of physical command [Bedroom Lamp].setLevel([20]) because it would make no change to the device. (7ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Skipped execution of physical command [Stove Light].setLevel([50]) because it would make no change to the device. (7ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace ║║ Executed virtual command [Bedroom Lamp, Lamp, Stove Light].setLocationMode (39ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Restoring attribute ‘level’ to value ‘20’ using command setLevel(20)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace ║║ Executed [Lamp].off (16ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Skipped execution of physical command [Lamp].setLevel([50]) because it would make no change to the device. (6ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Restoring attribute ‘level’ to value ‘50’ using command setLevel(50)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace ║║ Executed [Bedroom Lamp].off (18ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Executed physical command [Stove Light].setLevel([20]) (15ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace ║║ Executed [Stove Light].setLevel (16ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Executed physical command [Lamp].off() (15ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace ║║ Executed [Lamp].setLevel (16ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Skipped execution of physical command [Bedroom Lamp].setLevel([20]) because it would make no change to the device. (5ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Executed physical command [Stove Light].setLevel([40]) (15ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace ║║ Executed virtual command [Bedroom Lamp, Lamp, Stove Light].wait (0ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace ║║ Executed virtual command [Lamp].loadStateLocally (17ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: info ╔ Event processed successfully (2704ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:28 PM: trace ║║ Waiting for 500ms
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Executed physical command [Stove Light].off() (15ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:28 PM: trace ║║ Executed [Stove Light].setLevel (17ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Cancelling statement #14’s schedules…
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace ║║ Executed virtual command [Bedroom Lamp].loadStateLocally (18ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:28 PM: debug ║║ Executed physical command [Lamp].setLevel([60]) (15ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace ║║ Executed [Stove Light].off (17ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:28 PM: info smartapp_pause called by smartAppName=webCoRE Piston, value=500, smartAppVersionId=eba4eb9d-4efd-4bc8-b849-8f781f767758
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace ║║ Executed virtual command [Stove Light].loadStateLocally (18ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace ║║ Executed [Bedroom Lamp].setLevel (6ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:28 PM: debug ║║ Executed physical command [Bedroom Lamp].setLevel([60]) (15ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Executed physical command [Bedroom Lamp].off() (17ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: info smartapp_pause called by smartAppName=webCoRE Piston, value=500, smartAppVersionId=eba4eb9d-4efd-4bc8-b849-8f781f767758
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: debug ║║ Executed physical command [Lamp].setLevel([20]) (15ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:28 PM: trace ║║ Executed [Stove Light].setLevel (18ms)
3ffd564f-49d2-4069-9791-00425489e46d 8:02:29 PM: trace’


#2

Found another way to fade and it’s worning fine but restoration of dim level isn’t working and for some reason the light comes back on which isn’t what I’m looking for.


#3

Try adding a wait of a sec or two after capture, before turn on.


#4

So add it at the very beginning? I’ve changed it to this and the fade works fine, restoration of level works fine at first but then for some reason the lights come back on minutes later at a random level.


#5

Ok not sure why but even after shutting the lights off they come back on again minutes later yet again. In the notifications area it says the piston sent a setlevel command.


#6

Sorry, I fell asleep after I posted last night lol. What I meant was insert the wait between capture attribute level to local state; and turn on; (based on the original piston you posted.)


#7

Just curious, but what kind of lights are these?


#8

They’re all Cree Connected daylights and it makes me wonder if you truly do get what you pay for when getting smart bulbs from Home Depot for $15.97 each.


#9

Well the main reason I ask is because I use Osram Lightify bulbs. Which are also Zigbee. About a year ago, after reading the Zigbee documentation, I found there are commands you can send to your bulb via the device handler to tell it to fade for turning on, turning off and between levels. The speed is specified by time. Not all bulbs support the command, but if they do, the command is always the same.

I modified my device handler to set the default fade time as part of the configure function and I also made a custom function that sets it as well. So now any time I add a new bulb it sets the fade time. If the bulbs lose power (forgetting those settings) then I have a piston I can run that runs that custom function to fix the fading.

Perhaps it’s worth looking into doing the same for your bulb to see if that’s an option rather than trying to use a piston to do your fading.

Just an idea.

(Posting from my phone right now, but I can look up that command for you later when I’m at a computer if you want)


#10

Do you have any advice on how to do that? I’m fine with using custom code, but still haven’t actually customized any code myself.


#11

I sent you a PM with a sort of step by step in case you are interested in making the change. Don’t feel obligated to try and do it just because I sent you a write up though haha. If you want to stick with a piston because it’s working, then nothing wrong with that.