async def test_default_availability_payload(hass, mock_publish):
    'Test the availability payload.'
    assert (await async_setup_component(hass, switch.DOMAIN, {switch.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'availability_topic': 'availability_topic', 'payload_on': 1, 'payload_off': 0}}))
    state = hass.states.get('switch.test')
    assert (STATE_UNAVAILABLE == state.state)
    async_fire_mqtt_message(hass, 'availability_topic', 'online')
    (await hass.async_block_till_done())
    (await hass.async_block_till_done())
    state = hass.states.get('switch.test')
    assert (STATE_OFF == state.state)
    assert (not state.attributes.get(ATTR_ASSUMED_STATE))
    async_fire_mqtt_message(hass, 'availability_topic', 'offline')
    (await hass.async_block_till_done())
    (await hass.async_block_till_done())
    state = hass.states.get('switch.test')
    assert (STATE_UNAVAILABLE == state.state)
    async_fire_mqtt_message(hass, 'state-topic', '1')
    (await hass.async_block_till_done())
    (await hass.async_block_till_done())
    state = hass.states.get('switch.test')
    assert (STATE_UNAVAILABLE == state.state)
    async_fire_mqtt_message(hass, 'availability_topic', 'online')
    (await hass.async_block_till_done())
    (await hass.async_block_till_done())
    state = hass.states.get('switch.test')
    assert (STATE_ON == state.state)
Test the availability payload.
async def test_default_availability_payload(hass, mock_publish):
    
    assert (await async_setup_component(hass, switch.DOMAIN, {switch.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'availability_topic': 'availability_topic', 'payload_on': 1, 'payload_off': 0}}))
    state = hass.states.get('switch.test')
    assert (STATE_UNAVAILABLE == state.state)
    async_fire_mqtt_message(hass, 'availability_topic', 'online')
    (await hass.async_block_till_done())
    (await hass.async_block_till_done())
    state = hass.states.get('switch.test')
    assert (STATE_OFF == state.state)
    assert (not state.attributes.get(ATTR_ASSUMED_STATE))
    async_fire_mqtt_message(hass, 'availability_topic', 'offline')
    (await hass.async_block_till_done())
    (await hass.async_block_till_done())
    state = hass.states.get('switch.test')
    assert (STATE_UNAVAILABLE == state.state)
    async_fire_mqtt_message(hass, 'state-topic', '1')
    (await hass.async_block_till_done())
    (await hass.async_block_till_done())
    state = hass.states.get('switch.test')
    assert (STATE_UNAVAILABLE == state.state)
    async_fire_mqtt_message(hass, 'availability_topic', 'online')
    (await hass.async_block_till_done())
    (await hass.async_block_till_done())
    state = hass.states.get('switch.test')
    assert (STATE_ON == state.state)