mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Support for mulitple Blink sync modules (#18663)
This commit is contained in:
committed by
Diogo Gomes
parent
d7a10136df
commit
4486de743d
@@ -25,21 +25,19 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
return
|
||||
data = hass.data[BLINK_DATA]
|
||||
|
||||
# Current version of blinkpy API only supports one sync module. When
|
||||
# support for additional models is added, the sync module name should
|
||||
# come from the API.
|
||||
sync_modules = []
|
||||
sync_modules.append(BlinkSyncModule(data, 'sync'))
|
||||
for sync_name, sync_module in data.sync.items():
|
||||
sync_modules.append(BlinkSyncModule(data, sync_name, sync_module))
|
||||
add_entities(sync_modules, True)
|
||||
|
||||
|
||||
class BlinkSyncModule(AlarmControlPanel):
|
||||
"""Representation of a Blink Alarm Control Panel."""
|
||||
|
||||
def __init__(self, data, name):
|
||||
def __init__(self, data, name, sync):
|
||||
"""Initialize the alarm control panel."""
|
||||
self.data = data
|
||||
self.sync = data.sync
|
||||
self.sync = sync
|
||||
self._name = name
|
||||
self._state = None
|
||||
|
||||
@@ -68,6 +66,7 @@ class BlinkSyncModule(AlarmControlPanel):
|
||||
"""Return the state attributes."""
|
||||
attr = self.sync.attributes
|
||||
attr['network_info'] = self.data.networks
|
||||
attr['associated_cameras'] = list(self.sync.cameras.keys())
|
||||
attr[ATTR_ATTRIBUTION] = DEFAULT_ATTRIBUTION
|
||||
return attr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user