How do I turn on the power and the delay light?

I have a KNX switch for a luminaire that turns on the power supply separately and the luminaire separately
how to realize this on Home Assistant, so that there is one switch that turns on both power and light and also I need a delay after the power supply for the command to turn on the luminaire to pass

Let’s say I control the luminaire in the following way

  light:
  - name: “Main light”
    address: “1/1/7”
    state_address: “1/1/8”

power on like this

  switch:
  - name: “Power for main light”
    address: “1/1/37”
    state_address: “1/1/38”

How and where to connect everything into one switch and add a delay ?
Am I right to use the switch type for power on ? or can it be light or something else ?

What about using a Template Switch

first ill create to script to turn on/off the Light

some like

script_on:
alias: Script ON
sequence:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: light.dinning
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.alysha_lamp

the off bit

script_off:
alias: Script off
sequence:
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: light.dinning
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.alysha_lamp

now the Template Switch

Join the 2 scripts

  - platform: template
    switches:
      fan_switch:
        friendly_name: Main Light
        unique_id: 8c318522-ada5-47b5-b6b5-3c2159cd87dd
        value_template: '{{ is_state("switch.power_for_main_light", "on") }}'
        turn_on:
          action: script.turn_on
          target:
            entity_id: script.script_on
        turn_off:
          action: script.turn_on
          target:
            entity_id: script.script_off

I’m old school Like writing in yaml

but with some reading you should be able to do it in the GUI

2 Likes

Sorry for the delay, I couldn’t figure it all out at once.
I was unable to run the scripts from your example (I changed the names to my own, of course), but it ran like this

bedroom_deltalight_on:
  alias: Вкл Шайбы спальня
  sequence:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: light.pitanie_shaiby_v_spalne
  - delay: '00:00:05'
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: light.shaiby_v_spalne_mdt
  description: ''

bedroom_deltalight_off:
  alias: Выкл Шайбы спальня
  sequence:
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: light.shaiby_v_spalne_mdt
  - delay: '00:00:05'
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: light.pitanie_shaiby_v_spalne
  description: ''

Template Switch I created in the visual editor and it works correctly, I also like to write everything in code but I can not find where to store its code, in which yaml file to look for it ?

With out see the code in the template switch it going to be hard to see what wrong
Off top of head think it could be the value_template that is what controls the switch weather it’s on /off

1 Like

Where in HA can I find the code for Template Switch ? I haven’t figured it out yet

ok in my config file

I have a line

switch: !include switches.yaml

This is where i have all my switches

then in side that file

I have Platform of templates

  - platform: template
    switches:
      fan_switch:
        friendly_name: Main Light
        unique_id: 8c318522-ada5-47b5-b6b5-3c2159cd87dd
        value_template: '{{ is_state("switch.power_for_main_light", "on") }}'
        turn_on:
          action: script.turn_on
          target:
            entity_id: script.script_on
        turn_off:
          action: script.turn_on
          target:
            entity_id: script.script_off

JUst look in Helpers

look like you can do it there

I just leant something LOL

1 Like