From c7b315c9f0e93df4479977467e3ae3436f756e19 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 29 Dec 2023 07:48:26 -0600 Subject: [PATCH 1/4] Fix record test (#591) * Fix record test * Correctly calculate offset * Fix formatting --- tests/test_media_source.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_media_source.py b/tests/test_media_source.py index 98bb967b..33d341aa 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=( From e385db838060ea5d7fa4f097ef8acb3e83406f5e Mon Sep 17 00:00:00 2001 From: Florian Gareis Date: Fri, 29 Dec 2023 14:53:19 +0100 Subject: [PATCH 2/4] Fix `TEMP_CELSIUS` deprecation (#588) --- custom_components/frigate/sensor.py | 4 ++-- tests/test_sensor.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/frigate/sensor.py b/custom_components/frigate/sensor.py index e38e57cb..4467a484 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 @@ -528,7 +528,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_sensor.py b/tests/test_sensor.py index 6baeacce..9a599b31 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) From 82fd3ec31426be8245dd63b5218587fb16426573 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 29 Dec 2023 04:03:22 -1000 Subject: [PATCH 3/4] Fix camera supported_features to return CameraEntityFeature (#589) related issue https://github.com/home-assistant/core/issues/106522 --- custom_components/frigate/camera.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/custom_components/frigate/camera.py b/custom_components/frigate/camera.py index f82fa5d1..9b376c79 100644 --- a/custom_components/frigate/camera.py +++ b/custom_components/frigate/camera.py @@ -235,12 +235,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 @@ -351,9 +351,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 From 911c830ee7895b1c745de1236fd642995fa5a69a Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Fri, 29 Dec 2023 15:05:53 +0000 Subject: [PATCH 4/4] v4.0.1 bump (#592) --- custom_components/frigate/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/frigate/manifest.json b/custom_components/frigate/manifest.json index 22d4ebe6..5d12b507 100644 --- a/custom_components/frigate/manifest.json +++ b/custom_components/frigate/manifest.json @@ -14,5 +14,5 @@ "iot_class": "local_push", "issue_tracker": "https://github.com/blakeblackshear/frigate-hass-integration/issues", "requirements": ["pytz==2022.7"], - "version": "4.0.0" + "version": "4.0.1" }