I have a few Wemos units with displays and I would like to configure the “Generic - MQTT Import” sensor to receive a broadcast of sorts that contains the real temperature and feels like temperature to the units to display. I have the units set up to receive traffic and that part works fine.
I am having trouble with the following automation:
- id: "Broadcast Real Temp MQTT"
alias: 'Broadcast Real Temp MQTT'
trigger:
- platform: time
minutes: '/1'
seconds: '0'
action:
service: mqtt.publish
data_template:
payload_template: '{{ sensor.pws_temp_f.payload }}'
topic: 'Real'
My goal is to transmit the temperature to the topic “Real”, every X number of minutes.
I am getting the following errors every interval:
018-02-07 22:30:00 ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: 'sensor' is undefined
2018-02-07 22:30:00 ERROR (MainThread) [homeassistant.core] Invalid service data for mqtt.publish: required key not provided @ data['topic']. Got None
The sensor in the States panel is:
sensor.pws_temp_f
with a numeric value containing a decimal.
I know I have something screwed up in the template or maybe I need to template the topic some how…
It is probably more lines than are really needed, but could not add the second service line to the first automation without a duplicate error. These are in an automation file, so you would need to format it for use in the configuration.yaml
This works well though
- id: "Broadcast Real Temp MQTT"
alias: 'Broadcast Real Temp MQTT'
trigger:
- platform: time
minutes: '/3'
seconds: '0'
action:
service: mqtt.publish
data_template:
payload_template: '{{ states.sensor.pws_temp_f.state }}'
topic: 'Real'
- id: "Broadcast Feels Like Temp MQTT"
alias: 'Broadcast Feels Like Temp MQTT'
trigger:
- platform: time
minutes: '/3'
seconds: '0'
action:
service: mqtt.publish
data_template:
payload_template: '{{ states.sensor.pws_feelslike_f.state }}'
topic: 'FeelsLike'
I am using Wemos D1’s to receive the “broadcast”. The Wemos units are running ESPEasy and I have defined a device as MQTT Sniffer and it detects the MQTT topic and pulls out the payload and then displays it on the little Wemos display.
Hope this helps, it is a very handy addition to a Wemos stack!