Add Ring config flow (#30564)
* Add Ring config flow * Address comments + migrate platforms to config entry * Migrate camera too * Address comments * Fix order config flows * setup -> async_setup
This commit is contained in:
1 parent
3348f4f6d1
commit
3f29c234b8
17 files changed
+435
-146
No files matched your search
@@ -22,7 +22,7 @@ SIREN_ICON = "mdi:alarm-bell"
|
||||
SKIP_UPDATES_DELAY = timedelta(seconds=5)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Create the switches for the Ring devices."""
|
||||
cameras = hass.data[DATA_RING_STICKUP_CAMS]
|
||||
switches = []
|
||||
@@ -30,7 +30,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
if device.has_capability("siren"):
|
||||
switches.append(SirenSwitch(device))
|
||||
|
||||
add_entities(switches, True)
|
||||
async_add_entities(switches, True)
|
||||
|
||||
|
||||
class BaseRingSwitch(SwitchDevice):
|
||||
@@ -41,10 +41,19 @@ class BaseRingSwitch(SwitchDevice):
|
||||
self._device = device
|
||||
self._device_type = device_type
|
||||
self._unique_id = f"{self._device.id}-{self._device_type}"
|
||||
self._disp_disconnect = None
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
async_dispatcher_connect(self.hass, SIGNAL_UPDATE_RING, self._update_callback)
|
||||
self._disp_disconnect = async_dispatcher_connect(
|
||||
self.hass, SIGNAL_UPDATE_RING, self._update_callback
|
||||
)
|
||||
|
||||
async def async_will_remove_from_hass(self):
|
||||
"""Disconnect callbacks."""
|
||||
if self._disp_disconnect:
|
||||
self._disp_disconnect()
|
||||
self._disp_disconnect = None
|
||||
|
||||
@callback
|
||||
def _update_callback(self):
|
||||
|
||||
Reference in new issue
Block a user