How To Cancel "Scene On The Fly"

I’ve created a Node Red flow for my movie theatre that uses HA’s scene.create function to capture the state of several lights in the room prior to adjusting lights for movie viewing. The same flow is used to reset the lights to their prior state once the movie is over. The Node Red flow is initiated via an HA helper switch, activated through use of Google voice commands; “Hey Google, House Lights Down” or “Hey Google, House Lights Up”. When the switch is turned on, “house lights” dim or are switched off accordingly. When the switch is turned off, “house lights” are returned to their previous state. The Google voice commands and flow works great, except for one thing!

If the movie viewer fails to call the flow that returns room lighting to normal, the helper switch isn’t turned off. This prevents the flow from running the next time a “Hey Google, House Lights Down” is called. I thought I could overcome the issue by setting the helper switch to off using another flow that turns off all lights in the house at 1:00 am. However, as it should, the scene in the room is restored to it’s prior state leaving many lights in the theatre on.

I thought one way of getting around this would be, before turning the helper switch off, to destroy the scene created when the flow was called . I cannot find a way of doing so. Is there a way to destroy the scene?

Here is the Node Red flow I’m using;

[{"id":"39b757249008f12c","type":"comment","z":"0feb6dd07c9438fe","name":"Movie Time","info":"Capture state of lights in Library, Studio, Stairway and Guest Hallway. Turn these lamps off then set library pots to low setting.","x":130,"y":260,"wires":[]},{"id":"c404737968a06c46","type":"api-call-service","z":"0feb6dd07c9438fe","name":"Stairs","server":"fcf9b76b.256a88","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":["83835fdc48d715148c6bc0967fa2b12f"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":630,"y":500,"wires":[[]]},{"id":"989126a29c1cc319","type":"api-call-service","z":"0feb6dd07c9438fe","name":"Dim Picture Stairway","server":"fcf9b76b.256a88","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":["16007242ece1b11d64ebf2481291508c"],"entityId":[],"data":"{\"brightness_pct\":3}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":960,"y":380,"wires":[[]]},{"id":"139f768bd846a101","type":"api-call-service","z":"0feb6dd07c9438fe","name":"Library Canoe","server":"fcf9b76b.256a88","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":["44150119e20c3dbe80906fd12918fd65"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":660,"y":560,"wires":[[]]},{"id":"f22fa8570eef458b","type":"api-call-service","z":"0feb6dd07c9438fe","name":"Easel Lamp","server":"fcf9b76b.256a88","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.easel_light"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":650,"y":800,"wires":[[]]},{"id":"f58c73d0cb6c39af","type":"api-call-service","z":"0feb6dd07c9438fe","name":"Guest Hallway","server":"fcf9b76b.256a88","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.guest_hall"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":660,"y":860,"wires":[[]]},{"id":"b973e2c5cacdcada","type":"api-call-service","z":"0feb6dd07c9438fe","name":"Library Reading Lamp","server":"fcf9b76b.256a88","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":["11134b0c15f111ebb365b530ab709592"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":680,"y":620,"wires":[[]]},{"id":"0dfdd3b737749818","type":"api-call-service","z":"0feb6dd07c9438fe","name":"Dim Library Pots","server":"fcf9b76b.256a88","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":["5a342058b239db55920f1d582f32fae2"],"entityId":[],"data":"{\"brightness_pct\":3}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":940,"y":440,"wires":[[]]},{"id":"5b9cadeb4414af64","type":"api-call-service","z":"0feb6dd07c9438fe","name":"Studio Pots","server":"fcf9b76b.256a88","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.studio_pot_lights"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":650,"y":680,"wires":[[]]},{"id":"6d64f7cb5501b109","type":"api-call-service","z":"0feb6dd07c9438fe","name":"Studio Table lamp","server":"fcf9b76b.256a88","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.studio_table_lamp"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":670,"y":740,"wires":[[]]},{"id":"fc1fdf1b9d6b96f2","type":"comment","z":"0feb6dd07c9438fe","name":"Turn Unnecessary Lights Off","info":"With exception of Library Pots and Picture Stairway, turn off any lamps in the library area that are on.","x":700,"y":300,"wires":[]},{"id":"c607b274f26cf06c","type":"comment","z":"0feb6dd07c9438fe","name":"Determine Current Lighting State","info":"","x":410,"y":300,"wires":[]},{"id":"0372a1f62bc36305","type":"comment","z":"0feb6dd07c9438fe","name":"Dim Remaining Lights","info":"","x":960,"y":300,"wires":[]},{"id":"4ef557b336d7673a","type":"comment","z":"0feb6dd07c9438fe","name":"Restore Previous Lighting State","info":"","x":1230,"y":300,"wires":[]},{"id":"2c82d2d3094d677c","type":"api-call-service","z":"0feb6dd07c9438fe","name":"Snapshot Entities","server":"fcf9b76b.256a88","version":5,"debugenabled":true,"domain":"scene","service":"create","areaId":[],"deviceId":[],"entityId":[],"data":"{\"scene_id\":\"before\",\"snapshot_entities\":[\"switch.stairs\",\"light.picture_stairway\",\"light.library_pots\",\"light.library_canoe\",\"switch.reading_lamp\",\"switch.studio_pot_lights\",\"switch.studio_table_lamp\",\"switch.easel_light\",\"switch.guest_hall\"]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":370,"y":380,"wires":[["c404737968a06c46","989126a29c1cc319","0dfdd3b737749818","139f768bd846a101","b973e2c5cacdcada","5b9cadeb4414af64","6d64f7cb5501b109","f22fa8570eef458b","f58c73d0cb6c39af"]],"info":"Using a 'Snappshot' command, capture current state of the following entities;\n        \"switch.stairs\",\n        \"light.picture_stairway\",\n        \"light.library_pots\",\n        \"light.library_canoe\",\n        \"switch.reading_lamp\",\n        \"switch.studio_pot_lights\",\n        \"switch.studio_table_lamp\",\n        \"switch.easel_light\",\n        \"switch.guest_hall\""},{"id":"6385ccd56c623281","type":"server-state-changed","z":"0feb6dd07c9438fe","name":"Movie Time","server":"fcf9b76b.256a88","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.movie_time","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"false","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":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":150,"y":360,"wires":[["3c22dc3262fc577a"],["2c82d2d3094d677c"]],"outputLabels":["Raise House Lights","Lower House Lights"]},{"id":"3c22dc3262fc577a","type":"api-call-service","z":"0feb6dd07c9438fe","name":"Restore Entities State","server":"fcf9b76b.256a88","version":5,"debugenabled":false,"domain":"scene","service":"turn_on","areaId":[],"deviceId":[],"entityId":["scene.before"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":1200,"y":360,"wires":[[]]},{"id":"fcf9b76b.256a88","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30"}]

Thanks in advance for your insight.

After the call service to reset the switch @ 1am, turn off all the lights.

Edit if you call scene.create right before resetting the boolean @1am, it will over write the scene when all the lights are off.

Wow, the answer was right in front of me all the time! HA documentation mentions this but I failed to realize how it would apply. Thank you very much, Mike.