Skip to content

Commit

Permalink
Fix issue clearing renault schedules (#105719)
Browse files Browse the repository at this point in the history
* Fix issue clearing renault schedules

* Adjust
  • Loading branch information
epenet committed Dec 14, 2023
1 parent 9095027 commit 351b07b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/renault/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
16 changes: 9 additions & 7 deletions homeassistant/components/renault/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2348,7 +2348,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.7.1
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,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.7.1
Expand Down
22 changes: 15 additions & 7 deletions tests/components/renault/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 351b07b

Please sign in to comment.