75
you are viewing a single comment's thread
view the rest of the comments
[-] TedZanzibar@feddit.uk 1 points 21 hours ago

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.

[-] Ludicrous0251@piefed.zip 1 points 20 hours ago

snapshot_entities: | {{ states.light | map(attribute='entity_id') | list }}

This is the only part I'm unsure about, seems like a clunky way to get all of the lights, but if only certain ones are causing problems, I'd just put the problem ones here as a list (or create a light group in HA and only call that group

Also, input_boolean.ups_power feels like ChatGPT is assuming you have a helper for the current power status, but I would just call directly from the UPS entity. You should be able to clean this up in the GUI.

[-] TedZanzibar@feddit.uk 1 points 19 hours ago

That first line is what CGPT helped me with. I wanted something that I don't need to modify when I add or remove lights, so this just gets everything. Ideally I'd just get the lights that don't have the power restore feature but most of my lights go via Hue and that doesn't expose the feature to HA at all.

The input_boolean is a thing I already had setup. The UPS fires a webhook event when it goes in and out of battery mode and there's a separate automation that switches the helper based on those.

this post was submitted on 19 Feb 2026
75 points (97.5% liked)

homeassistant

18517 readers
12 users here now

Home Assistant is open source home automation that puts local control and privacy first.
Powered by a worldwide community of tinkerers and DIY enthusiasts.

Home Assistant can be self-installed on ProxMox, Raspberry Pi, or even purchased pre-installed: Home Assistant: Installation

Discussion of Home-Assistant adjacent topics is absolutely fine, within reason.
If you're not sure, DM @GreatAlbatross@feddit.uk

founded 2 years ago
MODERATORS