def test_controlling_state_via_topic(self):
        assert _setup_component(self.hass, garage_door.DOMAIN, {
            garage_door.DOMAIN: {
                'platform': 'mqtt',
                'name': 'test',
                'state_topic': 'state-topic',
                'command_topic': 'command-topic',
                'state_open': 1,
                'state_closed': 0,
                'service_open': 1,
                'service_close': 0
            }
        })

        state = self.hass.states.get('garage_door.test')
        self.assertEqual(STATE_CLOSED, state.state)
        self.assertIsNone(state.attributes.get(ATTR_ASSUMED_STATE))

        fire_mqtt_message(self.hass, 'state-topic', '1')
        self.hass.pool.block_till_done()

        state = self.hass.states.get('garage_door.test')
        self.assertEqual(STATE_OPEN, state.state)

        fire_mqtt_message(self.hass, 'state-topic', '0')
        self.hass.pool.block_till_done()

        state = self.hass.states.get('garage_door.test')
        self.assertEqual(STATE_CLOSED, state.state)
Test the controlling state via topic.
dataset/ETHPy150Open home-assistant/home-assistant/tests/components/garage_door/test_mqtt.py/TestGarageDoorMQTT.test_controlling_state_via_topic