Fix MQTT climate action null warnings (#64658)
This commit is contained in:
parent
8d9bb73d22
commit
63048a67e0
2 changed files with 17 additions and 0 deletions
|
@ -125,6 +125,8 @@ CONF_TEMP_MAX = "max_temp"
|
|||
CONF_TEMP_MIN = "min_temp"
|
||||
CONF_TEMP_STEP = "temp_step"
|
||||
|
||||
PAYLOAD_NONE = "None"
|
||||
|
||||
MQTT_CLIMATE_ATTRIBUTES_BLOCKED = frozenset(
|
||||
{
|
||||
climate.ATTR_AUX_HEAT,
|
||||
|
@ -441,6 +443,12 @@ class MqttClimate(MqttEntity, ClimateEntity):
|
|||
if payload in CURRENT_HVAC_ACTIONS:
|
||||
self._action = payload
|
||||
self.async_write_ha_state()
|
||||
elif not payload or payload == PAYLOAD_NONE:
|
||||
_LOGGER.debug(
|
||||
"Invalid %s action: %s, ignoring",
|
||||
CURRENT_HVAC_ACTIONS,
|
||||
payload,
|
||||
)
|
||||
else:
|
||||
_LOGGER.warning(
|
||||
"Invalid %s action: %s",
|
||||
|
|
|
@ -900,6 +900,15 @@ async def test_get_with_templates(hass, mqtt_mock, caplog):
|
|||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("hvac_action") == "cooling"
|
||||
|
||||
# Test ignoring null values
|
||||
async_fire_mqtt_message(hass, "action", "null")
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("hvac_action") == "cooling"
|
||||
assert (
|
||||
"Invalid ['off', 'heating', 'cooling', 'drying', 'idle', 'fan'] action: None, ignoring"
|
||||
in caplog.text
|
||||
)
|
||||
|
||||
|
||||
async def test_set_with_templates(hass, mqtt_mock, caplog):
|
||||
"""Test setting various attributes with templates."""
|
||||
|
|
Loading…
Add table
Reference in a new issue