Hi,
I’m trying to get a “climate” card working with mqtt, but I’m failing with the templates for the state and command modes.
This is what I have so far
climate:
name: "climate test"
max_temp: 25
min_temp: 15
precision: 0.1
temp_step: 0.5
modes:
- auto
- heat
- cool
- 'off'
mode_state_template: >-
{% set values = { 'auto':'auto', 'day':'heat', 'night':'cool', 'off':'off'} %}
{{ values[value] if value in values.keys() else 'off' }}
mode_state_topic: "ebusd/700/z1OPMode"
value_template: "{{ value_json.opmode.value }}"
mode_command_template: >-
{% set values = { 'auto':'auto', 'day':'heat', 'night':'cool', 'off':'off'} %}
{{ values[value] if value in values.keys() else 'auto' }}
mode_command_topic: "ebusd/700/z1OpMode/set"
temperature_state_topic: "ebusd/700/z1ActualRoomTempDesired"
value_template: "{{ value_json.tempv.value }}"
temperature_low_state_topic: "ebusd/700/z1NightTemp"
value_template: "{{ value_json.tempv.value }}"
temperature_high_state_topic: "ebusd/700/z1DayTemp"
value_template: "{{ value_json.tempv.value }}"
temperature_low_command_topic: "ebusd/700/z1NightTemp/set"
temperature_high_command_topic: "ebusd/700/z1DayTemp/set"
current_temperature_topic: "ebusd/700/z1ActualRoomTempDesired"
value_template: "{{ value_json.tempv.value }}"
and the json looks like this
{
"opmode": {
"value": "day"
}
the modes are : auto, day, night and off
Its correctly showing the temperature, so the template with " value_json.tempv.value" is apparently correct for the json of the temperature topic which looks like this
{
"tempv": {
"value": 20.5
}
}
Its also sending the command correctly, but its just always sending “auto” because of the if statement, but it doesn’t default to “off” with the state template - which i find weird.
I tried to debug this in the Template simulator in the editor tools, but I seem to fail to grasp how this works, since I cannot copy/paste my yaml files there.
If been googling, searching and trying for hours…
Any help or guidance would be appreciated.
System Info:
Docker Home Assistant 2023.3.1 Frontend 20230302.0 - latest
Mosquitto
Ebusd