I have created a new version based on the MQTT climate.py code from Home Assistant 0.88.1.
I tested it briefly (on my test system running 0.88.1, because my production system continues to run version 0.80) and it seems to work correctly. It did not produce any errors in the system log.
Here is how it looks in Lovelace using three different thermostat cards. All three work correctly. You’ll notice it indicates the current operating mode is Heat
and the current activity is Idle
(the HVAC system is not actively heating at the moment).
Here is how it looks after running for few minutes. Notice it now indicates the current activity is Heat
. The Heating Hours Today
sensor now shows a few minutes of activity (0.03 h). The History Chart (not shown here) also correctly shows when the HVAC system is actively heating (couldn’t test cooling but it should work).
This revised version is slightly different from the previous one.
-
status_state_topic
and status_state_template
are now called activity_state_topic
and activity_state_template
.
- It does not automatically adjust the temperature step-size based on the chosen unit system. If you want a step-size of 0.5 degrees you must specify it in the configuration:
temp_step: 0.5
Here is the updated version on pastebin.
For Home Assistant version 0.88.X you must copy this custom component into the following directory:
<config>/custom_component/mqtt/climate.py
That’s different from previous versions where it would go into <config>/custom_component/climate/mqtt.py
Here is a sample configuration. Notice it uses activity_state_topic
, activity_state_template
, and temp_step
.
climate:
- platform: mqtt
name: "Thermostat"
unique_id: '1234567890'
payload_on: 1
payload_off: 0
activity_state_topic: "premise/thermostat/heatingstatus"
activity_state_template: >-
{% set values = { '1':'heat', '2':'cool', '4':'idle'} %}
{{ values[value] if value in values.keys() else 'idle' }}
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' }}
fan_modes:
- auto
- 'on'
fan_mode_state_topic: "premise/thermostat/fancontrol"
fan_mode_state_template: >-
{% set values = { '0':'auto', '1':'on'} %}
{{ values[value] if value in values.keys() else 'auto' }}
fan_mode_command_topic: "premise/command/thermostat/fancontrol"
fan_mode_command_template: >-
{% set values = { 'auto':'0', 'on':'1'} %}
{{ values[value] if value in values.keys() else '0' }}
current_temperature_topic: "premise/thermostat/temperature"
min_temp: 17
max_temp: 28
temp_step: 0.5
temperature_state_topic: "premise/thermostat/currentsetpoint"
temperature_command_topic: "premise/command/thermostat/currentsetpoint"
hold_state_topic: "premise/thermostat/mode"
hold_state_template: "{{ 'hold' if value == '2' else 'auto' }}"
hold_command_topic: "premise/command/thermostat/mode"
hold_command_template: "{{ '2' if value == 'hold' else '0' }}"