Don't initialize mqtt components which have already been discovered (#7625)
* Don't initialize mqtt components which have already been discovered * Fix string length * Fix blank lines, fix constant name * Remove globals. Remove JSON dump * Add tests. Update grammar * PEP8 style issue * Add hyphen to object_id regex * PEP8 style fix
This commit is contained in:
1 parent
f3dabe21ab
commit
be53cc7068
2 files changed
+38
-1
No files matched your search
@@ -73,3 +73,24 @@ def test_correct_config_discovery(hass, mqtt_mock, caplog):
|
||||
|
||||
assert state is not None
|
||||
assert state.name == 'Beer'
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_non_duplicate_discovery(hass, mqtt_mock, caplog):
|
||||
"""Test for a non duplicate component."""
|
||||
yield from async_start(hass, 'homeassistant', {})
|
||||
|
||||
async_fire_mqtt_message(hass, 'homeassistant/binary_sensor/bla/config',
|
||||
'{ "name": "Beer" }')
|
||||
async_fire_mqtt_message(hass, 'homeassistant/binary_sensor/bla/config',
|
||||
'{ "name": "Beer" }')
|
||||
yield from hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get('binary_sensor.beer')
|
||||
state_duplicate = hass.states.get('binary_sensor.beer1')
|
||||
|
||||
assert state is not None
|
||||
assert state.name == 'Beer'
|
||||
assert state_duplicate is None
|
||||
assert 'Component has already been discovered: ' \
|
||||
'binary_sensor bla' in caplog.text
|
||||
Reference in new issue
Block a user