Hi there,
I’m new to Home Assistant, coming from openHAB, but I am really impressed how smooth and easy some things are working. But there are also some problems I encountered; most of them I can solve by myself, but regarding the following, I actually have no clue, what to do.
(I think it’s similar to this posting: Rule broken)
I have a lock, which I want do get locked within the action part of a rule. But this should happen only, if it’s unlocked. So my rule looks like this:
## Tür abschließen
- service_template: >
{% if is_state('lock.hm_sec_key', 'unlocked') %}
lock.lock
{%- else -%}
# Do nothing
{% endif %}
entity_id: lock.hm_sec_key
The rules breaks at this point.
This on the other hand works:
## Tür abschließen
- service_template: >
{% if is_state('lock.hm_sec_key', 'unlocked') %}
lock.lock
{%- else -%}
lock.unlock
{% endif %}
entity_id: lock.hm_sec_key
So, I understand, that I seem to always have to put a service call inside the “else” block, right? But what if I don’t want anything to happen “else”? If I just delete the else-part like this, the rule also breaks:
## Tür abschließen
- service_template: >
{% if is_state('lock.hm_sec_key', 'unlocked') %}
lock.lock
{% endif %}
entity_id: lock.hm_sec_key
How can I achieve to lock the door in my rule, when it is unlocked without doing anything else?
Thank you very much for your ideas, help or insights!
Cheers
Norman