Opening and Closing state of Roller Shutter

How can i amend my cover template code to be able to get opening and closing states for the roller shutter door ?


cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Roller Shutter"
        value_template: >-
          {% if is_state('binary_sensor.shutter_sensor_contact','on') %}
            Open
          {% else %}
            Closed
          {% endif %}
        open_cover:
          service: switch.toggle
          data:
            entity_id: switch.shutter
        close_cover:
          service: switch.toggle
          data:
            entity_id: switch.shutter
        stop_cover:
          service: switch.toggle
          data:
            entity_id: switch.shutter_plug_2
        icon_template: >-
          {% if is_state('binary_sensor.shutter_sensor_2_ias_zone','on') %}
            mdi:garage-open
          {% else %}
            mdi:garage
          {% endif %}

Please dont post pictures of text. Post the correctly formatted text. That way people can copy / edit / paste to show you a solution.

Sorry about that, changed original post :slightly_smiling_face:

For a start you can change this:

        value_template: >-
          {% if is_state('binary_sensor.shutter_sensor_contact','on') %}
            Open
          {% else %}
            Closed
          {% endif %}

To this:

        value_template: "{{ is_state('binary_sensor.shutter_sensor_contact', 'on') }}"

As the value template accepts true and false as results as well:

Screenshot 2022-04-29 at 02-15-07 Template Cover
https://www.home-assistant.io/integrations/cover.template/#value_template

As you are using the same service to open and close your cover you should guard against pressing a button twice, which will have the opposite effect to what you want.

        open_cover:
          - condition: state
            entity_id: cover.garage_door
            state: closed
          - service: switch.toggle
            data:
              entity_id: switch.shutter
        close_cover:
          - condition: state
            entity_id: cover.garage_door
            state: open
          - service: switch.toggle
            data:
              entity_id: switch.shutter

Are you sure you really want the toggle service?

Do you turn the switch on to open and close?

How does the switch get turned off?

Toggle just swaps the state, on toggles to off, or off toggles to on. “Toggle” does not generate a momentary pulse.

So the set up I have is that I have a switch bot, bit pressing the button on the remote key fob which then opens and closes the shutter.

hi, I wanted some info, I have roller shutter actuators that don’t give me back the status if it is closed or open, can someone help me define the status of these actuators so I know if they are open or closed thanks in advance