Cover card, change default button action

Hi there, I just installed some window open/close sensors, so now i want to change the default action when you want to close the cover to use a script wich will check that point.

I tried editing in yaml mode the button, but then all th icons disspaeared.

I’d suggest using a cover template to call your script

# Example state-based configuration.yaml entry
template:
  - cover:
      - name: Garage Door
        state: "{{ states('sensor.garage_door')|float > 0 }}"
        device_class: garage
        open_cover:
          action: script.open_garage_door
        close_cover:
          action: script.close_garage_door
        stop_cover:
          action: script.stop_garage_door
# Example trigger-based configuration.yaml entry
template:
  - triggers:
      - trigger: state
        entity_id: sensor.garage_door
    cover:
      - name: Garage Door
        state: "{{ trigger.to_state.state|float(0) > 0 }}"
        device_class: garage
        open_cover:
          action: script.open_garage_door
        close_cover:
          action: script.close_garage_door
        stop_cover:
          action: script.stop_garage_door
2 Likes

thank you very much. Nice to know.

anyone who woould explain the two examples codes for me, please?

in the first example, what does this do?

state: "{{ states('sensor.garage_door')|float > 0 }}"

and in the second one, what about this piece ?

- triggers:
      - trigger: state
        entity_id: sensor.garage_door
    cover:
      - name: Garage Door
        state: "{{ trigger.to_state.state|float(0) > 0 }}"

thanks in advance

I´ve tryed this

template:
  - cover:
      - name: Persiana - 2
        device_class: cover
        open_cover:
          action: script.open_persiana_2
        close_cover:
          action: script.close_persiana_2
        stop_cover:
          action: script.stop_persiana_2

but I can´t find a espected Persiana - 2 cover anywhere

Does it appear if you remove the - 2 from the name?

hi there, just fixed it. with this code

cover:
  - platform: template
    covers:
      persiana_segura_2:
        friendly_name: "Persiana Segura 2"
        open_cover:
          service: cover.open_cover
          target:
            entity_id: cover.2
        close_cover:
          service: script.cerrar_persiana_2
        stop_cover:
          service: cover.stop_cover
          target:
            entity_id: cover.2
        position_template: "{{ state_attr('cover.2', 'current_position') }}"
        set_cover_position:
          service: cover.set_cover_position
          target:
            entity_id: cover.2
          data:
            position: "{{ position }}"
        icon_template: >
          {% if is_state('cover.2', 'open') %}
            mdi:blinds-open
          {% else %}
            mdi:blinds
          {% endif %}

You realize the Cover template info provided earlier in this thread was the ACTUAL solution. Your posted resolution is specific to YOUR needs.

I felt the need to mention this after seeing your other post

Glad you figured it out…

Sorry I don’t get what you mean.