Cover time based and wall button

I all, I have this configuration:

  - platform: cover_time_based
    devices:
      test:
       name: test
       travelling_time_down: 10
       travelling_time_up: 10
       open_switch_entity_id: light.rete230
       close_switch_entity_id: light.tapparella6
       aliases:
        - test

In home assistant everything is working:
image
If I press UP/DOWN the cover goes UP/DOWN, if I move the cursor the cover moves in the right position…

The problem is that: I want to sync home assistant to my wall buttons.
By HA I can control only the up and down relay…

So I need to create two automations that see when the UP/DOWN relay are excited by the wall buttons…
I’m trying a code like this:

alias: AAA su (Duplica)
description: ''
trigger:
  - platform: state
    entity_id: light.rete230
    from: 'off'
    to: 'on'
condition: []
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 200
  - condition: state
    entity_id: light.rete230
    state: 'off'
  - service_template: |-
      {% if is_state('light.tapparella6','on')  %}
        cover.stop_cover
      {% else %}
        cover.open_cover
      {% endif %}
    entity_id: cover.test
mode: single

The idea of the automation is:
-if the relay is on and goes off after some milliseconds it means that the wall button is pressed so the service open_cover must be called
-if the relay is on and remains on after some milliseconds it means that the cover moves by the HA button and no action are required
-if the relay is on and goes off after some milliseconds and the other relay is ON it means that I need to stop the cover

But it doesn’t work…
Can I solve this?