Got a little help from CGPT so it might not be perfect, but this seems to work from my limited testing:
triggers:
- trigger: state
entity_id:
- input_boolean.ups_power
conditions: []
actions:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.ups_power
state:
- "on"
sequence:
- action: scene.create
data:
scene_id: light_states_backup
snapshot_entities: |
{{ states.light | map(attribute='entity_id') | list }}
- conditions:
- condition: state
entity_id: input_boolean.ups_power
state:
- "off"
sequence:
- action: scene.turn_on
target:
entity_id: scene.light_states_backup
data: {}
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- action: scene.delete
data:
entity_id: scene.light_states_backup
mode: single
I've only tested it by toggling the UPS boolean manually and not actually cutting the power, so I'm probably going to need to add a delay, or a retry loop or something to make sure the scene applies consistently but so far so good! Thanks for the inspiration.