Hi,
i tried to forward my sensor data to an MQTT topic using data templates so that the entity ID is contained in the transmitted JSON as MQTT payload.
My current automation looks like this:
- id: '1558647997872'
alias: Sensor to MQTT
trigger:
- entity_id: sensor.temp_bath
platform: state
condition: []
action:
- service: mqtt.publish
data_template:
payload: '{ "entity": "{{trigger.entity_id}}", "value": {{trigger.to_state.state}}}'
topic: homeassistant/incomming
It seems that the trigger variable is not available when rendering the template as i receive the following error:
ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: 'trigger' is undefined
Is there anything i did no notice when using data_templates? Mit HA version is 0.93.2