Add unique_id to MQTT switch (#13719)
This commit is contained in:
parent
f3411f8db2
commit
2bb1a95098
2 changed files with 35 additions and 1 deletions
|
@ -248,3 +248,26 @@ class TestSwitchMQTT(unittest.TestCase):
|
|||
|
||||
state = self.hass.states.get('switch.test')
|
||||
self.assertEqual(STATE_ON, state.state)
|
||||
|
||||
def test_unique_id(self):
|
||||
"""Test unique id option only creates one switch per unique_id."""
|
||||
assert setup_component(self.hass, switch.DOMAIN, {
|
||||
switch.DOMAIN: [{
|
||||
'platform': 'mqtt',
|
||||
'name': 'Test 1',
|
||||
'state_topic': 'test-topic',
|
||||
'command_topic': 'command-topic',
|
||||
'unique_id': 'TOTALLY_UNIQUE'
|
||||
}, {
|
||||
'platform': 'mqtt',
|
||||
'name': 'Test 2',
|
||||
'state_topic': 'test-topic',
|
||||
'command_topic': 'command-topic',
|
||||
'unique_id': 'TOTALLY_UNIQUE'
|
||||
}]
|
||||
})
|
||||
|
||||
fire_mqtt_message(self.hass, 'test-topic', 'payload')
|
||||
self.hass.block_till_done()
|
||||
assert len(self.hass.states.async_entity_ids()) == 2
|
||||
# all switches group is 1, unique id created is 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue