this post was submitted on 19 Feb 2026
71 points (97.3% liked)

homeassistant

18498 readers
26 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
you are viewing a single comment's thread
view the rest of the comments
[–] Ludicrous0251@piefed.zip 1 points 15 hours ago

Here is the full script in case it's helpful. took a hot second of searching to set everything up, but now it's really easy to use. When you call the script inside an automation it has input fields just like if you're calling a built-in function like light.turn_on

For your specific use case though, it may be easier to just take advantage of the built-in Scenes function. You can use an "entity snapshot" with "Scene: Create" a scene of the current state of your "bad" lights when the power goes out, then "Activate" that scene, perhaps with a couple of seconds transition time to smooth things out as soon as power is restored.

I use a similar scene based function to create flashing colored light alerts based on certain conditions.

sequence:
  - repeat:
      for_each: "{{ lights }}"
      sequence:
        - variables:
            light_state: "{{states(repeat.item)}}"
            timescale: "{{states('input_number.timescale')}}"
        - if:
            - condition: template
              value_template: "{{light_state == 'on'}}"
          then:
            - metadata: {}
              data:
                brightness_pct: "{{target_brightness}}"
                transition: "{{transition_rate * timescale}}"
                kelvin: "{{color_temperature}}"
              target:
                entity_id: "{{repeat.item}}"
              action: light.turn_on
fields:
  lights:
    selector:
      entity:
        multiple: true
        filter:
          - domain: light
    name: Light(s)
    required: true
  target_brightness:
    selector:
      number:
        min: 1
        max: 100
    name: Target brightness (%)
    default: 1
    required: true
  color_temperature:
    selector:
      color_temp:
        unit: kelvin
        min: 1500
        max: 7000
    name: Color temperature
    required: true
    default: 2200
  transition_rate:
    selector:
      number:
        min: 1
        max: 600
    name: Transition rate
    description: Transition rate, scaled by 'input_number.timescale'
    required: true
    default: 100
description: Dims the target light(s) if they are on - Kelvin setpoint.
icon: mdi:lightbulb-auto-outline
mode: parallel
max: 15