mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Fix Ezviz entity state for cameras that are offline (#136003)
This commit is contained in:
parent
1fb51ef189
commit
47e78e9008
@ -141,11 +141,6 @@ class EzvizCamera(EzvizEntity, Camera):
|
|||||||
if camera_password:
|
if camera_password:
|
||||||
self._attr_supported_features = CameraEntityFeature.STREAM
|
self._attr_supported_features = CameraEntityFeature.STREAM
|
||||||
|
|
||||||
@property
|
|
||||||
def available(self) -> bool:
|
|
||||||
"""Return True if entity is available."""
|
|
||||||
return self.data["status"] != 2
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return true if on."""
|
"""Return true if on."""
|
||||||
|
@ -42,6 +42,11 @@ class EzvizEntity(CoordinatorEntity[EzvizDataUpdateCoordinator], Entity):
|
|||||||
"""Return coordinator data for this entity."""
|
"""Return coordinator data for this entity."""
|
||||||
return self.coordinator.data[self._serial]
|
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):
|
class EzvizBaseEntity(Entity):
|
||||||
"""Generic entity for EZVIZ individual poll entities."""
|
"""Generic entity for EZVIZ individual poll entities."""
|
||||||
@ -72,3 +77,8 @@ class EzvizBaseEntity(Entity):
|
|||||||
def data(self) -> dict[str, Any]:
|
def data(self) -> dict[str, Any]:
|
||||||
"""Return coordinator data for this entity."""
|
"""Return coordinator data for this entity."""
|
||||||
return self.coordinator.data[self._serial]
|
return self.coordinator.data[self._serial]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Return True if entity is available."""
|
||||||
|
return self.data["status"] != 2
|
||||||
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from propcache import cached_property
|
||||||
from pyezviz.exceptions import PyEzvizError
|
from pyezviz.exceptions import PyEzvizError
|
||||||
from pyezviz.utils import decrypt_image
|
from pyezviz.utils import decrypt_image
|
||||||
|
|
||||||
@ -62,6 +63,11 @@ class EzvizLastMotion(EzvizEntity, ImageEntity):
|
|||||||
else None
|
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:
|
async def _async_load_image_from_url(self, url: str) -> Image | None:
|
||||||
"""Load an image by url."""
|
"""Load an image by url."""
|
||||||
if response := await self._fetch_url(url):
|
if response := await self._fetch_url(url):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user