From 42dc06aff7439a6c5be5708eae5713d050999230 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 14 Feb 2023 08:57:35 -0600 Subject: [PATCH] Fix netatmo with python 3.11 Ideally the library makes these StrEnums instead see https://blog.pecar.me/python-enum --- homeassistant/components/netatmo/netatmo_entity_base.py | 8 +++++--- tests/components/netatmo/test_camera.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/netatmo/netatmo_entity_base.py b/homeassistant/components/netatmo/netatmo_entity_base.py index 78352e486e016..12798c164f834 100644 --- a/homeassistant/components/netatmo/netatmo_entity_base.py +++ b/homeassistant/components/netatmo/netatmo_entity_base.py @@ -92,9 +92,11 @@ def async_update_callback(self) -> None: @property def device_info(self) -> DeviceInfo: """Return the device info for the sensor.""" - manufacturer, model = DEVICE_DESCRIPTION_MAP[ - getattr(NetatmoDeviceType, self._model) - ] + if "." in self._model: + netatmo_device = NetatmoDeviceType(self._model.partition(".")[2]) + else: + netatmo_device = getattr(NetatmoDeviceType, self._model) + manufacturer, model = DEVICE_DESCRIPTION_MAP[netatmo_device] return DeviceInfo( configuration_url=self._config_url, identifiers={(DOMAIN, self._id)}, diff --git a/tests/components/netatmo/test_camera.py b/tests/components/netatmo/test_camera.py index 76397988187b4..0ff55df6caf0d 100644 --- a/tests/components/netatmo/test_camera.py +++ b/tests/components/netatmo/test_camera.py @@ -350,7 +350,7 @@ async def test_service_set_camera_light_invalid_type(hass, config_entry, netatmo await hass.async_block_till_done() mock_set_state.assert_not_called() - assert excinfo.value.args == ("NACamera does not have a floodlight",) + assert "NACamera does not have a floodlight" in excinfo.value.args[0] async def test_camera_reconnect_webhook(hass, config_entry):