Power Supply Switch as precondition for Light

Hello together,
I have a setup with a few LED stripes, and I’m looking for the most elegant way to configure them.

Some WS2812-Stripes are controlled by esphome, and integrated into home assistant. Their power supply (5V Meanwell) is switched by a Tasmota-Device, of course also integrated into home assistant. The LED-Stripes are used from multiple points (multiple automations, manually, scenes).
I haven’t found a proper way to deal with the power supply yet.

Including the power supply switch on into the scene won’t work out, as the light components themselves are unavailable until they got their power and contacted home assistant.
Adding a manual power-supply on to each automation with a delay may works out, but is pretty anoying and seams to be a dirty hack.

Is there any way to add something like a “hook” to the light entity? Something like “before_on: {{turn on switch}}”
My “dream” would be, that as soon as I turn on a light, home assistant automatically turns on the power switch. This would represent the dependency on device level (where it physically is), and simplifies all further handling of those lights.

I know esphome has something like this: https://esphome.io/components/power_supply.html
This of course does not help in this case, when not esphome locally but home assistant globally is in charge of the power supply.

Thanks!
margau

Use a script to turn on the outlet, wait_template for the led strips to be on, turn on the scene.

Call the script instead of the scene in the automation.

You could use one script and pass the outlet and scene you want as variables to reduce duplication.

Use a template switch . Test If the power switch is off if so turn it on. If your LED’s take some time to “wake up” switch on with a delay

Then you can turn both the LED’s and power switch off and on at the same time.

Hi,
my solution was a script:

led_stripe_on:
  alias: LED Stripes on
  sequence:
  - type: turn_on
    device_id: [...]
    entity_id: switch.sonoff
    domain: switch
  - alias: Control lights
    service: scene.turn_on
    data_template:
      entity_id: '{{scene}}'
  - wait_template: '{{ not (is_state(''light.neopixel_light'', ''unavailable'') or  is_state(''light.neopixel_light_2'',
      ''unavailable'') or is_state(''light.neopixel_light_3'', ''unavailable''))}}'
    continue_on_timeout: true
    timeout: 00:01:00
  - alias: Control lights
    service: scene.turn_on
    data_template:
      entity_id: '{{scene}}'
  mode: restart
  max: 10

Still not the most elegant way, but the best I found for now.
Unfortunately, I had (and still will have) problems with the availability time of esphome nodes.
Tried to get this configureable, but the PR war rejected (https://github.com/home-assistant/core/pull/41648). I still don’t have an idea how to minimize time from switch turning on to the light available in home assistant.

Best regards
margau

I do much the same . I use a Binary sensor to test against. So If true I know the lights are ready to accept any dimming commands

lrsync:
        friendly_name: 'Livingroom Light Sync'
        value_template: >-
          {% if is_state('light.lr1', 'on') 
          and is_state('light.lr2', 'on') 
          and is_state('light.lr3', 'on') 
          and is_state('light.dr1', 'on') 
          and is_state('light.dr2', 'on') 
          and is_state('light.dr3', 'on') 
          and is_state('switch.wall_switch_158d00016cf4bc', 'on')
          %}
            true
          {% else %}
            false
          {% endif %}