Hi there,
I need to push a button for a small amount of time within a cover template action. As of documentation, I am allowed to configure a delay either by using the “HH:MM:SS” notation, or by setting the milliseconds, seconds, etc. attributes directly. In my current configuration I was using the milliseconds attribute to set a 50ms delay between toggling of switching a button on and off.
stop_cover:
- choose:
- conditions: >
{{ this.state == "closing" or this.state == "opening" }}
sequence:
# stop moving
- service: switch.turn_on
data:
entity_id: switch.garagentor_relay_0
- delay:
milliseconds: 50
- service: switch.turn_off
data:
entity_id: switch.garagentor_relay_0
Unfortunately, when executing this script, the log tells me, that this notion is not supported:
Garagentor: Choose at step 1: choice 2: Error rendering Garagentor: Choose at step 1: choice 2 delay template: offset milliseconds: 50 should be format 'HH:MM', 'HH:MM:SS' or 'HH:MM:SS.F'
What am I missing? Where can I find information about the ‘HH:MM:SS.F’ notation? I would assume the .F could be used for my 50ms delay, but how?
“00:00:00.05” ? or “00:00:00.02” ?
Thanks in advance,
BR, Stefan
At first look that looks right. Syntax, indents. I’d try a couple of things.
does the error go away if you remove the delay?
does the error go away if you change it to a 1 second delay - delay: “00:00:01”
does it go away if you make it 500ms instead?
123
(Taras)
February 6, 2023, 2:08pm
3
Sorry, misread the post; overlooked the fact it’s a Template Cover (not a script).
Post the Template Cover’s entire configuration.
I have changed it now to the ‘HH:MM:SS.F’ format (‘00:00:00.1’) and this seemed to work.
And yes, removal of the delay works as well.
Somehow also changing to 500ms delay seems to work.
So maybe the problem is more because of a to small time value?
cover:
- platform: template
covers:
garage_door:
unique_id: "cover.garagentor"
device_class: garage
friendly_name: "Garagentor"
value_template: >
{% if states('binary_sensor.garagentor_input_1') == "on" %}
open
{% elif states('binary_sensor.garagentor_input_0') == "on" %}
closed
{% else %}
{% if as_timestamp(states.binary_sensor.garagentor_input_0.last_changed) > as_timestamp(states.binary_sensor.garagentor_input_1.last_changed) %}
opening
{% else %}
closing
{% endif %}
{% endif %}
open_cover:
- choose:
- conditions: >
{{ this.state == "closing" }}
sequence:
# first stop moving
- service: switch.turn_on
data:
entity_id: switch.garagentor_relay_0
- delay:
milliseconds: 500
- service: switch.turn_off
data:
entity_id: switch.garagentor_relay_0
# then start opening
- service: switch.turn_on
data:
entity_id: switch.garagentor_relay_0
- delay:
milliseconds: 500
- service: switch.turn_off
data:
entity_id: switch.garagentor_relay_0
- conditions: >
{{ this.state == "closed" }}
sequence:
# start opening
- service: switch.turn_on
data:
entity_id: switch.garagentor_relay_0
- delay:
milliseconds: 500
- service: switch.turn_off
data:
entity_id: switch.garagentor_relay_0
close_cover:
- choose:
- conditions: >
{{ this.state == "opening" }}
sequence:
# first stop moving
- service: switch.turn_on
data:
entity_id: switch.garagentor_relay_0
- delay:
milliseconds: 500
- service: switch.turn_off
data:
entity_id: switch.garagentor_relay_0
# then start opening
- service: switch.turn_on
data:
entity_id: switch.garagentor_relay_0
- delay:
milliseconds: 500
- service: switch.turn_off
data:
entity_id: switch.garagentor_relay_0
- conditions: >
{{ this.state == "open" }}
sequence:
# start opening
- service: switch.turn_on
data:
entity_id: switch.garagentor_relay_0
- delay:
milliseconds: 500
- service: switch.turn_off
data:
entity_id: switch.garagentor_relay_0
stop_cover:
- choose:
- conditions: >
{{ this.state == "closing" or this.state == "opening" }}
sequence:
# stop moving
- service: switch.turn_on
data:
entity_id: switch.garagentor_relay_0
- delay:
milliseconds: 500
- service: switch.turn_off
data:
entity_id: switch.garagentor_relay_0
icon_template: >
{% if states('binary_sensor.garagentor_input_1') == "on" %}
mdi:garage-variant
{% elif states('binary_sensor.garagentor_input_0') == "on" %}
mdi:garage-open-variant
{% else %}
mdi:garage-alert-variant
{% endif %}
123
(Taras)
February 10, 2023, 8:45pm
6
As an experiment, I created the following Template Cover. It simply controls an Input Boolean.
cover:
- platform: template
covers:
garage_door:
device_class: garage
friendly_name: Garage Door
value_template: "{{ is_state('input_boolean.foo', 'on') }}"
open_cover:
- service: input_boolean.turn_on
data:
entity_id: input_boolean.foo
- delay:
milliseconds: 50
- service: input_boolean.turn_off
data:
entity_id: input_boolean.foo
- delay:
milliseconds: 50
- service: input_boolean.turn_on
data:
entity_id: input_boolean.foo
close_cover:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.foo
stop_cover:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.foo
It uses two 50 millisecond delays in open_cover
and there were no errors produced when the cover was commanded to open.
The test was performed with Home Assistant 2023.2.3.
I cannot reproduce my error again. Maybe it got fixed with update to the .3-version but the changelog does not state a fix like the above.
Sorry for bothering? maybe I should have checked once more.
Thank you for the help anyway.
1 Like