From 25bfe7ec82025dd0598d8252927182539dfd3a5e Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 14 Dec 2023 12:54:03 +0100 Subject: [PATCH] Fix issue clearing renault schedules (#105719) * Fix issue clearing renault schedules * Adjust --- .../components/renault/manifest.json | 2 +- homeassistant/components/renault/services.py | 16 ++++++++------ requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/renault/test_services.py | 22 +++++++++++++------ 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/renault/manifest.json b/homeassistant/components/renault/manifest.json index e5470259aa42ac..98e1c8b1e7c811 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": "platinum", - "requirements": ["renault-api==0.2.0"] + "requirements": ["renault-api==0.2.1"] } diff --git a/homeassistant/components/renault/services.py b/homeassistant/components/renault/services.py index d25b73cafc27c7..d2c7d45184479d 100644 --- a/homeassistant/components/renault/services.py +++ b/homeassistant/components/renault/services.py @@ -43,13 +43,15 @@ { vol.Required("id"): cv.positive_int, vol.Optional("activated"): cv.boolean, - vol.Optional("monday"): vol.Schema(SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), - vol.Optional("tuesday"): vol.Schema(SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), - vol.Optional("wednesday"): vol.Schema(SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), - vol.Optional("thursday"): vol.Schema(SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), - vol.Optional("friday"): vol.Schema(SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), - vol.Optional("saturday"): vol.Schema(SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), - vol.Optional("sunday"): vol.Schema(SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), + vol.Optional("monday"): vol.Any(None, SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), + vol.Optional("tuesday"): vol.Any(None, SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), + vol.Optional("wednesday"): vol.Any( + None, SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA + ), + vol.Optional("thursday"): vol.Any(None, SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), + vol.Optional("friday"): vol.Any(None, SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), + vol.Optional("saturday"): vol.Any(None, SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), + vol.Optional("sunday"): vol.Any(None, SERVICE_CHARGE_SET_SCHEDULE_DAY_SCHEMA), } ) SERVICE_CHARGE_SET_SCHEDULES_SCHEMA = SERVICE_VEHICLE_SCHEMA.extend( diff --git a/requirements_all.txt b/requirements_all.txt index cbd2bdbf87bde0..eb5034fdfd048b 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2332,7 +2332,7 @@ raspyrfm-client==1.2.8 regenmaschine==2023.06.0 # homeassistant.components.renault -renault-api==0.2.0 +renault-api==0.2.1 # homeassistant.components.renson renson-endura-delta==1.6.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index d62114a8f6e0d9..593bea301cffe9 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1744,7 +1744,7 @@ rapt-ble==0.1.2 regenmaschine==2023.06.0 # homeassistant.components.renault -renault-api==0.2.0 +renault-api==0.2.1 # homeassistant.components.renson renson-endura-delta==1.6.0 diff --git a/tests/components/renault/test_services.py b/tests/components/renault/test_services.py index 58d51eca537155..7f5cb9a81846ad 100644 --- a/tests/components/renault/test_services.py +++ b/tests/components/renault/test_services.py @@ -203,13 +203,12 @@ async def test_service_set_charge_schedule_multi( { "id": 2, "activated": True, - "monday": {"startTime": "T12:00Z", "duration": 15}, - "tuesday": {"startTime": "T12:00Z", "duration": 15}, - "wednesday": {"startTime": "T12:00Z", "duration": 15}, - "thursday": {"startTime": "T12:00Z", "duration": 15}, - "friday": {"startTime": "T12:00Z", "duration": 15}, - "saturday": {"startTime": "T12:00Z", "duration": 15}, - "sunday": {"startTime": "T12:00Z", "duration": 15}, + "monday": {"startTime": "T12:00Z", "duration": 30}, + "tuesday": {"startTime": "T12:00Z", "duration": 30}, + "wednesday": None, + "friday": {"startTime": "T12:00Z", "duration": 30}, + "saturday": {"startTime": "T12:00Z", "duration": 30}, + "sunday": {"startTime": "T12:00Z", "duration": 30}, }, {"id": 3}, ] @@ -238,6 +237,15 @@ async def test_service_set_charge_schedule_multi( mock_call_data: list[ChargeSchedule] = mock_action.mock_calls[0][1][0] assert mock_action.mock_calls[0][1] == (mock_call_data,) + # Monday updated with new values + assert mock_call_data[1].monday.startTime == "T12:00Z" + assert mock_call_data[1].monday.duration == 30 + # Wednesday has original values cleared + assert mock_call_data[1].wednesday is None + # Thursday keeps original values + assert mock_call_data[1].thursday.startTime == "T23:30Z" + assert mock_call_data[1].thursday.duration == 15 + async def test_service_invalid_device_id( hass: HomeAssistant, config_entry: ConfigEntry