sender
November 24, 2020, 8:32am
1
I am using:
cover:
- platform: template
covers:
tuin_voor_poort_cover:
device_class: gate
friendly_name: "Tuin Poort"
value_template: "{{ is_state('binary_sensor.tuin_v_poort_sensor_956', 'on') }}"
open_cover:
service: script.pulse_gate
close_cover:
service: script.pulse_gate
With:
pulse_gate:
alias: pulse_gate
sequence:
- service: switch.turn_on
data: {}
entity_id: switch.tuin_v_poort_e1_schakelaar_1188
- delay: '1'
- service: switch.turn_off
data: {}
entity_id: switch.tuin_v_poort_e1_schakelaar_1188
mode: single
icon: mdi:gate
resulting in:
This works well in usage!
But I cannot use this in an automation.
If I do call a service t open cover or close a cover it can easily do the opposite.
So if the cover is closed, If I open it, it opens. But if is already open and I call service to open it closes!
this way it is not reliable in an automation (or in node-red).
What is wrong with this behavior? Did I miss any setting?
callifo
(Callifo)
November 24, 2020, 8:37am
2
You probably need to adapt yours like I have mine; only open the cover if the current status is closed, and vice versa.
open_cover:
service_template: >
{% if is_state('cover.garage_door', 'closed') %}
cover.open_cover
{% else %}
script.do_nothing
{% endif %}
entity_id: cover.left_garage
close_cover:
service_template: >
{% if is_state('cover.garage_door', 'open') %}
cover.close_cover
{% else %}
script.do_nothing
{% endif %}
Mine was more of a security concern. You could tell Google Assistant to âclose the garage doorâ when it was closed, to make it open without a security pin. Pretty bad if someone decides to tell the GA speaker to do that whilst you are out.
1 Like
sender
November 24, 2020, 8:43am
3
Thank you. I have to look in.
What I find strange is that when the âcoverâ is already closed/opened" and I call service to close/open I would expect no action when the state is already the same.
Is that a correct assumption?!
callifo
(Callifo)
November 24, 2020, 9:02am
4
Unfortunately not, no.
HA does not check whether something is already open or not, it just runs the command. For items that use the same button for open and close, this will actually toggle the state incorrectly.
The above, will filter out that behavior.
sender
November 24, 2020, 9:58am
5
Ok, lostâŚ
I am not good in scripting and I do not fully understand what I am doing⌠I tried to make:
cover:
- platform: template
covers:
tuin_voor_poort_cover:
device_class: gate
friendly_name: "Tuin Poort"
value_template: "{{ is_state('binary_sensor.tuin_v_poort_sensor_956', 'on') }}"
open_cover:
service_template: >
{% if is_state('cover.tuin_voor_poort_cover', 'closed') %}
script.pulse_gate
{% else %}
script.do_nothing
{% endif %}
close_cover:
service_template: >
{% if is_state('cover.tuin_voor_poort_cover', 'open') %}
script.pulse_gate
{% else %}
script.do_nothing
{% endif %}
But this is not correct?
sender
November 24, 2020, 10:01am
6
What is this code part of? Of the cover or a script?
sender
November 24, 2020, 10:25am
7
This gives an error:
cover:
- platform: template
covers:
tuin_voor_poort_cover:
device_class: gate
friendly_name: "Tuin Poort"
value_template: "{{ is_state('binary_sensor.tuin_v_poort_sensor_956', 'on') }}"
open_cover:
service_template: >
{% if is_state('cover.tuin_voor_poort_cover', 'closed') %}
cover.open_cover
{% else %}
script.do_nothing
{% endif %}
# entity_id: cover.left_garage
close_cover:
service_template: >
{% if is_state('cover.tuin_voor_poort_cover', 'open') %}
cover.close_cover
{% else %}
script.do_nothing
{% endif %}
Cover is real-life open but shows closed then. When trying to open:
Error:
EDIT:
This gets rid of the error but no response when pressing button. And state not correctâŚ
cover:
- platform: template
covers:
tuin_voor_poort_cover:
device_class: gate
friendly_name: "Tuin Poort"
value_template: "{{ is_state('binary_sensor.tuin_v_poort_sensor_956', 'on') }}"
open_cover:
service_template: >
{% if is_state('cover.tuin_voor_poort_cover', 'closed') %}
cover.open_cover
{% else %}
script.do_nothing
{% endif %}
entity_id: cover.tuin_voor_poort_cover
close_cover:
service_template: >
{% if is_state('cover.tuin_voor_poort_cover', 'open') %}
cover.close_cover
{% else %}
script.do_nothing
{% endif %}
callifo
(Callifo)
November 24, 2020, 11:00am
8
You canât open a cover from itself, its a circular reference. You need to incorporate my script above for your use case. It should be something like,
cover:
- platform: template
covers:
tuin_voor_poort_cover:
device_class: gate
friendly_name: "Tuin Poort"
value_template: "{{ is_state('binary_sensor.tuin_v_poort_sensor_956', 'on') }}"
open_cover:
service_template: >
{% if is_state('cover.tuin_voor_poort_cover', 'closed') %}
script.pulse_gate
{% else %}
script.do_nothing
{% endif %}
close_cover:
service_template: >
{% if is_state('cover.tuin_voor_poort_cover', 'open') %}
script.pulse_gate
{% else %}
script.do_nothing
{% endif %}
You also need a script called do_nothing, with nothing in it, or it will also cause an error when you run it.
2 Likes
sender
November 24, 2020, 11:18am
9
I think I have it running!
So coolâŚ!
Thank you!
1 Like
sender
November 2, 2024, 6:56pm
10
4 years laterâŚ
Change service
to action
and it works again.
sender
November 2, 2024, 7:46pm
11
Ok still something wrong:
Logger: homeassistant.helpers.config_validation
Source: helpers/config_validation.py:1200
First occurred: 20:37:52 (1 occurrences)
Last logged: 20:37:52
The cover integration does not support any configuration parameters, got [{âplatformâ: âtemplateâ, âcoversâ: {âtuin_voor_poort_coverâ: {âdevice_classâ: âgateâ, âfriendly_nameâ: âTuin Poortâ, âvalue_templateâ: â{{ is_state(âbinary_sensor.door_windows_sensor_blauwe_hekjeâ, âonâ) }}â, âopen_coverâ: {âactionâ: â{% if is_state(âcover.tuin_voor_poort_coverâ, âclosedâ) %}\n script.pulse_open_gate\n{% else %}\n script.do_nothing\n{% endif %}\nâ}, âclose_coverâ: {âactionâ: â{% if is_state(âcover.tuin_voor_poort_coverâ, âopenâ) %}\n script.pulse_close_gate\n{% else %}\n script.do_nothing\n{% endif %}â}}}}]. Please remove the configuration parameters from your configuration.
Trying this for a few days:
#OLD
- platform: template
covers:
tuin_voor_poort_cover:
device_class: gate
friendly_name: "Tuin Poort"
value_template: "{{ is_state('binary_sensor.door_windows_sensor_blauwe_hekje', 'on') }}"
open_cover:
action: >
{% if is_state('cover.tuin_voor_poort_cover', 'closed') %}
script.pulse_open_gate
{% else %}
script.do_nothing
{% endif %}
close_cover:
action: >
{% if is_state('cover.tuin_voor_poort_cover', 'open') %}
script.pulse_close_gate
{% else %}
script.do_nothing
{% endif %}
#NEW
- platform: template
covers:
tuin_voor_poort_cover:
device_class: gate
friendly_name: "Tuin Poort"
value_template: "{{ is_state('binary_sensor.door_windows_sensor_blauwe_hekje', 'on') }}"
open_cover:
action: script.pulse_open_gate
close_cover:
action: script.pulse_close_gate