Add unique_id for mqtt binary sensor (#14929)
* Added unique_id for mqtt binary sensor * Added missing mqtt message fire in test
This commit is contained in:
parent
65b0ec6615
commit
08adfd87f7
2 changed files with 34 additions and 3 deletions
|
@ -77,6 +77,25 @@ class TestSensorMQTT(unittest.TestCase):
|
|||
state = self.hass.states.get('binary_sensor.test')
|
||||
self.assertIsNone(state)
|
||||
|
||||
def test_unique_id(self):
|
||||
"""Test unique id option only creates one sensor per unique_id."""
|
||||
assert setup_component(self.hass, binary_sensor.DOMAIN, {
|
||||
binary_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
|
||||
|
||||
def test_availability_without_topic(self):
|
||||
"""Test availability without defined availability topic."""
|
||||
self.assertTrue(setup_component(self.hass, binary_sensor.DOMAIN, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue