From 1075ea1220727fa2308ef992ec32d50ca6027773 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:52:23 +0200 Subject: [PATCH] Bump renault-api to 0.3.0 (#143657) --- .../components/renault/binary_sensor.py | 5 +- .../components/renault/manifest.json | 2 +- .../components/renault/renault_vehicle.py | 15 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/renault/const.py | 11 -- .../renault/snapshots/test_diagnostics.ambr | 4 - .../renault/snapshots/test_sensor.ambr | 172 ------------------ tests/components/renault/test_sensor.py | 8 +- tests/components/renault/test_services.py | 14 +- 10 files changed, 29 insertions(+), 206 deletions(-) diff --git a/homeassistant/components/renault/binary_sensor.py b/homeassistant/components/renault/binary_sensor.py index 0aebd3bd835..f7b81289f1b 100644 --- a/homeassistant/components/renault/binary_sensor.py +++ b/homeassistant/components/renault/binary_sensor.py @@ -74,10 +74,7 @@ BINARY_SENSOR_TYPES: tuple[RenaultBinarySensorEntityDescription, ...] = tuple( coordinator="battery", device_class=BinarySensorDeviceClass.PLUG, on_key="plugStatus", - on_value=[ - PlugState.PLUGGED.value, - PlugState.PLUGGED_WAITING_FOR_CHARGE.value, - ], + on_value=PlugState.PLUGGED.value, ), RenaultBinarySensorEntityDescription( key="charging", diff --git a/homeassistant/components/renault/manifest.json b/homeassistant/components/renault/manifest.json index 1a599afe4e4..06acf4a3e49 100644 --- a/homeassistant/components/renault/manifest.json +++ b/homeassistant/components/renault/manifest.json @@ -8,5 +8,5 @@ "iot_class": "cloud_polling", "loggers": ["renault_api"], "quality_scale": "silver", - "requirements": ["renault-api==0.2.9"] + "requirements": ["renault-api==0.3.0"] } diff --git a/homeassistant/components/renault/renault_vehicle.py b/homeassistant/components/renault/renault_vehicle.py index 2ecaa7e1061..89059e890f4 100644 --- a/homeassistant/components/renault/renault_vehicle.py +++ b/homeassistant/components/renault/renault_vehicle.py @@ -11,7 +11,7 @@ import logging from typing import TYPE_CHECKING, Any, Concatenate, cast from renault_api.exceptions import RenaultException -from renault_api.kamereon import models +from renault_api.kamereon import models, schemas from renault_api.renault_vehicle import RenaultVehicle from homeassistant.core import HomeAssistant @@ -201,7 +201,18 @@ class RenaultVehicleProxy: @with_error_wrapping async def get_charging_settings(self) -> models.KamereonVehicleChargingSettingsData: """Get vehicle charging settings.""" - return await self._vehicle.get_charging_settings() + full_endpoint = await self._vehicle.get_full_endpoint("charging-settings") + response = await self._vehicle.http_get(full_endpoint) + response_data = cast( + models.KamereonVehicleDataResponse, + schemas.KamereonVehicleDataResponseSchema.load(response.raw_data), + ) + return cast( + models.KamereonVehicleChargingSettingsData, + response_data.get_attributes( + schemas.KamereonVehicleChargingSettingsDataSchema + ), + ) @with_error_wrapping async def set_charge_schedules( diff --git a/requirements_all.txt b/requirements_all.txt index d7b2a85bfe8..660f525fd06 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2630,7 +2630,7 @@ refoss-ha==1.2.5 regenmaschine==2024.03.0 # homeassistant.components.renault -renault-api==0.2.9 +renault-api==0.3.0 # homeassistant.components.renson renson-endura-delta==1.7.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index b17adac11c7..905591fb5ce 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2134,7 +2134,7 @@ refoss-ha==1.2.5 regenmaschine==2024.03.0 # homeassistant.components.renault -renault-api==0.2.9 +renault-api==0.3.0 # homeassistant.components.renson renson-endura-delta==1.7.2 diff --git a/tests/components/renault/const.py b/tests/components/renault/const.py index c552321ef97..30ff85d6c69 100644 --- a/tests/components/renault/const.py +++ b/tests/components/renault/const.py @@ -256,17 +256,6 @@ MOCK_VEHICLES = { ATTR_STATE: "plugged", ATTR_UNIQUE_ID: "vf1aaaaa555777999_plug_state", }, - { - ATTR_ENTITY_ID: "sensor.reg_number_remote_engine_start", - ATTR_STATE: STATE_UNKNOWN, - ATTR_UNIQUE_ID: "vf1aaaaa555777999_res_state", - }, - { - ATTR_DEFAULT_DISABLED: True, - ATTR_ENTITY_ID: "sensor.reg_number_remote_engine_start_code", - ATTR_STATE: STATE_UNKNOWN, - ATTR_UNIQUE_ID: "vf1aaaaa555777999_res_state_code", - }, ], }, "zoe_50": { diff --git a/tests/components/renault/snapshots/test_diagnostics.ambr b/tests/components/renault/snapshots/test_diagnostics.ambr index a2921dff35e..80ef412427d 100644 --- a/tests/components/renault/snapshots/test_diagnostics.ambr +++ b/tests/components/renault/snapshots/test_diagnostics.ambr @@ -24,8 +24,6 @@ 'externalTemperature': 8.0, 'hvacStatus': 'off', }), - 'res_state': dict({ - }), }), 'details': dict({ 'assets': list([ @@ -229,8 +227,6 @@ 'externalTemperature': 8.0, 'hvacStatus': 'off', }), - 'res_state': dict({ - }), }), 'details': dict({ 'assets': list([ diff --git a/tests/components/renault/snapshots/test_sensor.ambr b/tests/components/renault/snapshots/test_sensor.ambr index 175ad2422ed..2027a32c0a4 100644 --- a/tests/components/renault/snapshots/test_sensor.ambr +++ b/tests/components/renault/snapshots/test_sensor.ambr @@ -1577,70 +1577,6 @@ 'unique_id': 'vf1aaaaa555777999_hvac_last_activity', 'unit_of_measurement': None, }), - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'sensor', - 'entity_category': None, - 'entity_id': 'sensor.reg_number_remote_engine_start', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': 'Remote engine start', - 'platform': 'renault', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'res_state', - 'unique_id': 'vf1aaaaa555777999_res_state', - 'unit_of_measurement': None, - }), - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'sensor', - 'entity_category': None, - 'entity_id': 'sensor.reg_number_remote_engine_start_code', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': 'Remote engine start code', - 'platform': 'renault', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'res_state_code', - 'unique_id': 'vf1aaaaa555777999_res_state_code', - 'unit_of_measurement': None, - }), ]) # --- # name: test_sensor_empty[zoe_40].2 @@ -1834,28 +1770,6 @@ 'last_updated': , 'state': 'unknown', }), - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': 'REG-NUMBER Remote engine start', - }), - 'context': , - 'entity_id': 'sensor.reg_number_remote_engine_start', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'unknown', - }), - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': 'REG-NUMBER Remote engine start code', - }), - 'context': , - 'entity_id': 'sensor.reg_number_remote_engine_start_code', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'unknown', - }), ]) # --- # name: test_sensor_empty[zoe_50] @@ -4249,70 +4163,6 @@ 'unique_id': 'vf1aaaaa555777999_hvac_last_activity', 'unit_of_measurement': None, }), - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'sensor', - 'entity_category': None, - 'entity_id': 'sensor.reg_number_remote_engine_start', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': 'Remote engine start', - 'platform': 'renault', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'res_state', - 'unique_id': 'vf1aaaaa555777999_res_state', - 'unit_of_measurement': None, - }), - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': , - 'domain': 'sensor', - 'entity_category': None, - 'entity_id': 'sensor.reg_number_remote_engine_start_code', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': 'Remote engine start code', - 'platform': 'renault', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'res_state_code', - 'unique_id': 'vf1aaaaa555777999_res_state_code', - 'unit_of_measurement': None, - }), ]) # --- # name: test_sensors[zoe_40].2 @@ -4506,28 +4356,6 @@ 'last_updated': , 'state': 'unknown', }), - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': 'REG-NUMBER Remote engine start', - }), - 'context': , - 'entity_id': 'sensor.reg_number_remote_engine_start', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'unknown', - }), - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': 'REG-NUMBER Remote engine start code', - }), - 'context': , - 'entity_id': 'sensor.reg_number_remote_engine_start_code', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'unknown', - }), ]) # --- # name: test_sensors[zoe_50] diff --git a/tests/components/renault/test_sensor.py b/tests/components/renault/test_sensor.py index 6d71d2e6412..45ecc46335e 100644 --- a/tests/components/renault/test_sensor.py +++ b/tests/components/renault/test_sensor.py @@ -253,9 +253,9 @@ async def test_sensor_throttling_after_init( @pytest.mark.parametrize( ("vehicle_type", "vehicle_count", "scan_interval"), [ - ("zoe_40", 1, 300), # 5 coordinators => 5 minutes interval + ("zoe_50", 1, 420), # 7 coordinators => 7 minutes interval ("captur_fuel", 1, 240), # 4 coordinators => 4 minutes interval - ("multi", 2, 540), # 9 coordinators => 9 minutes interval + ("multi", 2, 480), # 8 coordinators => 8 minutes interval ], indirect=["vehicle_type"], ) @@ -292,9 +292,9 @@ async def test_dynamic_scan_interval( @pytest.mark.parametrize( ("vehicle_type", "vehicle_count", "scan_interval"), [ - ("zoe_40", 1, 240), # (5-1) coordinators => 4 minutes interval + ("zoe_50", 1, 300), # (7-2) coordinators => 5 minutes interval ("captur_fuel", 1, 180), # (4-1) coordinators => 3 minutes interval - ("multi", 2, 420), # (9-2) coordinators => 7 minutes interval + ("multi", 2, 360), # (8-2) coordinators => 6 minutes interval ], indirect=["vehicle_type"], ) diff --git a/tests/components/renault/test_services.py b/tests/components/renault/test_services.py index 1aa31768004..11bdc6bc5b7 100644 --- a/tests/components/renault/test_services.py +++ b/tests/components/renault/test_services.py @@ -159,11 +159,12 @@ async def test_service_set_charge_schedule( } with ( + patch("renault_api.renault_vehicle.RenaultVehicle.get_full_endpoint"), patch( - "renault_api.renault_vehicle.RenaultVehicle.get_charging_settings", - return_value=schemas.KamereonVehicleDataResponseSchema.loads( + "renault_api.renault_vehicle.RenaultVehicle.http_get", + return_value=schemas.KamereonResponseSchema.loads( load_fixture("renault/charging_settings.json") - ).get_attributes(schemas.KamereonVehicleChargingSettingsDataSchema), + ), ), patch( "renault_api.renault_vehicle.RenaultVehicle.set_charge_schedules", @@ -208,11 +209,12 @@ async def test_service_set_charge_schedule_multi( } with ( + patch("renault_api.renault_vehicle.RenaultVehicle.get_full_endpoint"), patch( - "renault_api.renault_vehicle.RenaultVehicle.get_charging_settings", - return_value=schemas.KamereonVehicleDataResponseSchema.loads( + "renault_api.renault_vehicle.RenaultVehicle.http_get", + return_value=schemas.KamereonResponseSchema.loads( load_fixture("renault/charging_settings.json") - ).get_attributes(schemas.KamereonVehicleChargingSettingsDataSchema), + ), ), patch( "renault_api.renault_vehicle.RenaultVehicle.set_charge_schedules",