diff --git a/bimmer_connected/tests/test_remote_services.py b/bimmer_connected/tests/test_remote_services.py index 65676219..fd489bcc 100644 --- a/bimmer_connected/tests/test_remote_services.py +++ b/bimmer_connected/tests/test_remote_services.py @@ -207,7 +207,7 @@ async def test_set_charging_settings(bmw_fixture: respx.Router): @pytest.mark.asyncio -async def test_set_charging_profile(bmw_fixture: respx.Router): +async def test_set_charging_profile(bmw_fixture: respx.Router, monkeypatch: pytest.MonkeyPatch): """Test setting the charging profile on a car.""" account = await prepare_account_with_vehicles() @@ -238,6 +238,11 @@ async def test_set_charging_profile(bmw_fixture: respx.Router): await vehicle.remote_services.trigger_charging_profile_update(precondition_climate=True) assert vehicle.charging_profile.is_pre_entry_climatization_enabled is True + # test with an unknown charging mode + monkeypatch.setattr(vehicle.charging_profile, "charging_mode", ChargingMode.UNKNOWN) + await vehicle.remote_services.trigger_charging_profile_update(charging_mode=ChargingMode.IMMEDIATE_CHARGING) + assert vehicle.charging_profile.charging_mode == ChargingMode.IMMEDIATE_CHARGING + @pytest.mark.asyncio async def test_vehicles_without_enabled_services(bmw_fixture: respx.Router): diff --git a/bimmer_connected/vehicle/charging_profile.py b/bimmer_connected/vehicle/charging_profile.py index 3c128cd6..27458cce 100644 --- a/bimmer_connected/vehicle/charging_profile.py +++ b/bimmer_connected/vehicle/charging_profile.py @@ -16,12 +16,15 @@ class ChargingMode(StrEnum): IMMEDIATE_CHARGING = "IMMEDIATE_CHARGING" DELAYED_CHARGING = "DELAYED_CHARGING" + NO_ACTION = "NO_ACTION" UNKNOWN = "UNKNOWN" MAP_CHARGING_MODE_TO_REMOTE_SERVICE = { ChargingMode.IMMEDIATE_CHARGING: "CHARGING_IMMEDIATELY", ChargingMode.DELAYED_CHARGING: "TIME_SLOT", + ChargingMode.NO_ACTION: "NO_ACTION", + ChargingMode.UNKNOWN: "NO_ACTION", }