I have this automation which sends info from my Heat it! termostates over MQTT to the sentral server. I updated Hass, and now it doesn’t work.
- alias: Gulvtemperatur med modus
action:
data_template:
payload_template: "{{states('climate.termostat_'+trigger.payload+'_mode')}},{{state_attr('climate.termostat_'+trigger.payload+'_mode', 'node_id')}},{{state_attr('climate.termostat_'+trigger.payload+'_mode', 'current_temperature')}},{{trigger.payload}},{{state_attr('climate.termostat_'+trigger.payload+'_mode', 'temperature')}}"
topic: eg/Gulvtemperatur
service: mqtt.publish
condition: []
id: '110343257'
trigger:
- platform: state
entity_id:
- sensor.termostat1_temperature
- sensor.termostat2_temperature
- sensor.termostat3_temperature
- sensor.termostat4_temperature
- sensor.termostat5_temperature
- sensor.termostat6_temperature
- sensor.termostat7_temperature
- sensor.termostat8_temperature
- sensor.termostat9_temperature
- sensor.termostat10_temperature
- sensor.termostat11_temperature
- sensor.termostat12_temperature
- sensor.termostat13_temperature
- sensor.termostat14_temperature
When I use the number itself, it works. Like this:
{{states('climate.termostat_8_mode')}},{{state_attr('climate.termostat_8_mode', 'node_id')}},{{state_attr('climate.termostat_8_mode', 'current_temperature')}},{{8}},{{state_attr('climate.termostat_8_mode', 'temperature')}}
But I’d like having one that works on all termostats instead of one automation per termostate. I spent quite a lot of time (and got a lot of help…) to originally get this working. What should I look for to get the correct number out of this? It seems like Hass doesn’t read payload as it did before. Here’s the error message. I find it weird that it doesn’t seem to point to the correct line in the automations.yaml anywhere, but it has to be the payload.
Logger: homeassistant.components.automation.gulvtemperatur_med_modus_2
Source: helpers/service.py:190
Integration: Automasjon (documentation, issues)
First occurred: 4:01:48 (140 occurrences)
Last logged: 8:57:37Gulvtemperatur med modus: Error executing script. Unexpected error for call_service at pos 1: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘payload’
While executing automation automation.gulvtemperatur_med_modus_2
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/template.py”, line 353, in async_render
render_result = compiled.render(kwargs)
File “/srv/homeassistant/lib/python3.7/site-packages/jinja2/environment.py”, line 1090, in render
self.environment.handle_exception()
File “/srv/homeassistant/lib/python3.7/site-packages/jinja2/environment.py”, line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File “/srv/homeassistant/lib/python3.7/site-packages/jinja2/_compat.py”, line 28, in reraise
raise value.with_traceback(tb)
File “”, line 1, in top-level template code
jinja2.exceptions.UndefinedError: ‘dict object’ has no attribute ‘payload’The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/service.py”, line 188, in async_prepare_call_from_config
service_data.update(template.render_complex(config[conf], variables))
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/template.py”, line 95, in render_complex
for key, item in value.items()
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/template.py”, line 95, in
for key, item in value.items()
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/template.py”, line 98, in render_complex
return value.async_render(variables)
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/template.py”, line 355, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: ‘dict object’ has no attribute ‘payload’The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/script.py”, line 251, in _async_step
self, f"async{cv.determine_script_action(self._action)}_step"
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/script.py”, line 430, in _async_call_service_step
self._hass, self._action, self._variables
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/service.py”, line 190, in async_prepare_call_from_config
raise HomeAssistantError(f"Error rendering data template: {ex}") from ex
homeassistant.exceptions.HomeAssistantError: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘payload’
This is what I got from listening to the state changes:
{
“event_type”: “state_changed”,
“data”: {
“entity_id”: “sensor.termostat8_temperature”,
“old_state”: {
“entity_id”: “sensor.termostat8_temperature”,
“state”: “26.5”,
“attributes”: {
“node_id”: 3,
“value_index”: 1,
“value_instance”: 1,
“value_id”: “72057594093256722”,
“unit_of_measurement”: “°C”,
“friendly_name”: “Termostat 8 temperatur”
},
“last_changed”: “2020-12-27T09:29:01.227079+00:00”,
“last_updated”: “2020-12-27T09:29:01.227079+00:00”,
“context”: {
“id”: “7b7d826b77a7425cd05b7fc711f1168d”,
“parent_id”: null,
“user_id”: null
}
},
“new_state”: {
“entity_id”: “sensor.termostat8_temperature”,
“state”: “26.5”,
“attributes”: {
“node_id”: 3,
“value_index”: 1,
“value_instance”: 1,
“value_id”: “72057594093256722”,
“unit_of_measurement”: “°C”,
“friendly_name”: “Termostat 8 temperatur”
},
“last_changed”: “2020-12-27T09:33:22.296272+00:00”,
“last_updated”: “2020-12-27T09:33:22.296272+00:00”,
“context”: {
“id”: “7f6bbacec12ebcf3a0d5623701ee4927”,
“parent_id”: null,
“user_id”: null
}
}
},
“origin”: “LOCAL”,
“time_fired”: “2020-12-27T09:33:22.296272+00:00”,
“context”: {
“id”: “7f6bbacec12ebcf3a0d5623701ee4927”,
“parent_id”: null,
“user_id”: null
}