Cleanup if discovered mqtt climate can't be added (#19739)

* Cleanup if discovered mqtt climate can't be added
This commit is contained in:
emontnemery authored and GitHub committed 2019-01-08 16:53:02 +01:00
1 parent 203701bc7c
commit 0cea54cea1
2 files changed
+45 -5

No files matched your search

+34 -1
View File
@@ -719,7 +719,7 @@ async def test_discovery_removal_climate(hass, mqtt_mock, caplog):
async def test_discovery_update_climate(hass, mqtt_mock, caplog):
"""Test removal of discovered climate."""
"""Test update of discovered climate."""
entry = MockConfigEntry(domain=mqtt.DOMAIN)
await async_start(hass, 'homeassistant', {}, entry)
data1 = (
@@ -749,6 +749,39 @@ async def test_discovery_update_climate(hass, mqtt_mock, caplog):
assert state is None
async def test_discovery_broken(hass, mqtt_mock, caplog):
"""Test handling of bad discovery message."""
entry = MockConfigEntry(domain=mqtt.DOMAIN)
await async_start(hass, 'homeassistant', {}, entry)
data1 = (
'{ "name": "Beer",'
' "power_command_topic": "test_topic#" }'
)
data2 = (
'{ "name": "Milk", '
' "power_command_topic": "test_topic" }'
)
async_fire_mqtt_message(hass, 'homeassistant/climate/bla/config',
data1)
await hass.async_block_till_done()
state = hass.states.get('climate.beer')
assert state is None
async_fire_mqtt_message(hass, 'homeassistant/climate/bla/config',
data2)
await hass.async_block_till_done()
await hass.async_block_till_done()
state = hass.states.get('climate.milk')
assert state is not None
assert state.name == 'Milk'
state = hass.states.get('climate.beer')
assert state is None
async def test_entity_device_info_with_identifier(hass, mqtt_mock):
"""Test MQTT climate device registry integration."""
entry = MockConfigEntry(domain=mqtt.DOMAIN)