Dynamic scene problem

Hi guys,

I created an automation to flash specific lights in red, when somebody presses the doorbell. I am creating a dynamic scene with snapshots of the current states of the specific lights to reset the lights to their inital state after the flashes.
But this doesnt really work. If the lights where initialy off, they stay red and dont turn off again.

Here is my automation:

[{"id":"f4bb13862c1e8f5e","type":"server-state-changed","z":"846206a6ec80b8ec","g":"8080347b2b363a71","name":"","server":"9b250c83.3b44f","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"binary_sensor.treppenhaus_ding","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"on","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":260,"y":1540,"wires":[["7c39a15a9d22a828"],[]]},{"id":"29a48490e2e3ebc8","type":"api-call-service","z":"846206a6ec80b8ec","g":"8080347b2b363a71","name":"Licht zurücksetzten","server":"9b250c83.3b44f","version":5,"debugenabled":false,"domain":"scene","service":"turn_on","areaId":[],"deviceId":[],"entityId":["scene.temp_ding"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1170,"y":1600,"wires":[["ed9ef3ec28965ecf"]]},{"id":"7c39a15a9d22a828","type":"api-call-service","z":"846206a6ec80b8ec","g":"8080347b2b363a71","name":"Dynamische Szene erstellen","server":"9b250c83.3b44f","version":5,"debugenabled":false,"domain":"scene","service":"create","areaId":[],"deviceId":[],"entityId":[],"data":"{\t   \"scene_id\":\"temp_ding\",\t   \"snapshot_entities\": [\t    \"light.arbeitsplatte_kuche\",\t    \"light.esstisch_oben\",\t    \"light.lampe_flur_1\",\t    \"light.led_tv\"\t   ]\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":620,"y":1540,"wires":[["25a9a0fc6e5c01e3"]]},{"id":"ed9ef3ec28965ecf","type":"api-call-service","z":"846206a6ec80b8ec","g":"8080347b2b363a71","name":"Szene löschen","server":"9b250c83.3b44f","version":5,"debugenabled":false,"domain":"scene","service":"delete","areaId":[],"deviceId":[],"entityId":["scene.temp_ding"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"reset","propertyType":"msg","value":"0","valueType":"str"}],"queue":"none","x":1380,"y":1600,"wires":[["25a9a0fc6e5c01e3"]]},{"id":"25a9a0fc6e5c01e3","type":"counter","z":"846206a6ec80b8ec","g":"8080347b2b363a71","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":"1","x":860,"y":1540,"wires":[["75cab1e843228b08"]]},{"id":"75cab1e843228b08","type":"switch","z":"846206a6ec80b8ec","g":"8080347b2b363a71","name":"","property":"count","propertyType":"msg","rules":[{"t":"lt","v":"20","vt":"str"},{"t":"eq","v":"20","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":990,"y":1540,"wires":[["2527e6e916d47a71"],["29a48490e2e3ebc8"]]},{"id":"2527e6e916d47a71","type":"api-call-service","z":"846206a6ec80b8ec","g":"8080347b2b363a71","name":"","server":"49b5425d.9340cc","version":5,"debugenabled":false,"domain":"light","service":"toggle","areaId":[],"deviceId":[],"entityId":["light.arbeitsplatte_kuche","light.esstisch_oben","light.lampe_flur_1","light.led_tv"],"data":"{\t   \"rgb_color\":[255,0,0],\t   \"brightness\": 255,\t   \"transition\": 0\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1150,"y":1540,"wires":[["c3f30670a22f4208"]]},{"id":"c3f30670a22f4208","type":"delay","z":"846206a6ec80b8ec","g":"8080347b2b363a71","name":"","pauseType":"delay","timeout":"200","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1400,"y":1540,"wires":[["25a9a0fc6e5c01e3"]]},{"id":"9b250c83.3b44f","type":"server","name":"Home Assistant","addon":true},{"id":"49b5425d.9340cc","type":"server","name":"Home Assistant","addon":true}]

It seems like the snaphot_entities doesn’t take a snapshot of their on/off state, only the color/brightness state. Is there a way to fix this?

What type of lights are these? are any wled? Does any of the lights return to their previous state? Maybe try without the delete scene at the end of the flow.

They are Hue bulbs and stripes. I will try to delete the scene at the end with a delay, maybe this helps

They all respond the same? Do you have any of them in a group? If yes expand the group. If it is one group, set data to jsonata and use $entity().attributes.entity_id for snapshot entities. If there are a mix it can get complicated The group would go first, then other single entities in the [ ].

{
   "scene_id":"test_lights",
   "snapshot_entities": $append($entities('light.group_name_here').attributes.entity_id, [$entities('switch.some_switch').entity_id, $entities('light.some_other_light').entity_id])
}
1 Like