MQTT HVAC
The mqtt
climate platform lets you control your MQTT enabled HVAC devices.
The platform currently works in optimistic mode, which means it does not obtain states from MQTT topics, but it sends and remembers control commands.
It uses a sensor under the hood to obtain the current temperature.
# Example configuration.yaml entry
climate:
- platform: mqtt
name: Study
current_temperature_topic: /sensors/hvac_study/current_temp
temperature_command_topic: /sensors/hvac_study/target_temp
Configuration Variables
- name
-
(string)(Optional)The name of the HVAC.
Default value: MQTT HVAC
- qos
-
(integer)(Optional)The maximum QoS level to be used when receiving and publishing messages.
Default value: 0
- retain
-
(boolean)(Optional)Defines if published messages should have the retain flag set.
Default value: false
- send_if_off
-
(boolean)(Optional)Set to
false
to suppress sending of all MQTT messages when the current mode isOff
.Default value: true
- initial
-
(number)(Optional)Set the initial target temperature.
Default value: 21
- payload_on
-
(string)(Optional)The payload that represents enabled state.
Default value: true
- payload_off
-
(string)(Optional)The payload that represents disabled state.
Default value: false
- availability_topic
-
(string)(Optional)The MQTT topic subscribed to receive availability (online/offline) updates.
- payload_available
-
(string)(Optional)The payload that represents the available state.
Default value: online
- payload_not_available
-
(string)(Optional)The payload that represents the unavailable state.
Default value: offline
- value_template
-
(template)(Optional)Default template to render the payloads on all
*_state_topic
s with. - current_temperature_topic
-
(string)(Optional)The MQTT topic on which to listen for the current temperature.
- power_command_topic
-
(string)(Optional)The MQTT topic to publish commands to change the power state. This is useful if your device has a separate power toggle in addition to mode.
- mode_command_topic
-
(string)(Optional)The MQTT topic to publish commands to change the HVAC operation mode.
- mode_state_topic
-
(string)(Optional)The MQTT topic to subscribe for changes of the HVAC operation mode. If this is not set, the operation mode works in optimistic mode (see below).
- mode_state_template
-
(template)(Optional)A template to render the value received on the
mode_state_topic
with. - temperature_command_topic
-
(string)(Optional)The MQTT topic to publish commands to change the target temperature.
- temperature_state_topic
-
(string)(Optional)The MQTT topic to subscribe for changes in the target temperature. If this is not set, the target temperature works in optimistic mode (see below).
- temperature_state_template
-
(template)(Optional)A template to render the value received on the
temperature_state_topic
with. - fan_mode_command_topic
-
(string)(Optional)The MQTT topic to publish commands to change the fan mode.
- fan_mode_state_topic
-
(string)(Optional)The MQTT topic to subscribe for changes of the HVAC fan mode. If this is not set, the fan mode works in optimistic mode (see below).
- fan_mode_state_template
-
(template)(Optional)A template to render the value received on the
fan_mode_state_topic
with. - swing_mode_command_topic
-
(string)(Optional)The MQTT topic to publish commands to change the swing mode.
- swing_mode_state_topic
-
(string)(Optional)The MQTT topic to subscribe for changes of the HVAC swing mode. If this is not set, the swing mode works in optimistic mode (see below).
- swing_mode_state_template
-
(template)(Optional)A template to render the value received on the
swing_mode_state_topic
with. - away_mode_command_topic
-
(string)(Optional)The MQTT topic to publish commands to change the away mode.
- away_mode_state_topic
-
(string)(Optional)The MQTT topic to subscribe for changes of the HVAC away mode. If this is not set, the away mode works in optimistic mode (see below).
- away_mode_state_template
-
(template)(Optional)A template to render the value received on the
away_mode_state_topic
with. - hold_command_topic
-
(string)(Optional)The MQTT topic to publish commands to change the hold mode.
- hold_state_topic
-
(string)(Optional)The MQTT topic to subscribe for changes of the HVAC hold mode. If this is not set, the hold mode works in optimistic mode (see below).
- hold_state_template
-
(template)(Optional)A template to render the value received on the
hold_state_topic
with. - aux_command_topic
-
(string)(Optional)The MQTT topic to publish commands to switch auxiliary heat.
- aux_state_topic
-
(string)(Optional)The MQTT topic to subscribe for changes of the auxiliary heat mode. If this is not set, the auxiliary heat mode works in optimistic mode (see below).
- aux_state_template
-
(template)(Optional)A template to render the value received on the
aux_state_topic
with.
Optimistic mode
If a property works in optimistic mode (when the corresponding state topic is not set), home assistant will assume that any state changes published to the command topics did work and change the internal state of the entity immediately after publishing to the command topic. If it does not work in optimistic mode, the internal state of the entity is only updated when the requested update is confirmed by the device through the state topic.
Using Templates
For all *_state_topic
s, a template can be specified that will be used to render the incoming payloads on these topics. Also, a default template that applies to all state topis can be specified as value_template
. This can be useful if you received payloads are e.g. in JSON format. Since in JSON, a quoted string (e.g. "foo"
) is just a string, this can also be used for unquoting.
Say you receive the operation mode "auto"
via your mode_state_topic
, but the mode is actually called just auto
, here’s what you could do:
climate:
- platform: mqtt
name: Study
modes:
- off
- on
- auto
mode_command_topic: "study/ac/mode/set"
mode_state_topic: "study/ac/mode/state"
mode_state_template: "{{ value_json }}"
This will parse the incoming "auto"
as JSON, resulting in auto
. Obviously, in this case you could also just set value_template: "{{ value_json }}"
.
Example
A full configuration example looks like the one below.
# Full example configuration.yaml entry
climate:
- platform: mqtt
name: Study
modes:
- off
- cool
- fan_only
swing_modes:
- on
- off
fan_modes:
- high
- medium
- low
power_command_topic: "study/ac/power/set"
mode_command_topic: "study/ac/mode/set"
temperature_command_topic: "study/ac/temperature/set"
fan_mode_command_topic: "study/ac/fan/set"
swing_mode_command_topic: "study/ac/swing/set"