Configure relay for external latching switch as light

Hi dear community,
for years I have a working solution controlling my lights in the hallway though from time to time I have issues because I had to setup it as a switch and not as a light component.
Several tries to solve this as a light component failed.
The lights in the hall way are triggered with a latching switch and my ESPhome device just acts as an other trigger switch for this latching switch. It also includes a sensor circuit connected to the line the latching switch controls so it knows if the light is on even it didn’t trigger itself.
Here is an excerpt of my config:

  - platform: gpio
    id: sensor1
      number: 4
      inverted: true
    device_class: power
      - delayed_on: 50ms
      - delayed_off: 50ms

  - platform: gpio
    id: relay1
    pin: 12

  - platform: template
    id: trigger_relay1
    type: binary
      - output.turn_on: relay1
      - delay: 250ms
      - output.turn_off: relay1

  - platform: template
    id: switch_relay1
    name: ${friendly_name}1
    lambda: |-
      return id(sensor1).state;
          binary_sensor.is_off: sensor1
          output.turn_on: trigger_relay1
          binary_sensor.is_on: sensor1
          output.turn_off: trigger_relay1

The problem for me to change this to the light component is that there is not template light like there is for a switch. I need that because the state of the output does not reflect the state of the light because the output just triggers the external latching switch.
With a template switch I can do this using a lambda expression.
So going over and over this I have no idea how to do this with a light in the end.
But I’d really love to have this as a real light because for example using a light card, which looks and acts a little different than a switch card and using a switch cards mixed with all the other lights.

Any ideas?