async def test_status(hass, mqtt_mock):
    'Test status updates from the vacuum.'
    config = deepcopy(DEFAULT_CONFIG)
    config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(mqttvacuum.ALL_SERVICES, SERVICE_TO_STRING)
    assert (await async_setup_component(hass, vacuum.DOMAIN, {vacuum.DOMAIN: config}))
    message = '{\n        "battery_level": 54,\n        "state": "cleaning",\n        "fan_speed": "max"\n    }'
    async_fire_mqtt_message(hass, 'vacuum/state', message)
    state = hass.states.get('vacuum.mqtttest')
    assert (state.state == STATE_CLEANING)
    assert (state.attributes.get(ATTR_BATTERY_LEVEL) == 54)
    assert (state.attributes.get(ATTR_BATTERY_ICON) == 'mdi:battery-50')
    assert (state.attributes.get(ATTR_FAN_SPEED) == 'max')
    message = '{\n        "battery_level": 61,\n        "state": "docked",\n        "fan_speed": "min"\n    }'
    async_fire_mqtt_message(hass, 'vacuum/state', message)
    state = hass.states.get('vacuum.mqtttest')
    assert (state.state == STATE_DOCKED)
    assert (state.attributes.get(ATTR_BATTERY_ICON) == 'mdi:battery-charging-60')
    assert (state.attributes.get(ATTR_BATTERY_LEVEL) == 61)
    assert (state.attributes.get(ATTR_FAN_SPEED) == 'min')
    assert (state.attributes.get(ATTR_FAN_SPEED_LIST) == ['min', 'medium', 'high', 'max'])
Test status updates from the vacuum.
async def test_status(hass, mqtt_mock):
    
    config = deepcopy(DEFAULT_CONFIG)
    config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(mqttvacuum.ALL_SERVICES, SERVICE_TO_STRING)
    assert (await async_setup_component(hass, vacuum.DOMAIN, {vacuum.DOMAIN: config}))
    message = '{\n        "battery_level": 54,\n        "state": "cleaning",\n        "fan_speed": "max"\n    }'
    async_fire_mqtt_message(hass, 'vacuum/state', message)
    state = hass.states.get('vacuum.mqtttest')
    assert (state.state == STATE_CLEANING)
    assert (state.attributes.get(ATTR_BATTERY_LEVEL) == 54)
    assert (state.attributes.get(ATTR_BATTERY_ICON) == 'mdi:battery-50')
    assert (state.attributes.get(ATTR_FAN_SPEED) == 'max')
    message = '{\n        "battery_level": 61,\n        "state": "docked",\n        "fan_speed": "min"\n    }'
    async_fire_mqtt_message(hass, 'vacuum/state', message)
    state = hass.states.get('vacuum.mqtttest')
    assert (state.state == STATE_DOCKED)
    assert (state.attributes.get(ATTR_BATTERY_ICON) == 'mdi:battery-charging-60')
    assert (state.attributes.get(ATTR_BATTERY_LEVEL) == 61)
    assert (state.attributes.get(ATTR_FAN_SPEED) == 'min')
    assert (state.attributes.get(ATTR_FAN_SPEED_LIST) == ['min', 'medium', 'high', 'max'])