diff --git a/homeassistant/components/mqtt/vacuum.py b/homeassistant/components/mqtt/vacuum.py index ae4b3322b8e2..5895d52e9dce 100644 --- a/homeassistant/components/mqtt/vacuum.py +++ b/homeassistant/components/mqtt/vacuum.py @@ -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: diff --git a/tests/components/mqtt/test_vacuum.py b/tests/components/mqtt/test_vacuum.py index 4140177a929d..78ca45a792fc 100644 --- a/tests/components/mqtt/test_vacuum.py +++ b/tests/components/mqtt/test_vacuum.py @@ -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."""