Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions homeassistant/components/verisure/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def async_setup_entry(

assert hass.config.config_dir
async_add_entities(
VerisureSmartcam(hass, coordinator, serial_number, hass.config.config_dir)
VerisureSmartcam(coordinator, serial_number, hass.config.config_dir)
for serial_number in coordinator.data["cameras"]
)

Expand All @@ -48,7 +48,6 @@ class VerisureSmartcam(CoordinatorEntity, Camera):

def __init__(
self,
hass: HomeAssistant,
coordinator: VerisureDataUpdateCoordinator,
serial_number: str,
directory_path: str,
Expand All @@ -60,7 +59,6 @@ def __init__(
self._directory_path = directory_path
self._image = None
self._image_id = None
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, self.delete_image)

@property
def name(self) -> str:
Expand Down Expand Up @@ -126,7 +124,7 @@ def check_imagelist(self) -> None:
self._image_id = new_image_id
self._image = new_image_path

def delete_image(self) -> None:
def delete_image(self, _=None) -> None:
"""Delete an old image."""
remove_image = os.path.join(
self._directory_path, "{}{}".format(self._image_id, ".jpg")
Expand All @@ -145,3 +143,8 @@ def capture_smartcam(self) -> None:
LOGGER.debug("Capturing new image from %s", self.serial_number)
except VerisureError as ex:
LOGGER.error("Could not capture image, %s", ex)

async def async_added_to_hass(self) -> None:
"""Entity added to Home Assistant."""
await super().async_added_to_hass()
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.delete_image)