diff --git a/custom_components/frigate/camera.py b/custom_components/frigate/camera.py index ebde5eae..7fd41f95 100644 --- a/custom_components/frigate/camera.py +++ b/custom_components/frigate/camera.py @@ -300,12 +300,12 @@ def extra_state_attributes(self) -> dict[str, str]: } @property - def supported_features(self) -> int: + def supported_features(self) -> CameraEntityFeature: """Return supported features of this camera.""" if not self._attr_is_streaming: - return 0 + return CameraEntityFeature(0) - return cast(int, CameraEntityFeature.STREAM) + return CameraEntityFeature.STREAM async def async_camera_image( self, width: int | None = None, height: int | None = None @@ -446,9 +446,9 @@ def device_info(self) -> dict[str, Any]: } @property - def supported_features(self) -> int: + def supported_features(self) -> CameraEntityFeature: """Return supported features of this camera.""" - return cast(int, CameraEntityFeature.STREAM) + return CameraEntityFeature.STREAM async def async_camera_image( self, width: int | None = None, height: int | None = None diff --git a/custom_components/frigate/sensor.py b/custom_components/frigate/sensor.py index 0b31e77b..9bf3b963 100644 --- a/custom_components/frigate/sensor.py +++ b/custom_components/frigate/sensor.py @@ -5,7 +5,7 @@ from typing import Any from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_URL, PERCENTAGE, TEMP_CELSIUS +from homeassistant.const import CONF_URL, PERCENTAGE, UnitOfTemperature from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -538,7 +538,7 @@ def state(self) -> float | None: @property def unit_of_measurement(self) -> Any: """Return the unit of measurement of the sensor.""" - return TEMP_CELSIUS + return UnitOfTemperature.CELSIUS @property def icon(self) -> str: diff --git a/tests/test_media_source.py b/tests/test_media_source.py index 5d5b5a9f..f55b6d4a 100644 --- a/tests/test_media_source.py +++ b/tests/test_media_source.py @@ -647,9 +647,10 @@ async def test_async_resolve_media( # Convert from HA local timezone to UTC. info = await system_info.async_get_system_info(hass) - date = datetime.datetime(2021, 5, 30, 15, 46, 8) - date = pytz.timezone(info.get("timezone", "utc")).localize(date) - date = date.astimezone(pytz.utc) + date = datetime.datetime(2021, 5, 30, 15, 46, 8, 0, datetime.timezone.utc) - ( + datetime.datetime.now(pytz.timezone(info.get("timezone", "utc"))).utcoffset() + or datetime.timedelta() + ) assert media == PlayMedia( url=( diff --git a/tests/test_sensor.py b/tests/test_sensor.py index 8caa3dcb..a3bc9ef2 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -29,7 +29,7 @@ ICON_SERVER, ICON_SPEEDOMETER, ) -from homeassistant.const import PERCENTAGE, TEMP_CELSIUS +from homeassistant.const import PERCENTAGE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr, entity_registry as er import homeassistant.util.dt as dt_util @@ -234,7 +234,7 @@ async def test_coral_temp_sensor(hass: HomeAssistant) -> None: assert entity_state assert entity_state.state == "50.0" assert entity_state.attributes["icon"] == ICON_CORAL - assert entity_state.attributes["unit_of_measurement"] == TEMP_CELSIUS + assert entity_state.attributes["unit_of_measurement"] == UnitOfTemperature.CELSIUS stats: dict[str, Any] = copy.deepcopy(TEST_STATS) client.async_get_stats = AsyncMock(return_value=stats)