Add MQTT Sensor unique_id (#13318)
* Add MQTT Sensor unique_id * Add test * Update comment
This commit is contained in:
parent
99f4509c2b
commit
81b1d08d35
2 changed files with 35 additions and 1 deletions
|
@ -329,3 +329,24 @@ class TestSensorMQTT(unittest.TestCase):
|
|||
self.assertEqual('100',
|
||||
state.attributes.get('val'))
|
||||
self.assertEqual('100', state.state)
|
||||
|
||||
def test_unique_id(self):
|
||||
"""Test unique id option only creates one sensor per unique_id."""
|
||||
assert setup_component(self.hass, sensor.DOMAIN, {
|
||||
sensor.DOMAIN: [{
|
||||
'platform': 'mqtt',
|
||||
'name': 'Test 1',
|
||||
'state_topic': 'test-topic',
|
||||
'unique_id': 'TOTALLY_UNIQUE'
|
||||
}, {
|
||||
'platform': 'mqtt',
|
||||
'name': 'Test 2',
|
||||
'state_topic': 'test-topic',
|
||||
'unique_id': 'TOTALLY_UNIQUE'
|
||||
}]
|
||||
})
|
||||
|
||||
fire_mqtt_message(self.hass, 'test-topic', 'payload')
|
||||
self.hass.block_till_done()
|
||||
|
||||
assert len(self.hass.states.all()) == 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue