I’m not sure if what I’m trying to do is possible or if I just have the syntax wrong. I have a floorplan dashboard with icons and badges for my various sensors around the house. I would like to have my front door lock or unlock, based on current state, after a long press on the icon. I’m assuming the way I need to accomplish this is through the use of templating but I can’t seem to get it quite right and I’m not sure where errors might be logged.
- type: state-icon
entity: lock.front_door_lock
tap_action: []
hold_action:
- action: template
value_template: |
{% if is_state('lock.front_door_lock', 'locked') %}
service: lock.unlock
data: {}
target:
entity_id: lock.front_door_lock
{% else %}
service: lock.lock
data: {}
target:
entity_id: lock.front_door_lock
{% endif %}
Can someone help me identify where I’ve gone wrong?