Fix Ezviz entity state for cameras that are offline (#136003)

This commit is contained in:
Renier Moorcroft 2025-02-25 16:55:31 +02:00 committed by GitHub
parent 1fb51ef189
commit 47e78e9008
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 5 deletions

View File

@ -141,11 +141,6 @@ class EzvizCamera(EzvizEntity, Camera):
if camera_password:
self._attr_supported_features = CameraEntityFeature.STREAM
@property
def available(self) -> bool:
"""Return True if entity is available."""
return self.data["status"] != 2
@property
def is_on(self) -> bool:
"""Return true if on."""

View File

@ -42,6 +42,11 @@ class EzvizEntity(CoordinatorEntity[EzvizDataUpdateCoordinator], Entity):
"""Return coordinator data for this entity."""
return self.coordinator.data[self._serial]
@property
def available(self) -> bool:
"""Return True if entity is available."""
return self.data["status"] != 2
class EzvizBaseEntity(Entity):
"""Generic entity for EZVIZ individual poll entities."""
@ -72,3 +77,8 @@ class EzvizBaseEntity(Entity):
def data(self) -> dict[str, Any]:
"""Return coordinator data for this entity."""
return self.coordinator.data[self._serial]
@property
def available(self) -> bool:
"""Return True if entity is available."""
return self.data["status"] != 2

View File

@ -4,6 +4,7 @@ from __future__ import annotations
import logging
from propcache import cached_property
from pyezviz.exceptions import PyEzvizError
from pyezviz.utils import decrypt_image
@ -62,6 +63,11 @@ class EzvizLastMotion(EzvizEntity, ImageEntity):
else None
)
@cached_property
def available(self) -> bool:
"""Entity gets data from ezviz API so always available."""
return True
async def _async_load_image_from_url(self, url: str) -> Image | None:
"""Load an image by url."""
if response := await self._fetch_url(url):