deCONZ add via_hub attribute for device registry (#16760)

* deCONZ add via_hub attribute for device registry

* A shorter way to get bridgeid
pull/16768/head
Robert Svensson 2018-09-21 09:21:44 +02:00 committed by Paulus Schoutsen
parent 78b6439ee6
commit 90c18d1c15
8 changed files with 14 additions and 0 deletions

View File

@ -127,6 +127,7 @@ class DeconzBinarySensor(BinarySensorDevice):
self._sensor.uniqueid.count(':') != 7):
return None
serial = self._sensor.uniqueid.split('-', 1)[0]
bridgeid = self.hass.data[DATA_DECONZ].config.bridgeid
return {
'connections': {(CONNECTION_ZIGBEE, serial)},
'identifiers': {(DECONZ_DOMAIN, serial)},
@ -134,4 +135,5 @@ class DeconzBinarySensor(BinarySensorDevice):
'model': self._sensor.modelid,
'name': self._sensor.name,
'sw_version': self._sensor.swversion,
'via_hub': (DECONZ_DOMAIN, bridgeid),
}

View File

@ -213,6 +213,7 @@ class DeconzLight(Light):
self._light.uniqueid.count(':') != 7):
return None
serial = self._light.uniqueid.split('-', 1)[0]
bridgeid = self.hass.data[DATA_DECONZ].config.bridgeid
return {
'connections': {(CONNECTION_ZIGBEE, serial)},
'identifiers': {(DECONZ_DOMAIN, serial)},
@ -220,4 +221,5 @@ class DeconzLight(Light):
'model': self._light.modelid,
'name': self._light.name,
'sw_version': self._light.swversion,
'via_hub': (DECONZ_DOMAIN, bridgeid),
}

View File

@ -147,6 +147,7 @@ class DeconzSensor(Entity):
self._sensor.uniqueid.count(':') != 7):
return None
serial = self._sensor.uniqueid.split('-', 1)[0]
bridgeid = self.hass.data[DATA_DECONZ].config.bridgeid
return {
'connections': {(CONNECTION_ZIGBEE, serial)},
'identifiers': {(DECONZ_DOMAIN, serial)},
@ -154,6 +155,7 @@ class DeconzSensor(Entity):
'model': self._sensor.modelid,
'name': self._sensor.name,
'sw_version': self._sensor.swversion,
'via_hub': (DECONZ_DOMAIN, bridgeid),
}
@ -227,6 +229,7 @@ class DeconzBattery(Entity):
self._sensor.uniqueid.count(':') != 7):
return None
serial = self._sensor.uniqueid.split('-', 1)[0]
bridgeid = self.hass.data[DATA_DECONZ].config.bridgeid
return {
'connections': {(CONNECTION_ZIGBEE, serial)},
'identifiers': {(DECONZ_DOMAIN, serial)},
@ -234,4 +237,5 @@ class DeconzBattery(Entity):
'model': self._sensor.modelid,
'name': self._sensor.name,
'sw_version': self._sensor.swversion,
'via_hub': (DECONZ_DOMAIN, bridgeid),
}

View File

@ -92,6 +92,7 @@ class DeconzSwitch(SwitchDevice):
self._switch.uniqueid.count(':') != 7):
return None
serial = self._switch.uniqueid.split('-', 1)[0]
bridgeid = self.hass.data[DATA_DECONZ].config.bridgeid
return {
'connections': {(CONNECTION_ZIGBEE, serial)},
'identifiers': {(DECONZ_DOMAIN, serial)},
@ -99,6 +100,7 @@ class DeconzSwitch(SwitchDevice):
'model': self._switch.modelid,
'name': self._switch.name,
'sw_version': self._switch.swversion,
'via_hub': (DECONZ_DOMAIN, bridgeid),
}

View File

@ -34,6 +34,7 @@ async def setup_bridge(hass, data, allow_clip_sensor=True):
entry = Mock()
entry.data = {'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'}
bridge = DeconzSession(loop, session, **entry.data)
bridge.config = Mock()
with patch('pydeconz.DeconzSession.async_get_state',
return_value=mock_coro(data)):
await bridge.async_load_parameters()

View File

@ -55,6 +55,7 @@ async def setup_bridge(hass, data, allow_deconz_groups=True):
entry = Mock()
entry.data = {'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'}
bridge = DeconzSession(loop, session, **entry.data)
bridge.config = Mock()
with patch('pydeconz.DeconzSession.async_get_state',
return_value=mock_coro(data)):
await bridge.async_load_parameters()

View File

@ -49,6 +49,7 @@ async def setup_bridge(hass, data, allow_clip_sensor=True):
entry = Mock()
entry.data = {'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'}
bridge = DeconzSession(loop, session, **entry.data)
bridge.config = Mock()
with patch('pydeconz.DeconzSession.async_get_state',
return_value=mock_coro(data)):
await bridge.async_load_parameters()

View File

@ -47,6 +47,7 @@ async def setup_bridge(hass, data):
entry = Mock()
entry.data = {'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'}
bridge = DeconzSession(loop, session, **entry.data)
bridge.config = Mock()
with patch('pydeconz.DeconzSession.async_get_state',
return_value=mock_coro(data)):
await bridge.async_load_parameters()