Can you set the action topic with a sensor state? Like the below “topic: {{states.sensor.missedannouncement.states}}”? I have tried many different ways and my config gives me an error. I am attempting to save tts notifications when we are not home.
- alias: "JDTest"
initial_state: True
trigger:
platform: state
entity_id: switch.JDTest
to: 'on'
action:
- service: mqtt.publish
data:
topic: {{states.sensor.missedannouncement.states}}
payload: 'This is a TEST'
and my sensor
- platform: template
sensors:
missedannouncement:
friendly_name: "MissedAnnouncement"
value_template: >
{% if is_state("sensor.missedannouncement1", "NULL") -%}
home/missed/announcement1
{% elif is_state("sensor.missedannouncement2", "NULL") %}
home/missed/announcement2
{% elif is_state("sensor.missedannouncement3", "NULL") %}
home/missed/announcement3
{% endif %}
my error
Error loading /config/configuration.yaml: invalid key: "OrderedDict([('states.sensor.missedannouncement.states', None)])"
in "/config/automations/automation.yaml", line 255, column 0