'Test the setting of the value via MQTT.'

def test_setting_sensor_value_via_mqtt_message(self):

    assert setup_component(self.hass, binary_sensor.DOMAIN, {binary_sensor.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'test-topic', 'payload_on': 'ON', 'payload_off': 'OFF'}})
    state = self.hass.states.get('binary_sensor.test')
    self.assertEqual(STATE_OFF, state.state)
    fire_mqtt_message(self.hass, 'test-topic', 'ON')
    self.hass.block_till_done()
    state = self.hass.states.get('binary_sensor.test')
    self.assertEqual(STATE_ON, state.state)
    fire_mqtt_message(self.hass, 'test-topic', 'OFF')
    self.hass.block_till_done()
    state = self.hass.states.get('binary_sensor.test')
    self.assertEqual(STATE_OFF, state.state)
