Change state without action

First of all, help me :smiley: Been searching for a couple of hours but can’t find a solution.

So this is the setup:
I have a switch (relay) that when toggled on, triggers the light on and the relay turns off again but the light stays on. The relay has to turn off again, otherwise the switches won’t work again. Kind of an impulse relay system.

I’ve been able to make these switches smart so I can send the same toggle with HA and also read if the switch has been pressed.

Comes my ‘problem’.

I tried with Template Light to simulate a working light in HA in combination with the python_script.set_state. Scripts, automations,… Just not able to figure it out.

What I need:
Note: Switch.A goes on for 500ms and then off again. To send the impulse.
If Switch.A is on, Light.A goes on. If I turn Light.A off through HA, switch.A goes on.
If Light.A is on, and I press the switch.A button (IRL) the impulse is send, and in HA the light should turn off. Visa Versa as well.

I tried to work with Choose, also can’t figure it out. Also thought with Input_boolean, didn’t work. Just need an extra push or something :smiley:

Something I tried:

- alias: werkaubofzo
  trigger:
    - platform: state
      entity_id: switch.bijgebouw_kant_huis
      to: "on"
  mode: single
  action:
    - choose:
            conditions:
            - condition: state
              entity_id: light.bijgebouw_kant_huis
              state: "on"
            sequence:
            - service: python_script.set_state
              data:
                entity_id: light.bijgebouw_kant_huis
                state: 'off'
      default: 
            - service: python_script.set_state
              data:
                entity_id: light.bijgebouw_kant_huis
                state: "on"

I’VE FOUND IT! Anyone with latching relays, pulse switches, impulse switches, whatever haha.
If anyone every needs this, this the yaml’s I used:

One thing you have is the smart latching relay :slight_smile: called switch.yourlight in here:

In light.yaml add this:

  - platform: template 
    lights: 
      your_light:
        friendly_name: "your light"
        turn_on: 
          service: script.yourlight
        turn_off:
          service: script.yourlight

in input_boolean.yaml:

  your_light:
    name: your_light

in script.yaml:

yourlight:
  sequence:
  - service: homeassistant.turn_on
    target:
      entity_id: input_boolean.yourlight
  - delay: 1
  - service: homeassistant.turn_off
    target:
      entity_id: input_boolean.yourlight

in automation.yaml

- alias: yourlightautomation
  trigger:
    - platform: state
      entity_id: switch.yourlight
      to: "on"
  mode: single
  action:
      choose: 
      - conditions: 
        - condition: state
          entity_id: light.yourlight
          state: "on"
        sequence:
          - service: python_script.set_state
            data:
              entity_id: light.yourlight
              state: "off"
      - conditions:
        - condition: state
          entity_id: light.yourlight
          state: "off"
        sequence:
          - service: python_script.set_state
            data:
              entity_id: light.yourlight
              state: "on"

Maybe one day someone will find these usefull, maybe nobody won’t haha.

To give a little more info about my latching relays. I have a Conson setup at home that I can’t turn smart. I bougth this (Ethernet Relais Board Netwerk Mqtt Home Assistent Domoticz Modbus Wifi RS485 Kan Module Http Web Tcp Udp Coap Ip Watchdog timer|Access Control Kits| - AliExpress) to read the digital input from my switches and then send the signal with the relay’s from the device.

Greetings