Fix clearing error message for MQTT vacuum (#23206)

* Fix clearing error message

* Remove redundant hass.async_block_till_done
This commit is contained in:
Erik Montnemery 2019-04-19 06:01:19 +02:00 committed by Paulus Schoutsen
parent eac2388d49
commit bea7e2a7fa
2 changed files with 9 additions and 2 deletions

View File

@ -313,7 +313,7 @@ class MqttVacuum(MqttAttributes, MqttAvailability, MqttDiscoveryUpdate,
error = self._templates[CONF_ERROR_TEMPLATE]\
.async_render_with_possible_json_value(
msg.payload, error_value=None)
if error:
if error is not None:
self._error = cv.string(error)
if self._docked:

View File

@ -298,10 +298,17 @@ async def test_status_error(hass, mock_publish):
}"""
async_fire_mqtt_message(hass, 'vacuum/state', message)
await hass.async_block_till_done()
await hass.async_block_till_done()
state = hass.states.get('vacuum.mqtttest')
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):
"""Test that you can use non-default templates for battery_level."""