Hello, I need help with a payload that I want to send to a heating thermostat. Its not important, but I want to understand how it works. So far, I have this code.
show_name: true
show_icon: true
type: button
name: Heizung +1
icon: mdi:thermometer
tap_action:
action: call-service
service: mqtt.publish
data:
evaluate_payload: false
qos: 0
retain: false
topic: zigbee2mqtt/Wohnzimmer - Heizung Fenster/set
payload: >
{{ "{\"occupied_heating_setpoint\": " ~
(state_attr('climate.wohnzimmer_heizung_fenster', 'temperature') | float +
1) | int ~ "}" }}
However, when I press the button, I get the following error message: āz2m: Invalid message āundefinedā, skippingā¦ā What am I doing wrong?
Maybe someone can help in the future
123
(Taras)
February 26, 2025, 6:46pm
3
You canāt use templates in a Button Card .
Move the entire mqtt.publish
action into a script.
alias: Increment Setpoint
sequence:
- variables:
msg:
occupied_heating_setpoint: >
{{ (state_attr('climate.wohnzimmer_heizung_fenster', 'temperature') + 1) | int(0) }}
- service: mqtt.publish
data:
topic: zigbee2mqtt/Wohnzimmer - Heizung Fenster/set
payload: "{{ msg | tojson }}"
Then make the Button Card call the script.
show_name: true
show_icon: true
type: button
name: Heizung +1
icon: mdi:thermometer
tap_action:
action: call-service
service: script.increment_setpoint
1 Like
Wow, thanks for that I donāt know about that. Would it work with another card that supports templating in the same way I wrote the payload?
123
(Taras)
February 26, 2025, 7:01pm
5
None of the standard set of cards supports templates except for the Markdown Card.
Various custom cards support templates.
1 Like