graLf
(GraLf)
July 6, 2025, 9:53pm
1
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
graLf
(GraLf)
July 14, 2025, 11:01am
3
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
graLf
(GraLf)
July 18, 2025, 6:25am
4
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
graLf:
- name: Persiana - 2
Does it appear if you remove the - 2 from the name?
graLf
(GraLf)
July 23, 2025, 4:56pm
6
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…
graLf
(GraLf)
July 24, 2025, 6:47am
8
Sorry I don’t get what you mean.