Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions homeassistant/components/mqtt/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
ATTR_HVAC_MODE,
ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW,
CURRENT_HVAC_ACTIONS,
DEFAULT_MAX_TEMP,
DEFAULT_MIN_TEMP,
FAN_AUTO,
Expand Down Expand Up @@ -529,21 +528,23 @@ def render_template(msg, template_name):
def handle_action_received(msg):
"""Handle receiving action via MQTT."""
payload = render_template(msg, CONF_ACTION_TEMPLATE)
if payload in CURRENT_HVAC_ACTIONS:
self._action = payload
self.async_write_ha_state()
elif not payload or payload == PAYLOAD_NONE:
if not payload or payload == PAYLOAD_NONE:
_LOGGER.debug(
"Invalid %s action: %s, ignoring",
CURRENT_HVAC_ACTIONS,
[e.value for e in HVACAction],
payload,
)
else:
return
try:
self._action = HVACAction(payload)
except ValueError:
_LOGGER.warning(
"Invalid %s action: %s",
CURRENT_HVAC_ACTIONS,
[e.value for e in HVACAction],
payload,
)
return
self.async_write_ha_state()

add_subscription(topics, CONF_ACTION_TOPIC, handle_action_received)

Expand Down