Add unique_id to mqtt camera (#16569)

* Add unique_id to mqtt camera

* Remove whitespaces

* Add test for unique_id

* Add blank line
This commit is contained in:
Maciej Bieniek authored and Paulus Schoutsen committed 2018-09-21 13:09:54 +02:00
1 parent 3bfe9e757e
commit a0a54dfd5b
2 files changed
+33 -1

No files matched your search

+23
View File
@@ -29,3 +29,26 @@ def test_run_camera_setup(hass, aiohttp_client):
assert resp.status == 200
body = yield from resp.text()
assert body == 'beer'
@asyncio.coroutine
def test_unique_id(hass):
"""Test unique id option only creates one camera per unique_id."""
yield from async_mock_mqtt_component(hass)
yield from async_setup_component(hass, 'camera', {
'camera': [{
'platform': 'mqtt',
'name': 'Test Camera 1',
'topic': 'test-topic',
'unique_id': 'TOTALLY_UNIQUE'
}, {
'platform': 'mqtt',
'name': 'Test Camera 2',
'topic': 'test-topic',
'unique_id': 'TOTALLY_UNIQUE'
}]
})
async_fire_mqtt_message(hass, 'test-topic', 'payload')
yield from hass.async_block_till_done()
assert len(hass.states.async_all()) == 1