I have an August Lock Gen3 and Connect I see on my dashboard it captures the value of “sensor.door_name.operator” with the last person or method that locked or unlocked the door.
Is there a way to set this to a variable and then use that variable in a TTS action?
I just getting started with HA, so any help is appreciated.
Well I can get it to work without the if part of the message. However, that means it says the same thing whenever the door is opened, which if it is opened manually, I want it to say something different.
id: “1620854877589”
alias: Welcome Back
description: “”
trigger:
Please have a read of point 11 here, then edit your message to format your pasted config correctly.
Your template format is not quite correct, this
{% if {{states.sensor.main_door_operator.state}} = Manual Lock %}
should be:
{% if states('sensor.main_door_operator) = 'Manual Lock' %}
Likewise for your elif template.
Note that you are only triggering on the “to unlock” state, so it will never execute the “Manual Lock” message. If you want to trigger on both the lock and unlock events you will need something like this:
trigger:
platform: state
entity_id: lock.main_door # triggers on all changes of state and attribute changes.
condition:
...etc
If you only want to trigger on the lock/unlock events and not attribute changes:
trigger:
platform: state
entity_id: lock.main_door
to:
- 'locked'
- 'unlocked'
condition:
...etc
Here is what I have now, which I think, corrects the template format issue.
action:
- wait_for_trigger:
- type: opened
platform: device
device_id: 6c652e113de5451aa323129d81b3b211
entity_id: binary_sensor.main_door_open
domain: binary_sensor
- data:
service: tts.google_translate_say
entity_id: media_player.formal_speaker
message: >
{% if states('sensor.main_door_operator) = 'Manual Unlock' %}
See you later
{% else %}
Welcome home states('sensor.main_door_operator)
{% endif %}
But when I reboot my automations, I get the following error…
Logger: homeassistant.config
Source: config.py:443
First occurred: 9:38:18 AM (1 occurrences)
Last logged: 9:38:18 AM
Invalid config for [automation]: invalid template (TemplateSyntaxError: expected token ‘,’, got ‘Manual’) for dictionary value @ data[‘action’][1][‘data’]. Got None. (See /config/configuration.yaml, line 140).
message: >
{% if states('sensor.main_door_operator) = 'Manual Unlock' %}
See you later
{% else %}
Welcome home {{ states('sensor.main_door_operator') }}
{% endif %}
This is why I hate coding. If I just have the else statment of “Welcome home {{states.sensor.main_door_operator.state}}” by itself it works. As soon as I add the If part it complains.
action:
- service: tts.google_translate_say
entity_id: media_player.formal_speaker
data:
message: >
{% if states('sensor.main_door_operator') = 'Manual lock' %}
Have a great day
{% elif states('sensor.main_door_operator') = 'Manual unlock' %}
Have a great day
{% else %}
Welcome home {{states.sensor.main_door_operator.state}}
{% endif %}
Error msg
Logger: homeassistant.config
Source: config.py:443
First occurred: 2:26:08 PM (7 occurrences)
Last logged: 2:44:44 PM
Invalid config for [automation]: invalid template (TemplateSyntaxError: expected token 'end of statement block', got '=') for dictionary value @ data['action'][0]['data']. Got None. (See /config/configuration.yaml, line 145).