Reconfigure MQTT switch component if discovery info is changed (#18179)

This commit is contained in:
emontnemery authored and Paulus Schoutsen committed 2018-12-02 16:16:46 +01:00
1 parent afa99915e3
commit ae9e3d83d7
2 files changed
+113 -59

No files matched your search

+36
View File
@@ -361,6 +361,42 @@ async def test_discovery_removal_switch(hass, mqtt_mock, caplog):
assert state is None
async def test_discovery_update_switch(hass, mqtt_mock, caplog):
"""Test expansion of discovered switch."""
entry = MockConfigEntry(domain=mqtt.DOMAIN)
await async_start(hass, 'homeassistant', {}, entry)
data1 = (
'{ "name": "Beer",'
' "status_topic": "test_topic",'
' "command_topic": "test_topic" }'
)
data2 = (
'{ "name": "Milk",'
' "status_topic": "test_topic",'
' "command_topic": "test_topic" }'
)
async_fire_mqtt_message(hass, 'homeassistant/switch/bla/config',
data1)
await hass.async_block_till_done()
state = hass.states.get('switch.beer')
assert state is not None
assert state.name == 'Beer'
async_fire_mqtt_message(hass, 'homeassistant/switch/bla/config',
data2)
await hass.async_block_till_done()
await hass.async_block_till_done()
state = hass.states.get('switch.beer')
assert state is not None
assert state.name == 'Milk'
state = hass.states.get('switch.milk')
assert state is None
async def test_entity_device_info_with_identifier(hass, mqtt_mock):
"""Test MQTT switch device registry integration."""
entry = MockConfigEntry(domain=mqtt.DOMAIN)