Need help with value_template for MQTT HVAC

Woow great thanks for you help!

Any thoughts for the mode_state_template?

I got this:

mode_state_topic: "zigbee2mqtt/bathroom/switch/0003/thermostat"
mode_state_template: '{{ value_json.eurotronic_system_mode }}'  

And 1 is like normal operation, 2 is boost and 3 is child protection

From the documentation for MQTT HVAC, the default modes are:

modes:
  - auto
  - 'off'
  - cool
  - heat
  - dry
  - fan_only

These are the modes Home Assistant understands (and they’re used for Lovelace’s climate card).

Your value_template has to convert the modes reported by your Eurotronic thermostat into modes understood by Home Assistant.

For example, my thermostat reports its modes using a number. Here is each number mapped to one of Home Assistant’s modes.

0 = auto
1 = heat
2 = cool
4 = off

My thermostat’s configuration is like this:

   modes:
     - auto
     - heat
     - cool
     - 'off'
   mode_state_topic: "premise/thermostat/temperaturemode" 
   mode_state_template: >-
     {% set values = { '0':'auto', '1':'heat',  '2':'cool', '4':'off'} %}
     {{ values[value] if value in values.keys() else 'off' }}
   mode_command_topic: "premise/command/thermostat/temperaturemode"
   mode_command_template: >-
     {% set values = { 'auto':'0', 'heat':'1',  'cool':'2', 'off':'4'} %}
     {{ values[value] if value in values.keys() else '4' }}

You said your thermostat also reports its modes as numbers. However, the problem I see is that the modes you mentioned (normal operation, boost, child protection) don’t have direct equivalents in Home Assistant. Perhaps ‘normal’ can be handled as ‘auto’?

Thank you for your reply. Then I will use the Home-Assistant names for it.

How to handle it with mode_state_template: ‘{{ value_json.eurotronic_system_mode }}’

Like you made it like this:

mode_state_template: >-
{% set values = { ‘0’:‘auto’, ‘1’:‘heat’, ‘2’:‘cool’, ‘4’:‘off’} %}
{{ values[value] if value in values.keys() else ‘off’ }}

To help you design the template, I will need more information about the thermostat you are using. Is there documentation available for this thermostat describing its operating modes? Do you have examples of its JSON payloads?

Over MQTT the following message structure is visible over the broker:

zigbee2mqtt/bathroom/switch/0003/thermostat {"occupied_heating_setpoint":21,"unoccupied_heating_setpoint":16,"eurotronic_system_mode":1,"current_heating_setpoint":18.5,"pi_heating_demand":192,"local_temperature":17.7,"eurotronic_error_status":0,"battery":35,"linkquality":60}

System modes, Today I will do some testing which system mode I will receive when I turn on the protection mode by using the keys on the thermostat itself :

1 = (default 1)
2 = Boost
4 = Window open
7 = Child protection

Documentation, if you can read German :slight_smile: :

Only the first one has an equivalent MQTT HVAC mode which is heat. There are no equivalent modes for the other ones.

Hi
I’ve just updated from 0.89 to 0.93 and the custom component is not working anymore: Integration my_mqtt not found when trying to verify its climate platform.
it is located in /home/homeassistant/.homeassistant/custom_components/my_mqtt and there is one file climate.py as in this post Need help with value_template for MQTT HVAC
and the core.entity_registry is edited with my_mqtt instead of mqtt
is there something I’m missing?

Yes, since version 0.92. custom components require a manifest file which I have not yet created because I’m still using 0.89 on my production server and 0.91 on my test server.

I won’t be upgrading until 0.94 or 0.95 so I won’t be creating and sharing a manifest file for several more weeks. Until then, you can create your own by following the instructions here:

just did it, it works, thanks for the quick answer!

Hi ,
i try to use your custom climate but i want that i have a power button to turn off my A/C like your post image …

- platform: my_mqtt
  name: Tohar A/C
  modes:
     - cool
     - heat
     - off
  fan_modes:
     - auto
     - high
     - medium
    - low
  power_command_topic: "hvac/tohar/power/set"
  mode_command_topic: "hvac/tohar/mode/set"
  temperature_command_topic: "hvac/tohar/temperature/set"
  fan_mode_command_topic: "hvac/tohar/fan/set"
  current_temperature_topic: "hvac/tohar/state/temperature"
  payload_on: "on"
  payload_off: "off"
  retain: true
  initial: 22
  min_temp: 18
  max_temp: 30
  temp_step: 2

thanks…

Do you mean this image?

The top right is the standard Lovelace Thermostat card and the top left is a custom Lovelace card called Simple Thermostat. They work with any climate component and not just my custom climate component.

yes… iwant the power button also

Change this:

  modes:
     - cool
     - heat
     - off
  fan_modes:
     - auto
     - high
     - medium
    - low

to this:

  modes:
     - cool
     - heat
     - 'off'
  fan_modes:
     - auto
     - high
     - medium
     - low

Is there a way to change the else value to a variable instead of a constant?
I’ve tried this but can’t find the correct syntax
{% set values = { ‘0’:‘auto’, ‘1’:‘heat’, ‘2’:‘cool’, ‘4’:‘off’} %}
{{ values[value] if value in values.keys() else {{ states(“sensor.water_kitchen”) }} }}

This works but the 1 line is so much more concise
{% if value in values.key %}
{{ values.item }}
{% else %}
{{ states(“sensor.water_kitchen”) }}
{% endif %}

{{ values[value] if value in values.keys() else states('sensor.water_kitchen') }}

thank you so much, i could have sworn I tried that, lol

@123 did you eventually update your component? (No pressure, just asking! :slightly_smiling_face:)

Yes, it’s posted in a separate thread:

Be advised that it will work with Home Assistant version 0.93 to 0.95 but not 0.96.

great thanks!

@Imperial-Guard if your configuration is now done, can you share it? I have also the Eurotronic spirit thermostat with zigbee2mqtt.

1 Like