Address late review for blink (#103376)
* use self.coordinator * Dont store coordinator * revert unintended sensor change * revert remove * indention error * revert * Revert morepull/103379/head
parent
72c02d4d63
commit
26e1285f34
|
@ -57,8 +57,7 @@ class BlinkSyncModuleHA(
|
|||
) -> None:
|
||||
"""Initialize the alarm control panel."""
|
||||
super().__init__(coordinator)
|
||||
self.api: Blink = coordinator.api
|
||||
self._coordinator = coordinator
|
||||
self.api: Blink = self.coordinator.api
|
||||
self.sync = sync
|
||||
self._attr_unique_id: str = sync.serial
|
||||
self._attr_device_info = DeviceInfo(
|
||||
|
@ -94,7 +93,7 @@ class BlinkSyncModuleHA(
|
|||
except asyncio.TimeoutError as er:
|
||||
raise HomeAssistantError("Blink failed to disarm camera") from er
|
||||
|
||||
await self._coordinator.async_refresh()
|
||||
await self.coordinator.async_refresh()
|
||||
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm command."""
|
||||
|
@ -104,5 +103,5 @@ class BlinkSyncModuleHA(
|
|||
except asyncio.TimeoutError as er:
|
||||
raise HomeAssistantError("Blink failed to arm camera away") from er
|
||||
|
||||
await self._coordinator.async_refresh()
|
||||
await self.coordinator.async_refresh()
|
||||
self.async_write_ha_state()
|
||||
|
|
|
@ -47,6 +47,7 @@ async def async_setup_entry(
|
|||
hass: HomeAssistant, config: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
) -> None:
|
||||
"""Set up the blink binary sensors."""
|
||||
|
||||
coordinator: BlinkUpdateCoordinator = hass.data[DOMAIN][config.entry_id]
|
||||
|
||||
entities = [
|
||||
|
|
|
@ -32,6 +32,7 @@ async def async_setup_entry(
|
|||
hass: HomeAssistant, config: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
) -> None:
|
||||
"""Set up a Blink Camera."""
|
||||
|
||||
coordinator: BlinkUpdateCoordinator = hass.data[DOMAIN][config.entry_id]
|
||||
entities = [
|
||||
BlinkCamera(coordinator, name, camera)
|
||||
|
@ -54,7 +55,6 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
|||
"""Initialize a camera."""
|
||||
super().__init__(coordinator)
|
||||
Camera.__init__(self)
|
||||
self._coordinator = coordinator
|
||||
self._camera = camera
|
||||
self._attr_unique_id = f"{camera.serial}-camera"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
|
@ -80,7 +80,7 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
|||
raise HomeAssistantError("Blink failed to arm camera") from er
|
||||
|
||||
self._camera.motion_enabled = True
|
||||
await self._coordinator.async_refresh()
|
||||
await self.coordinator.async_refresh()
|
||||
|
||||
async def async_disable_motion_detection(self) -> None:
|
||||
"""Disable motion detection for the camera."""
|
||||
|
@ -90,7 +90,7 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
|||
raise HomeAssistantError("Blink failed to disarm camera") from er
|
||||
|
||||
self._camera.motion_enabled = False
|
||||
await self._coordinator.async_refresh()
|
||||
await self.coordinator.async_refresh()
|
||||
|
||||
@property
|
||||
def motion_detection_enabled(self) -> bool:
|
||||
|
@ -106,7 +106,7 @@ class BlinkCamera(CoordinatorEntity[BlinkUpdateCoordinator], Camera):
|
|||
"""Trigger camera to take a snapshot."""
|
||||
with contextlib.suppress(asyncio.TimeoutError):
|
||||
await self._camera.snap_picture()
|
||||
await self._coordinator.api.refresh()
|
||||
await self.coordinator.api.refresh()
|
||||
self.async_write_ha_state()
|
||||
|
||||
def camera_image(
|
||||
|
|
|
@ -48,6 +48,7 @@ async def async_setup_entry(
|
|||
hass: HomeAssistant, config: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
) -> None:
|
||||
"""Initialize a Blink sensor."""
|
||||
|
||||
coordinator: BlinkUpdateCoordinator = hass.data[DOMAIN][config.entry_id]
|
||||
entities = [
|
||||
BlinkSensor(coordinator, camera, description)
|
||||
|
|
Loading…
Reference in New Issue