ESPHOME switch template unexpected off

Hi, yes I found how to make it work, I’ve been using it for a long time and it’s ultra stable.
The bug is found in the publication of the change of state which, unlike other buttons etc in the case of the switch, is published at the end, but in our case it does not allow maintaining the position.
I fixed it by posting manually right away

  - platform: template
    id: cover_vasistas_manual
    name: Vasistas Manuale
    turn_on_action:
      - switch.template.publish: 
          id: cover_vasistas_manual
          state: ON
      - cover.stop: cover_vasistas
      - ............
    turn_off_action:
      - switch.template.publish: 
          id: cover_vasistas_manual
          state: OFF
      - ............
    icon: "mdi:gesture-swipe"
    optimistic: false
3 Likes