Remove discovered MQTT binary_sensor device when discovery topic is cleared (#16826)

This commit is contained in:
emontnemery authored and Paulus Schoutsen committed 2018-09-25 14:25:03 +02:00
1 parent 9ea5afd109
commit 093285f92f
2 files changed
+39 -7

No files matched your search

+22
View File
@@ -211,6 +211,28 @@ def test_discovery_removal(hass, mqtt_mock, caplog):
assert state is None
@asyncio.coroutine
def test_discovery_removal_binary_sensor(hass, mqtt_mock, caplog):
"""Test removal of discovered binary_sensor."""
yield from async_start(hass, 'homeassistant', {})
data = (
'{ "name": "Beer",'
' "status_topic": "test_topic" }'
)
async_fire_mqtt_message(hass, 'homeassistant/binary_sensor/bla/config',
data)
yield from hass.async_block_till_done()
state = hass.states.get('binary_sensor.beer')
assert state is not None
assert state.name == 'Beer'
async_fire_mqtt_message(hass, 'homeassistant/binary_sensor/bla/config',
'')
yield from hass.async_block_till_done()
yield from hass.async_block_till_done()
state = hass.states.get('binary_sensor.beer')
assert state is None
@asyncio.coroutine
def test_discovery_removal_light(hass, mqtt_mock, caplog):
"""Test removal of discovered light."""