Consolidate Switches

now I got you. There is no sensor.skylight with status “on/off” at the moment. Finally I need to create one based on trigger event
a_on → sensor.skylight (Status: on)
a_off → sensor.skylight (Status: off)

I’m a newbee in creating my own sensors. I found this:

I tried tried to modify but its not working.

template:
  - trigger:
      - platform: state
        entity_id: binary_sensor.skylight
  - sensor:
      - name: "skylight"
        state: >
          {%- if states('switch.a_on') -%}
            {{ states('sensor.skylight'), 'on' }}
          {%- endif -%}
          {%- if states('switch.a_off') -%}
            {{ states('sensor.skylight'), 'off' }}
          {%- endif -%}

Do you have an approach for this?