mirror of
https://github.com/home-assistant/core
synced 2024-07-27 18:58:57 +02:00
Fix clearing error message for MQTT vacuum (#23206)
* Fix clearing error message * Remove redundant hass.async_block_till_done
This commit is contained in:
parent
eac2388d49
commit
bea7e2a7fa
@ -313,7 +313,7 @@ class MqttVacuum(MqttAttributes, MqttAvailability, MqttDiscoveryUpdate,
|
|||||||
error = self._templates[CONF_ERROR_TEMPLATE]\
|
error = self._templates[CONF_ERROR_TEMPLATE]\
|
||||||
.async_render_with_possible_json_value(
|
.async_render_with_possible_json_value(
|
||||||
msg.payload, error_value=None)
|
msg.payload, error_value=None)
|
||||||
if error:
|
if error is not None:
|
||||||
self._error = cv.string(error)
|
self._error = cv.string(error)
|
||||||
|
|
||||||
if self._docked:
|
if self._docked:
|
||||||
|
@ -298,10 +298,17 @@ async def test_status_error(hass, mock_publish):
|
|||||||
}"""
|
}"""
|
||||||
async_fire_mqtt_message(hass, 'vacuum/state', message)
|
async_fire_mqtt_message(hass, 'vacuum/state', message)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await hass.async_block_till_done()
|
|
||||||
state = hass.states.get('vacuum.mqtttest')
|
state = hass.states.get('vacuum.mqtttest')
|
||||||
assert 'Error: Error1' == state.attributes.get(ATTR_STATUS)
|
assert 'Error: Error1' == state.attributes.get(ATTR_STATUS)
|
||||||
|
|
||||||
|
message = """{
|
||||||
|
"error": ""
|
||||||
|
}"""
|
||||||
|
async_fire_mqtt_message(hass, 'vacuum/state', message)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
state = hass.states.get('vacuum.mqtttest')
|
||||||
|
assert 'Stopped' == state.attributes.get(ATTR_STATUS)
|
||||||
|
|
||||||
|
|
||||||
async def test_battery_template(hass, mock_publish):
|
async def test_battery_template(hass, mock_publish):
|
||||||
"""Test that you can use non-default templates for battery_level."""
|
"""Test that you can use non-default templates for battery_level."""
|
||||||
|
Loading…
Reference in New Issue
Block a user