Roller shutter management with percentage opening

Hello everyone, I am new to Home Hassistant and I am trying to integrate shutter management via HA which are connected to the test Raspberry as in the following diagram

iot-tapp-pics-en.png

The secondary contacts of the relays (RS-UP/RS-DOWN) would be for the purpose of monitoring the status (S1/S2) of the shutter even when manually operated by the wall button.
Connected to the Raspberry are two relays (REL-1/REL-2) that are used as switches to prompt the relays connected to the shutter motor, also the intention is to use only wired components, so no wifi module or something like that.

However, I am experiencing some issues:

  • the relay on the Raspberry once activated continues to energize the shutter relay so I have to toggle it on and off with the HA toggle, the only indirect way I found to make it act as an impulse was to create a script that turns it on and marks it after about 1 sec. but I guess there is a more elegant way to achieve the same result so if you have any suggestions they are welcome

  • The other issue is that I would like to be able to also set the percentage of the shutter opening to update even the opening is changed manually by the wall button, again I was thinking of using the secondary contacts of the relays but I am having a hard time framing this, can you help me out?

By the way in the “Shutter Living Room” card, I only see the up arrow and the stop button, while the down arrow is gray.

Below I also post the code I used:

#config.yaml

cover:
  - platform: template
    covers:
      tappa_std:
        device_class: shutter
        friendly_name: "Shutter Living Room"
        value_template: closed
        open_cover:
          service: script.relay_pulse
        close_cover:
          service: script.relay_pulse
        stop_cover:
          service: script.relay_pulse


switch:
  - platform: rpi_gpio
    switches:
      - port: 23
        name: "Switch Shutter UP"
        unique_id: "shutter_up"
        invert_logic: true
      - port: 24
        name: "Switch Shutter Down"
        unique_id: "shutter_down"
        invert_logic: true
# script

alias: relay_pulse
sequence:
  - service: switch.turn_on
    entity_id: switch.switch_shutter_up
  - delay:
      milliseconds: 800
  - service: switch.turn_off
    entity_id: switch.switch_shutter_up
mode: single