Esphome multi_click help

Hi, I am having problems with on_multi_click where the physical switch connected to my esp module is not updated with the switch state from home assistant.
The part that is commented out works for keeping sync but doesn’t work for the second part of turning off/on the light.lower_hall.
Please help this has been wreaking my head for months.


binary_sensor:
  - platform: gpio
    filters:
      delayed_on_off: 50ms
    pin:
      number: 3
      mode: INPUT_PULLUP
    id: button_2
    on_multi_click:
    - timing:
      - OFF for at least 0.41s
      then:
        # if:
        #   condition:
        #     light.is_on: light_1
        #   then:
        #     - light.turn_off: light_1
        #   else:
        #     - light.turn_on: light_1
          - light.turn_off: light_1
    - timing:
      - ON for at least 0.41s
      then:
        # if:
        #   condition:
        #     light.is_off: light_1
        #   then:
        #     - light.turn_on: light_1
        #   else:
        #     - light.turn_off: light_1
        - light.turn_on: light_1
    - timing:
      - ON for at most 0.3s
      - OFF for at least 0.1s
      then:
      - homeassistant.service:
          service:  light.toggle
          data:
            entity_id:  light.lower_hall
    - timing:
      - OFF for at most 0.3s
      - ON for at least 0.1s
      then:
      - homeassistant.service:
          service:  light.toggle
          data:
            entity_id:  light.lower_hall

output:
  - platform: gpio
    pin: 12
    id: relay_1

light:
  - platform: binary
    name: "Hall"
    id: light_1
    output: relay_1

I fixed it.
If anyone is curious on what to do, you need to add a home assistant binary sensor in esphome.

This works for toggle type light switches.
It allows for a single switch to control 2 or more devices independently of each other.

The code below is how it works.

binary_sensor:
  # This is the binary sensor I added 
  - platform: homeassistant
    name: "lowerhall"
    entity_id: light.lower_hall
    id: lowerhall
    internal: true
  # Pin for physical lightswitch (toogle) 
  - platform: gpio
    filters:
      delayed_on_off: 50ms
    pin:
      number: 3
      mode: INPUT_PULLUP
    name: hall
    internal: true
    id: hall
    on_multi_click:
    - timing:
      - ON for at most 0.3s
      - OFF for at least 0.1s
      then:
        if:
          condition:
            binary_sensor.is_on: lowerhall
          then:
            - homeassistant.service:
                service:  light.turn_off
                data:
                  entity_id:  light.lower_hall
          else:
            - homeassistant.service:
                service:  light.turn_on
                data:
                  entity_id:  light.lower_hall
    - timing:
      - OFF for at most 0.3s
      - ON for at least 0.1s
      then:
        if:
          condition:
            binary_sensor.is_off: lowerhall
          then:
            - homeassistant.service:
                service:  light.turn_on
                data:
                  entity_id:  light.lower_hall
          else:
            - homeassistant.service:
                service:  light.turn_off
                data:
                  entity_id:  light.lower_hall
    - timing:
      - ON for at least 0.31s
      - OFF for at least 0.31s
      then:
        if:
          condition:
            light.is_on: light_1
          then:
            - homeassistant.service:
                service:  light.turn_off
                data:
                  entity_id:  light.hall
          else:
            - homeassistant.service:
                service:  light.turn_on
                data:
                  entity_id:  light.hall
    - timing:
      - OFF for at least 0.31s
      - ON for at least 0.31s
      then:
        if:
          condition:
            light.is_off: light_1
          then:
            - homeassistant.service:
                service:  light.turn_on
                data:
                  entity_id:  light.hall
          else:
            - homeassistant.service:
                service:  light.turn_off
                data:
                  entity_id:  light.hall

output:
  - platform: gpio
    pin: 12
    id: relay_1

light:
  - platform: binary
    name: "Hall"
    id: light_1
    output: relay_1