mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Refactor & enhance BMW tests (#97895)
Co-authored-by: rikroe <rikroe@users.noreply.github.com>
This commit is contained in:
parent
9ef3ec3dd3
commit
021b14fc17
@ -1,16 +1,7 @@
|
|||||||
"""Tests for the for the BMW Connected Drive integration."""
|
"""Tests for the for the BMW Connected Drive integration."""
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
|
|
||||||
from bimmer_connected.api.authentication import MyBMWAuthentication
|
from bimmer_connected.const import REMOTE_SERVICE_BASE_URL, VEHICLE_CHARGING_BASE_URL
|
||||||
from bimmer_connected.const import (
|
|
||||||
REMOTE_SERVICE_POSITION_URL,
|
|
||||||
VEHICLE_CHARGING_DETAILS_URL,
|
|
||||||
VEHICLE_STATE_URL,
|
|
||||||
VEHICLES_URL,
|
|
||||||
)
|
|
||||||
import httpx
|
|
||||||
import respx
|
import respx
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
@ -23,12 +14,7 @@ from homeassistant.components.bmw_connected_drive.const import (
|
|||||||
from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import MockConfigEntry
|
||||||
MockConfigEntry,
|
|
||||||
get_fixture_path,
|
|
||||||
load_json_array_fixture,
|
|
||||||
load_json_object_fixture,
|
|
||||||
)
|
|
||||||
|
|
||||||
FIXTURE_USER_INPUT = {
|
FIXTURE_USER_INPUT = {
|
||||||
CONF_USERNAME: "user@domain.com",
|
CONF_USERNAME: "user@domain.com",
|
||||||
@ -54,88 +40,6 @@ FIXTURE_CONFIG_ENTRY = {
|
|||||||
"unique_id": f"{FIXTURE_USER_INPUT[CONF_REGION]}-{FIXTURE_USER_INPUT[CONF_REGION]}",
|
"unique_id": f"{FIXTURE_USER_INPUT[CONF_REGION]}-{FIXTURE_USER_INPUT[CONF_REGION]}",
|
||||||
}
|
}
|
||||||
|
|
||||||
FIXTURE_PATH = Path(get_fixture_path("", integration=BMW_DOMAIN))
|
|
||||||
FIXTURE_FILES = {
|
|
||||||
"vehicles": sorted(FIXTURE_PATH.rglob("*-eadrax-vcs_v4_vehicles.json")),
|
|
||||||
"states": {
|
|
||||||
p.stem.split("_")[-1]: p
|
|
||||||
for p in FIXTURE_PATH.rglob("*-eadrax-vcs_v4_vehicles_state_*.json")
|
|
||||||
},
|
|
||||||
"charging": {
|
|
||||||
p.stem.split("_")[-1]: p
|
|
||||||
for p in FIXTURE_PATH.rglob("*-eadrax-crccs_v2_vehicles_*.json")
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def vehicles_sideeffect(request: httpx.Request) -> httpx.Response:
|
|
||||||
"""Return /vehicles response based on x-user-agent."""
|
|
||||||
x_user_agent = request.headers.get("x-user-agent", "").split(";")
|
|
||||||
brand = x_user_agent[1]
|
|
||||||
vehicles = []
|
|
||||||
for vehicle_file in FIXTURE_FILES["vehicles"]:
|
|
||||||
if vehicle_file.name.startswith(brand):
|
|
||||||
vehicles.extend(
|
|
||||||
load_json_array_fixture(vehicle_file, integration=BMW_DOMAIN)
|
|
||||||
)
|
|
||||||
return httpx.Response(200, json=vehicles)
|
|
||||||
|
|
||||||
|
|
||||||
def vehicle_state_sideeffect(request: httpx.Request) -> httpx.Response:
|
|
||||||
"""Return /vehicles/state response."""
|
|
||||||
try:
|
|
||||||
state_file = FIXTURE_FILES["states"][request.headers["bmw-vin"]]
|
|
||||||
return httpx.Response(
|
|
||||||
200, json=load_json_object_fixture(state_file, integration=BMW_DOMAIN)
|
|
||||||
)
|
|
||||||
except KeyError:
|
|
||||||
return httpx.Response(404)
|
|
||||||
|
|
||||||
|
|
||||||
def vehicle_charging_sideeffect(request: httpx.Request) -> httpx.Response:
|
|
||||||
"""Return /vehicles/state response."""
|
|
||||||
try:
|
|
||||||
charging_file = FIXTURE_FILES["charging"][request.headers["bmw-vin"]]
|
|
||||||
return httpx.Response(
|
|
||||||
200, json=load_json_object_fixture(charging_file, integration=BMW_DOMAIN)
|
|
||||||
)
|
|
||||||
except KeyError:
|
|
||||||
return httpx.Response(404)
|
|
||||||
|
|
||||||
|
|
||||||
def mock_vehicles() -> respx.Router:
|
|
||||||
"""Return mocked adapter for vehicles."""
|
|
||||||
router = respx.mock(assert_all_called=False)
|
|
||||||
|
|
||||||
# Get vehicle list
|
|
||||||
router.get(VEHICLES_URL).mock(side_effect=vehicles_sideeffect)
|
|
||||||
|
|
||||||
# Get vehicle state
|
|
||||||
router.get(VEHICLE_STATE_URL).mock(side_effect=vehicle_state_sideeffect)
|
|
||||||
|
|
||||||
# Get vehicle charging details
|
|
||||||
router.get(VEHICLE_CHARGING_DETAILS_URL).mock(
|
|
||||||
side_effect=vehicle_charging_sideeffect
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get vehicle position after remote service
|
|
||||||
router.post(urlparse(REMOTE_SERVICE_POSITION_URL).netloc).mock(
|
|
||||||
httpx.Response(
|
|
||||||
200,
|
|
||||||
json=load_json_object_fixture(
|
|
||||||
FIXTURE_PATH / "remote_service" / "eventposition.json",
|
|
||||||
integration=BMW_DOMAIN,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return router
|
|
||||||
|
|
||||||
|
|
||||||
async def mock_login(auth: MyBMWAuthentication) -> None:
|
|
||||||
"""Mock a successful login."""
|
|
||||||
auth.access_token = "SOME_ACCESS_TOKEN"
|
|
||||||
|
|
||||||
|
|
||||||
async def setup_mocked_integration(hass: HomeAssistant) -> MockConfigEntry:
|
async def setup_mocked_integration(hass: HomeAssistant) -> MockConfigEntry:
|
||||||
"""Mock a fully setup config entry and all components based on fixtures."""
|
"""Mock a fully setup config entry and all components based on fixtures."""
|
||||||
@ -147,3 +51,52 @@ async def setup_mocked_integration(hass: HomeAssistant) -> MockConfigEntry:
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
return mock_config_entry
|
return mock_config_entry
|
||||||
|
|
||||||
|
|
||||||
|
def check_remote_service_call(
|
||||||
|
router: respx.MockRouter,
|
||||||
|
remote_service: str = None,
|
||||||
|
remote_service_params: dict = None,
|
||||||
|
remote_service_payload: dict = None,
|
||||||
|
):
|
||||||
|
"""Check if the last call was a successful remote service call."""
|
||||||
|
|
||||||
|
# Check if remote service call was made correctly
|
||||||
|
if remote_service:
|
||||||
|
# Get remote service call
|
||||||
|
first_remote_service_call: respx.models.Call = next(
|
||||||
|
c
|
||||||
|
for c in router.calls
|
||||||
|
if c.request.url.path.startswith(REMOTE_SERVICE_BASE_URL)
|
||||||
|
or c.request.url.path.startswith(
|
||||||
|
VEHICLE_CHARGING_BASE_URL.replace("/{vin}", "")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
first_remote_service_call.request.url.path.endswith(remote_service) is True
|
||||||
|
)
|
||||||
|
assert first_remote_service_call.has_response is True
|
||||||
|
assert first_remote_service_call.response.is_success is True
|
||||||
|
|
||||||
|
# test params.
|
||||||
|
# we don't test payload as this creates a lot of noise in the tests
|
||||||
|
# and is end-to-end tested with the HA states
|
||||||
|
if remote_service_params:
|
||||||
|
assert (
|
||||||
|
dict(first_remote_service_call.request.url.params.items())
|
||||||
|
== remote_service_params
|
||||||
|
)
|
||||||
|
|
||||||
|
# Now check final result
|
||||||
|
last_event_status_call = next(
|
||||||
|
c for c in reversed(router.calls) if c.request.url.path.endswith("eventStatus")
|
||||||
|
)
|
||||||
|
|
||||||
|
assert last_event_status_call is not None
|
||||||
|
assert (
|
||||||
|
last_event_status_call.request.url.path
|
||||||
|
== "/eadrax-vrccs/v3/presentation/remote-commands/eventStatus"
|
||||||
|
)
|
||||||
|
assert last_event_status_call.has_response is True
|
||||||
|
assert last_event_status_call.response.is_success is True
|
||||||
|
assert last_event_status_call.response.json() == {"eventStatus": "EXECUTED"}
|
||||||
|
@ -1,34 +1,39 @@
|
|||||||
"""Fixtures for BMW tests."""
|
"""Fixtures for BMW tests."""
|
||||||
|
|
||||||
from unittest.mock import AsyncMock, Mock
|
|
||||||
|
|
||||||
from bimmer_connected.api.authentication import MyBMWAuthentication
|
from collections.abc import Generator
|
||||||
from bimmer_connected.vehicle.remote_services import RemoteServices, RemoteServiceStatus
|
|
||||||
|
from bimmer_connected.tests import ALL_CHARGING_SETTINGS, ALL_STATES
|
||||||
|
from bimmer_connected.tests.common import MyBMWMockRouter
|
||||||
|
from bimmer_connected.vehicle import remote_services
|
||||||
import pytest
|
import pytest
|
||||||
|
import respx
|
||||||
from homeassistant.components.bmw_connected_drive.coordinator import (
|
|
||||||
BMWDataUpdateCoordinator,
|
|
||||||
)
|
|
||||||
|
|
||||||
from . import mock_login, mock_vehicles
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def bmw_fixture(monkeypatch):
|
def bmw_fixture(
|
||||||
"""Patch the MyBMW Login and mock HTTP calls."""
|
request: pytest.FixtureRequest, monkeypatch: pytest.MonkeyPatch
|
||||||
monkeypatch.setattr(MyBMWAuthentication, "login", mock_login)
|
) -> Generator[respx.MockRouter, None, None]:
|
||||||
|
"""Patch MyBMW login API calls."""
|
||||||
|
|
||||||
monkeypatch.setattr(
|
# we use the library's mock router to mock the API calls, but only with a subset of vehicles
|
||||||
RemoteServices,
|
router = MyBMWMockRouter(
|
||||||
"trigger_remote_service",
|
vehicles_to_load=[
|
||||||
AsyncMock(return_value=RemoteServiceStatus({"eventStatus": "EXECUTED"})),
|
"WBA00000000DEMO01",
|
||||||
|
"WBA00000000DEMO02",
|
||||||
|
"WBA00000000DEMO03",
|
||||||
|
"WBY00000000REXI01",
|
||||||
|
],
|
||||||
|
states=ALL_STATES,
|
||||||
|
charging_settings=ALL_CHARGING_SETTINGS,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# we don't want to wait when triggering a remote service
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
BMWDataUpdateCoordinator,
|
remote_services,
|
||||||
"async_update_listeners",
|
"_POLLING_CYCLE",
|
||||||
Mock(),
|
0,
|
||||||
)
|
)
|
||||||
|
|
||||||
with mock_vehicles():
|
with router:
|
||||||
yield mock_vehicles
|
yield router
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"positionData": {
|
|
||||||
"status": "OK",
|
|
||||||
"position": {
|
|
||||||
"latitude": 123.456,
|
|
||||||
"longitude": 34.5678,
|
|
||||||
"formattedAddress": "some_formatted_address",
|
|
||||||
"heading": 121
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"errorDetails": null
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
{
|
|
||||||
"chargeAndClimateSettings": {
|
|
||||||
"chargeAndClimateTimer": {
|
|
||||||
"chargingMode": "Sofort laden",
|
|
||||||
"chargingModeSemantics": "Sofort laden",
|
|
||||||
"departureTimer": ["Aus"],
|
|
||||||
"departureTimerSemantics": "Aus",
|
|
||||||
"preconditionForDeparture": "Aus",
|
|
||||||
"showDepartureTimers": false
|
|
||||||
},
|
|
||||||
"chargingFlap": {
|
|
||||||
"permanentlyUnlockLabel": "Aus"
|
|
||||||
},
|
|
||||||
"chargingSettings": {
|
|
||||||
"acCurrentLimitLabel": "16A",
|
|
||||||
"acCurrentLimitLabelSemantics": "16 Ampere",
|
|
||||||
"chargingTargetLabel": "80%",
|
|
||||||
"dcLoudnessLabel": "Nicht begrenzt",
|
|
||||||
"unlockCableAutomaticallyLabel": "Aus"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"chargeAndClimateTimerDetail": {
|
|
||||||
"chargingMode": {
|
|
||||||
"chargingPreference": "NO_PRESELECTION",
|
|
||||||
"endTimeSlot": "0001-01-01T00:00:00",
|
|
||||||
"startTimeSlot": "0001-01-01T00:00:00",
|
|
||||||
"type": "CHARGING_IMMEDIATELY"
|
|
||||||
},
|
|
||||||
"departureTimer": {
|
|
||||||
"type": "WEEKLY_DEPARTURE_TIMER",
|
|
||||||
"weeklyTimers": [
|
|
||||||
{
|
|
||||||
"daysOfTheWeek": [],
|
|
||||||
"id": 1,
|
|
||||||
"time": "0001-01-01T00:00:00",
|
|
||||||
"timerAction": "DEACTIVATE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"daysOfTheWeek": [],
|
|
||||||
"id": 2,
|
|
||||||
"time": "0001-01-01T00:00:00",
|
|
||||||
"timerAction": "DEACTIVATE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"daysOfTheWeek": [],
|
|
||||||
"id": 3,
|
|
||||||
"time": "0001-01-01T00:00:00",
|
|
||||||
"timerAction": "DEACTIVATE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"daysOfTheWeek": [],
|
|
||||||
"id": 4,
|
|
||||||
"time": "0001-01-01T00:00:00",
|
|
||||||
"timerAction": "DEACTIVATE"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"isPreconditionForDepartureActive": false
|
|
||||||
},
|
|
||||||
"chargingFlapDetail": {
|
|
||||||
"isPermanentlyUnlock": false
|
|
||||||
},
|
|
||||||
"chargingSettingsDetail": {
|
|
||||||
"acLimit": {
|
|
||||||
"current": {
|
|
||||||
"unit": "A",
|
|
||||||
"value": 16
|
|
||||||
},
|
|
||||||
"isUnlimited": false,
|
|
||||||
"max": 32,
|
|
||||||
"min": 6,
|
|
||||||
"values": [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 32]
|
|
||||||
},
|
|
||||||
"chargingTarget": 80,
|
|
||||||
"dcLoudness": "UNLIMITED_LOUD",
|
|
||||||
"isUnlockCableActive": false,
|
|
||||||
"minChargingTargetToWarning": 0
|
|
||||||
},
|
|
||||||
"servicePack": "WAVE_01"
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"appVehicleType": "DEMO",
|
|
||||||
"attributes": {
|
|
||||||
"a4aType": "NOT_SUPPORTED",
|
|
||||||
"bodyType": "G26",
|
|
||||||
"brand": "BMW",
|
|
||||||
"color": 4284245350,
|
|
||||||
"countryOfOrigin": "DE",
|
|
||||||
"driveTrain": "ELECTRIC",
|
|
||||||
"driverGuideInfo": {
|
|
||||||
"androidAppScheme": "com.bmwgroup.driversguide.row",
|
|
||||||
"androidStoreUrl": "https://play.google.com/store/apps/details?id=com.bmwgroup.driversguide.row",
|
|
||||||
"iosAppScheme": "bmwdriversguide:///open",
|
|
||||||
"iosStoreUrl": "https://apps.apple.com/de/app/id714042749?mt=8"
|
|
||||||
},
|
|
||||||
"headUnitRaw": "HU_MGU",
|
|
||||||
"headUnitType": "MGU",
|
|
||||||
"hmiVersion": "ID8",
|
|
||||||
"lastFetched": "2023-01-04T14:57:06.019Z",
|
|
||||||
"model": "i4 eDrive40",
|
|
||||||
"softwareVersionCurrent": {
|
|
||||||
"iStep": 470,
|
|
||||||
"puStep": {
|
|
||||||
"month": 11,
|
|
||||||
"year": 21
|
|
||||||
},
|
|
||||||
"seriesCluster": "G026"
|
|
||||||
},
|
|
||||||
"softwareVersionExFactory": {
|
|
||||||
"iStep": 470,
|
|
||||||
"puStep": {
|
|
||||||
"month": 11,
|
|
||||||
"year": 21
|
|
||||||
},
|
|
||||||
"seriesCluster": "G026"
|
|
||||||
},
|
|
||||||
"telematicsUnit": "WAVE01",
|
|
||||||
"year": 2021
|
|
||||||
},
|
|
||||||
"mappingInfo": {
|
|
||||||
"isAssociated": false,
|
|
||||||
"isLmmEnabled": false,
|
|
||||||
"isPrimaryUser": true,
|
|
||||||
"lmmStatusReasons": [],
|
|
||||||
"mappingStatus": "CONFIRMED"
|
|
||||||
},
|
|
||||||
"vin": "WBA00000000DEMO02"
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,317 +0,0 @@
|
|||||||
{
|
|
||||||
"capabilities": {
|
|
||||||
"a4aType": "NOT_SUPPORTED",
|
|
||||||
"checkSustainabilityDPP": false,
|
|
||||||
"climateFunction": "AIR_CONDITIONING",
|
|
||||||
"climateNow": true,
|
|
||||||
"digitalKey": {
|
|
||||||
"bookedServicePackage": "SMACC_1_5",
|
|
||||||
"readerGraphics": "readerGraphics",
|
|
||||||
"state": "ACTIVATED"
|
|
||||||
},
|
|
||||||
"horn": true,
|
|
||||||
"isBmwChargingSupported": true,
|
|
||||||
"isCarSharingSupported": false,
|
|
||||||
"isChargeNowForBusinessSupported": true,
|
|
||||||
"isChargingHistorySupported": true,
|
|
||||||
"isChargingHospitalityEnabled": true,
|
|
||||||
"isChargingLoudnessEnabled": true,
|
|
||||||
"isChargingPlanSupported": true,
|
|
||||||
"isChargingPowerLimitEnabled": true,
|
|
||||||
"isChargingSettingsEnabled": true,
|
|
||||||
"isChargingTargetSocEnabled": true,
|
|
||||||
"isClimateTimerWeeklyActive": false,
|
|
||||||
"isCustomerEsimSupported": true,
|
|
||||||
"isDCSContractManagementSupported": true,
|
|
||||||
"isDataPrivacyEnabled": false,
|
|
||||||
"isEasyChargeEnabled": true,
|
|
||||||
"isEvGoChargingSupported": false,
|
|
||||||
"isMiniChargingSupported": false,
|
|
||||||
"isNonLscFeatureEnabled": false,
|
|
||||||
"isPersonalPictureUploadSupported": false,
|
|
||||||
"isRemoteEngineStartSupported": false,
|
|
||||||
"isRemoteHistoryDeletionSupported": false,
|
|
||||||
"isRemoteHistorySupported": true,
|
|
||||||
"isRemoteParkingSupported": false,
|
|
||||||
"isRemoteServicesActivationRequired": false,
|
|
||||||
"isRemoteServicesBookingRequired": false,
|
|
||||||
"isScanAndChargeSupported": true,
|
|
||||||
"isSustainabilityAccumulatedViewEnabled": false,
|
|
||||||
"isSustainabilitySupported": false,
|
|
||||||
"isWifiHotspotServiceSupported": false,
|
|
||||||
"lastStateCallState": "ACTIVATED",
|
|
||||||
"lights": true,
|
|
||||||
"lock": true,
|
|
||||||
"remote360": true,
|
|
||||||
"remoteChargingCommands": {
|
|
||||||
"chargingControl": ["START", "STOP"],
|
|
||||||
"flapControl": ["NOT_SUPPORTED"],
|
|
||||||
"plugControl": ["NOT_SUPPORTED"]
|
|
||||||
},
|
|
||||||
"remoteSoftwareUpgrade": true,
|
|
||||||
"sendPoi": true,
|
|
||||||
"specialThemeSupport": [],
|
|
||||||
"speechThirdPartyAlexa": false,
|
|
||||||
"speechThirdPartyAlexaSDK": false,
|
|
||||||
"unlock": true,
|
|
||||||
"vehicleFinder": true,
|
|
||||||
"vehicleStateSource": "LAST_STATE_CALL"
|
|
||||||
},
|
|
||||||
"state": {
|
|
||||||
"chargingProfile": {
|
|
||||||
"chargingControlType": "WEEKLY_PLANNER",
|
|
||||||
"chargingMode": "IMMEDIATE_CHARGING",
|
|
||||||
"chargingPreference": "NO_PRESELECTION",
|
|
||||||
"chargingSettings": {
|
|
||||||
"acCurrentLimit": 16,
|
|
||||||
"hospitality": "NO_ACTION",
|
|
||||||
"idcc": "UNLIMITED_LOUD",
|
|
||||||
"targetSoc": 80
|
|
||||||
},
|
|
||||||
"departureTimes": [
|
|
||||||
{
|
|
||||||
"action": "DEACTIVATE",
|
|
||||||
"id": 1,
|
|
||||||
"timeStamp": {
|
|
||||||
"hour": 0,
|
|
||||||
"minute": 0
|
|
||||||
},
|
|
||||||
"timerWeekDays": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"action": "DEACTIVATE",
|
|
||||||
"id": 2,
|
|
||||||
"timeStamp": {
|
|
||||||
"hour": 0,
|
|
||||||
"minute": 0
|
|
||||||
},
|
|
||||||
"timerWeekDays": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"action": "DEACTIVATE",
|
|
||||||
"id": 3,
|
|
||||||
"timeStamp": {
|
|
||||||
"hour": 0,
|
|
||||||
"minute": 0
|
|
||||||
},
|
|
||||||
"timerWeekDays": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"action": "DEACTIVATE",
|
|
||||||
"id": 4,
|
|
||||||
"timeStamp": {
|
|
||||||
"hour": 0,
|
|
||||||
"minute": 0
|
|
||||||
},
|
|
||||||
"timerWeekDays": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"checkControlMessages": [
|
|
||||||
{
|
|
||||||
"severity": "LOW",
|
|
||||||
"type": "TIRE_PRESSURE"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"climateControlState": {
|
|
||||||
"activity": "STANDBY"
|
|
||||||
},
|
|
||||||
"climateTimers": [
|
|
||||||
{
|
|
||||||
"departureTime": {
|
|
||||||
"hour": 0,
|
|
||||||
"minute": 0
|
|
||||||
},
|
|
||||||
"isWeeklyTimer": false,
|
|
||||||
"timerAction": "DEACTIVATE",
|
|
||||||
"timerWeekDays": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"departureTime": {
|
|
||||||
"hour": 0,
|
|
||||||
"minute": 0
|
|
||||||
},
|
|
||||||
"isWeeklyTimer": true,
|
|
||||||
"timerAction": "DEACTIVATE",
|
|
||||||
"timerWeekDays": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"departureTime": {
|
|
||||||
"hour": 0,
|
|
||||||
"minute": 0
|
|
||||||
},
|
|
||||||
"isWeeklyTimer": true,
|
|
||||||
"timerAction": "DEACTIVATE",
|
|
||||||
"timerWeekDays": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"combustionFuelLevel": {},
|
|
||||||
"currentMileage": 1121,
|
|
||||||
"doorsState": {
|
|
||||||
"combinedSecurityState": "LOCKED",
|
|
||||||
"combinedState": "CLOSED",
|
|
||||||
"hood": "CLOSED",
|
|
||||||
"leftFront": "CLOSED",
|
|
||||||
"leftRear": "CLOSED",
|
|
||||||
"rightFront": "CLOSED",
|
|
||||||
"rightRear": "CLOSED",
|
|
||||||
"trunk": "CLOSED"
|
|
||||||
},
|
|
||||||
"driverPreferences": {
|
|
||||||
"lscPrivacyMode": "OFF"
|
|
||||||
},
|
|
||||||
"electricChargingState": {
|
|
||||||
"chargingConnectionType": "UNKNOWN",
|
|
||||||
"chargingLevelPercent": 80,
|
|
||||||
"chargingStatus": "CHARGING",
|
|
||||||
"chargingTarget": 80,
|
|
||||||
"isChargerConnected": true,
|
|
||||||
"range": 472,
|
|
||||||
"remainingChargingMinutes": 10
|
|
||||||
},
|
|
||||||
"isLeftSteering": true,
|
|
||||||
"isLscSupported": true,
|
|
||||||
"lastFetched": "2023-01-04T14:57:06.386Z",
|
|
||||||
"lastUpdatedAt": "2023-01-04T14:57:06.407Z",
|
|
||||||
"location": {
|
|
||||||
"address": {
|
|
||||||
"formatted": "Am Olympiapark 1, 80809 München"
|
|
||||||
},
|
|
||||||
"coordinates": {
|
|
||||||
"latitude": 48.177334,
|
|
||||||
"longitude": 11.556274
|
|
||||||
},
|
|
||||||
"heading": 180
|
|
||||||
},
|
|
||||||
"range": 472,
|
|
||||||
"requiredServices": [
|
|
||||||
{
|
|
||||||
"dateTime": "2024-12-01T00:00:00.000Z",
|
|
||||||
"description": "",
|
|
||||||
"mileage": 50000,
|
|
||||||
"status": "OK",
|
|
||||||
"type": "BRAKE_FLUID"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"dateTime": "2024-12-01T00:00:00.000Z",
|
|
||||||
"description": "",
|
|
||||||
"mileage": 50000,
|
|
||||||
"status": "OK",
|
|
||||||
"type": "VEHICLE_TUV"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"dateTime": "2024-12-01T00:00:00.000Z",
|
|
||||||
"description": "",
|
|
||||||
"mileage": 50000,
|
|
||||||
"status": "OK",
|
|
||||||
"type": "VEHICLE_CHECK"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"status": "OK",
|
|
||||||
"type": "TIRE_WEAR_REAR"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"status": "OK",
|
|
||||||
"type": "TIRE_WEAR_FRONT"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tireState": {
|
|
||||||
"frontLeft": {
|
|
||||||
"details": {
|
|
||||||
"dimension": "225/35 R20 90Y XL",
|
|
||||||
"isOptimizedForOemBmw": true,
|
|
||||||
"manufacturer": "Pirelli",
|
|
||||||
"manufacturingWeek": 4021,
|
|
||||||
"mountingDate": "2022-03-07T00:00:00.000Z",
|
|
||||||
"partNumber": "2461756",
|
|
||||||
"season": 2,
|
|
||||||
"speedClassification": {
|
|
||||||
"atLeast": false,
|
|
||||||
"speedRating": 300
|
|
||||||
},
|
|
||||||
"treadDesign": "P-ZERO"
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
"currentPressure": 241,
|
|
||||||
"pressureStatus": 0,
|
|
||||||
"targetPressure": 269,
|
|
||||||
"wearStatus": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"frontRight": {
|
|
||||||
"details": {
|
|
||||||
"dimension": "225/35 R20 90Y XL",
|
|
||||||
"isOptimizedForOemBmw": true,
|
|
||||||
"manufacturer": "Pirelli",
|
|
||||||
"manufacturingWeek": 2419,
|
|
||||||
"mountingDate": "2022-03-07T00:00:00.000Z",
|
|
||||||
"partNumber": "2461756",
|
|
||||||
"season": 2,
|
|
||||||
"speedClassification": {
|
|
||||||
"atLeast": false,
|
|
||||||
"speedRating": 300
|
|
||||||
},
|
|
||||||
"treadDesign": "P-ZERO"
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
"currentPressure": 255,
|
|
||||||
"pressureStatus": 0,
|
|
||||||
"targetPressure": 269,
|
|
||||||
"wearStatus": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"rearLeft": {
|
|
||||||
"details": {
|
|
||||||
"dimension": "255/30 R20 92Y XL",
|
|
||||||
"isOptimizedForOemBmw": true,
|
|
||||||
"manufacturer": "Pirelli",
|
|
||||||
"manufacturingWeek": 1219,
|
|
||||||
"mountingDate": "2022-03-07T00:00:00.000Z",
|
|
||||||
"partNumber": "2461757",
|
|
||||||
"season": 2,
|
|
||||||
"speedClassification": {
|
|
||||||
"atLeast": false,
|
|
||||||
"speedRating": 300
|
|
||||||
},
|
|
||||||
"treadDesign": "P-ZERO"
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
"currentPressure": 324,
|
|
||||||
"pressureStatus": 0,
|
|
||||||
"targetPressure": 303,
|
|
||||||
"wearStatus": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"rearRight": {
|
|
||||||
"details": {
|
|
||||||
"dimension": "255/30 R20 92Y XL",
|
|
||||||
"isOptimizedForOemBmw": true,
|
|
||||||
"manufacturer": "Pirelli",
|
|
||||||
"manufacturingWeek": 1219,
|
|
||||||
"mountingDate": "2022-03-07T00:00:00.000Z",
|
|
||||||
"partNumber": "2461757",
|
|
||||||
"season": 2,
|
|
||||||
"speedClassification": {
|
|
||||||
"atLeast": false,
|
|
||||||
"speedRating": 300
|
|
||||||
},
|
|
||||||
"treadDesign": "P-ZERO"
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
"currentPressure": 331,
|
|
||||||
"pressureStatus": 0,
|
|
||||||
"targetPressure": 303,
|
|
||||||
"wearStatus": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"windowsState": {
|
|
||||||
"combinedState": "CLOSED",
|
|
||||||
"leftFront": "CLOSED",
|
|
||||||
"leftRear": "CLOSED",
|
|
||||||
"rear": "CLOSED",
|
|
||||||
"rightFront": "CLOSED",
|
|
||||||
"rightRear": "CLOSED"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
{
|
|
||||||
"chargeAndClimateSettings": {
|
|
||||||
"chargeAndClimateTimer": {
|
|
||||||
"showDepartureTimers": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"chargeAndClimateTimerDetail": {
|
|
||||||
"chargingMode": {
|
|
||||||
"chargingPreference": "CHARGING_WINDOW",
|
|
||||||
"endTimeSlot": "0001-01-01T01:30:00",
|
|
||||||
"startTimeSlot": "0001-01-01T18:01:00",
|
|
||||||
"type": "TIME_SLOT"
|
|
||||||
},
|
|
||||||
"departureTimer": {
|
|
||||||
"type": "WEEKLY_DEPARTURE_TIMER",
|
|
||||||
"weeklyTimers": [
|
|
||||||
{
|
|
||||||
"daysOfTheWeek": [
|
|
||||||
"MONDAY",
|
|
||||||
"TUESDAY",
|
|
||||||
"WEDNESDAY",
|
|
||||||
"THURSDAY",
|
|
||||||
"FRIDAY"
|
|
||||||
],
|
|
||||||
"id": 1,
|
|
||||||
"time": "0001-01-01T07:35:00",
|
|
||||||
"timerAction": "DEACTIVATE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"daysOfTheWeek": [
|
|
||||||
"MONDAY",
|
|
||||||
"TUESDAY",
|
|
||||||
"WEDNESDAY",
|
|
||||||
"THURSDAY",
|
|
||||||
"FRIDAY",
|
|
||||||
"SATURDAY",
|
|
||||||
"SUNDAY"
|
|
||||||
],
|
|
||||||
"id": 2,
|
|
||||||
"time": "0001-01-01T18:00:00",
|
|
||||||
"timerAction": "DEACTIVATE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"daysOfTheWeek": [],
|
|
||||||
"id": 3,
|
|
||||||
"time": "0001-01-01T07:00:00",
|
|
||||||
"timerAction": "DEACTIVATE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"daysOfTheWeek": [],
|
|
||||||
"id": 4,
|
|
||||||
"time": "0001-01-01T00:00:00",
|
|
||||||
"timerAction": "DEACTIVATE"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"isPreconditionForDepartureActive": false
|
|
||||||
},
|
|
||||||
"servicePack": "TCB1"
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"appVehicleType": "CONNECTED",
|
|
||||||
"attributes": {
|
|
||||||
"a4aType": "USB_ONLY",
|
|
||||||
"bodyType": "I01",
|
|
||||||
"brand": "BMW_I",
|
|
||||||
"color": 4284110934,
|
|
||||||
"countryOfOrigin": "CZ",
|
|
||||||
"driveTrain": "ELECTRIC_WITH_RANGE_EXTENDER",
|
|
||||||
"driverGuideInfo": {
|
|
||||||
"androidAppScheme": "com.bmwgroup.driversguide.row",
|
|
||||||
"androidStoreUrl": "https://play.google.com/store/apps/details?id=com.bmwgroup.driversguide.row",
|
|
||||||
"iosAppScheme": "bmwdriversguide:///open",
|
|
||||||
"iosStoreUrl": "https://apps.apple.com/de/app/id714042749?mt=8"
|
|
||||||
},
|
|
||||||
"headUnitType": "NBT",
|
|
||||||
"hmiVersion": "ID4",
|
|
||||||
"lastFetched": "2022-07-10T09:25:53.104Z",
|
|
||||||
"model": "i3 (+ REX)",
|
|
||||||
"softwareVersionCurrent": {
|
|
||||||
"iStep": 510,
|
|
||||||
"puStep": {
|
|
||||||
"month": 11,
|
|
||||||
"year": 21
|
|
||||||
},
|
|
||||||
"seriesCluster": "I001"
|
|
||||||
},
|
|
||||||
"softwareVersionExFactory": {
|
|
||||||
"iStep": 502,
|
|
||||||
"puStep": {
|
|
||||||
"month": 3,
|
|
||||||
"year": 15
|
|
||||||
},
|
|
||||||
"seriesCluster": "I001"
|
|
||||||
},
|
|
||||||
"year": 2015
|
|
||||||
},
|
|
||||||
"mappingInfo": {
|
|
||||||
"isAssociated": false,
|
|
||||||
"isLmmEnabled": false,
|
|
||||||
"isPrimaryUser": true,
|
|
||||||
"mappingStatus": "CONFIRMED"
|
|
||||||
},
|
|
||||||
"vin": "WBY00000000REXI01"
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,206 +0,0 @@
|
|||||||
{
|
|
||||||
"capabilities": {
|
|
||||||
"climateFunction": "AIR_CONDITIONING",
|
|
||||||
"climateNow": true,
|
|
||||||
"climateTimerTrigger": "DEPARTURE_TIMER",
|
|
||||||
"horn": true,
|
|
||||||
"isBmwChargingSupported": true,
|
|
||||||
"isCarSharingSupported": false,
|
|
||||||
"isChargeNowForBusinessSupported": false,
|
|
||||||
"isChargingHistorySupported": true,
|
|
||||||
"isChargingHospitalityEnabled": false,
|
|
||||||
"isChargingLoudnessEnabled": false,
|
|
||||||
"isChargingPlanSupported": true,
|
|
||||||
"isChargingPowerLimitEnabled": false,
|
|
||||||
"isChargingSettingsEnabled": false,
|
|
||||||
"isChargingTargetSocEnabled": false,
|
|
||||||
"isClimateTimerSupported": true,
|
|
||||||
"isCustomerEsimSupported": false,
|
|
||||||
"isDCSContractManagementSupported": true,
|
|
||||||
"isDataPrivacyEnabled": false,
|
|
||||||
"isEasyChargeEnabled": false,
|
|
||||||
"isEvGoChargingSupported": false,
|
|
||||||
"isMiniChargingSupported": false,
|
|
||||||
"isNonLscFeatureEnabled": false,
|
|
||||||
"isRemoteEngineStartSupported": false,
|
|
||||||
"isRemoteHistoryDeletionSupported": false,
|
|
||||||
"isRemoteHistorySupported": true,
|
|
||||||
"isRemoteParkingSupported": false,
|
|
||||||
"isRemoteServicesActivationRequired": false,
|
|
||||||
"isRemoteServicesBookingRequired": false,
|
|
||||||
"isScanAndChargeSupported": false,
|
|
||||||
"isSustainabilitySupported": false,
|
|
||||||
"isWifiHotspotServiceSupported": false,
|
|
||||||
"lastStateCallState": "ACTIVATED",
|
|
||||||
"lights": true,
|
|
||||||
"lock": true,
|
|
||||||
"remoteChargingCommands": {},
|
|
||||||
"sendPoi": true,
|
|
||||||
"specialThemeSupport": [],
|
|
||||||
"unlock": true,
|
|
||||||
"vehicleFinder": false,
|
|
||||||
"vehicleStateSource": "LAST_STATE_CALL"
|
|
||||||
},
|
|
||||||
"state": {
|
|
||||||
"chargingProfile": {
|
|
||||||
"chargingControlType": "WEEKLY_PLANNER",
|
|
||||||
"chargingMode": "DELAYED_CHARGING",
|
|
||||||
"chargingPreference": "CHARGING_WINDOW",
|
|
||||||
"chargingSettings": {
|
|
||||||
"hospitality": "NO_ACTION",
|
|
||||||
"idcc": "NO_ACTION",
|
|
||||||
"targetSoc": 100
|
|
||||||
},
|
|
||||||
"climatisationOn": false,
|
|
||||||
"departureTimes": [
|
|
||||||
{
|
|
||||||
"action": "DEACTIVATE",
|
|
||||||
"id": 1,
|
|
||||||
"timeStamp": {
|
|
||||||
"hour": 7,
|
|
||||||
"minute": 35
|
|
||||||
},
|
|
||||||
"timerWeekDays": [
|
|
||||||
"MONDAY",
|
|
||||||
"TUESDAY",
|
|
||||||
"WEDNESDAY",
|
|
||||||
"THURSDAY",
|
|
||||||
"FRIDAY"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"action": "DEACTIVATE",
|
|
||||||
"id": 2,
|
|
||||||
"timeStamp": {
|
|
||||||
"hour": 18,
|
|
||||||
"minute": 0
|
|
||||||
},
|
|
||||||
"timerWeekDays": [
|
|
||||||
"MONDAY",
|
|
||||||
"TUESDAY",
|
|
||||||
"WEDNESDAY",
|
|
||||||
"THURSDAY",
|
|
||||||
"FRIDAY",
|
|
||||||
"SATURDAY",
|
|
||||||
"SUNDAY"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"action": "DEACTIVATE",
|
|
||||||
"id": 3,
|
|
||||||
"timeStamp": {
|
|
||||||
"hour": 7,
|
|
||||||
"minute": 0
|
|
||||||
},
|
|
||||||
"timerWeekDays": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"action": "DEACTIVATE",
|
|
||||||
"id": 4,
|
|
||||||
"timerWeekDays": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"reductionOfChargeCurrent": {
|
|
||||||
"end": {
|
|
||||||
"hour": 1,
|
|
||||||
"minute": 30
|
|
||||||
},
|
|
||||||
"start": {
|
|
||||||
"hour": 18,
|
|
||||||
"minute": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"checkControlMessages": [],
|
|
||||||
"climateTimers": [
|
|
||||||
{
|
|
||||||
"departureTime": {
|
|
||||||
"hour": 6,
|
|
||||||
"minute": 40
|
|
||||||
},
|
|
||||||
"isWeeklyTimer": true,
|
|
||||||
"timerAction": "ACTIVATE",
|
|
||||||
"timerWeekDays": ["THURSDAY", "SUNDAY"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"departureTime": {
|
|
||||||
"hour": 12,
|
|
||||||
"minute": 50
|
|
||||||
},
|
|
||||||
"isWeeklyTimer": false,
|
|
||||||
"timerAction": "ACTIVATE",
|
|
||||||
"timerWeekDays": ["MONDAY"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"departureTime": {
|
|
||||||
"hour": 18,
|
|
||||||
"minute": 59
|
|
||||||
},
|
|
||||||
"isWeeklyTimer": true,
|
|
||||||
"timerAction": "DEACTIVATE",
|
|
||||||
"timerWeekDays": ["WEDNESDAY"]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"combustionFuelLevel": {
|
|
||||||
"range": 105,
|
|
||||||
"remainingFuelLiters": 6,
|
|
||||||
"remainingFuelPercent": 65
|
|
||||||
},
|
|
||||||
"currentMileage": 137009,
|
|
||||||
"doorsState": {
|
|
||||||
"combinedSecurityState": "UNLOCKED",
|
|
||||||
"combinedState": "CLOSED",
|
|
||||||
"hood": "CLOSED",
|
|
||||||
"leftFront": "CLOSED",
|
|
||||||
"leftRear": "CLOSED",
|
|
||||||
"rightFront": "CLOSED",
|
|
||||||
"rightRear": "CLOSED",
|
|
||||||
"trunk": "CLOSED"
|
|
||||||
},
|
|
||||||
"driverPreferences": {
|
|
||||||
"lscPrivacyMode": "OFF"
|
|
||||||
},
|
|
||||||
"electricChargingState": {
|
|
||||||
"chargingConnectionType": "CONDUCTIVE",
|
|
||||||
"chargingLevelPercent": 82,
|
|
||||||
"chargingStatus": "WAITING_FOR_CHARGING",
|
|
||||||
"chargingTarget": 100,
|
|
||||||
"isChargerConnected": true,
|
|
||||||
"range": 174
|
|
||||||
},
|
|
||||||
"isLeftSteering": true,
|
|
||||||
"isLscSupported": true,
|
|
||||||
"lastFetched": "2022-06-22T14:24:23.982Z",
|
|
||||||
"lastUpdatedAt": "2022-06-22T13:58:52Z",
|
|
||||||
"range": 174,
|
|
||||||
"requiredServices": [
|
|
||||||
{
|
|
||||||
"dateTime": "2022-10-01T00:00:00.000Z",
|
|
||||||
"description": "Next service due by the specified date.",
|
|
||||||
"status": "OK",
|
|
||||||
"type": "BRAKE_FLUID"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"dateTime": "2023-05-01T00:00:00.000Z",
|
|
||||||
"description": "Next vehicle check due after the specified distance or date.",
|
|
||||||
"status": "OK",
|
|
||||||
"type": "VEHICLE_CHECK"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"dateTime": "2023-05-01T00:00:00.000Z",
|
|
||||||
"description": "Next state inspection due by the specified date.",
|
|
||||||
"status": "OK",
|
|
||||||
"type": "VEHICLE_TUV"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"roofState": {
|
|
||||||
"roofState": "CLOSED",
|
|
||||||
"roofStateType": "SUN_ROOF"
|
|
||||||
},
|
|
||||||
"windowsState": {
|
|
||||||
"combinedState": "CLOSED",
|
|
||||||
"leftFront": "CLOSED",
|
|
||||||
"rightFront": "CLOSED"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,66 @@
|
|||||||
# serializer version: 1
|
# serializer version: 1
|
||||||
# name: test_entity_state_attrs
|
# name: test_entity_state_attrs
|
||||||
list([
|
list([
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'iX xDrive50 Flash lights',
|
||||||
|
'icon': 'mdi:car-light-alert',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'button.ix_xdrive50_flash_lights',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'unknown',
|
||||||
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'iX xDrive50 Sound horn',
|
||||||
|
'icon': 'mdi:bullhorn',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'button.ix_xdrive50_sound_horn',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'unknown',
|
||||||
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'iX xDrive50 Activate air conditioning',
|
||||||
|
'icon': 'mdi:hvac',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'button.ix_xdrive50_activate_air_conditioning',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'unknown',
|
||||||
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'iX xDrive50 Deactivate air conditioning',
|
||||||
|
'icon': 'mdi:hvac-off',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'button.ix_xdrive50_deactivate_air_conditioning',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'unknown',
|
||||||
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'iX xDrive50 Find vehicle',
|
||||||
|
'icon': 'mdi:crosshairs-question',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'button.ix_xdrive50_find_vehicle',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'unknown',
|
||||||
|
}),
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'attribution': 'Data provided by MyBMW',
|
'attribution': 'Data provided by MyBMW',
|
||||||
@ -61,6 +121,66 @@
|
|||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': 'unknown',
|
'state': 'unknown',
|
||||||
}),
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'M340i xDrive Flash lights',
|
||||||
|
'icon': 'mdi:car-light-alert',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'button.m340i_xdrive_flash_lights',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'unknown',
|
||||||
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'M340i xDrive Sound horn',
|
||||||
|
'icon': 'mdi:bullhorn',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'button.m340i_xdrive_sound_horn',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'unknown',
|
||||||
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'M340i xDrive Activate air conditioning',
|
||||||
|
'icon': 'mdi:hvac',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'button.m340i_xdrive_activate_air_conditioning',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'unknown',
|
||||||
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'M340i xDrive Deactivate air conditioning',
|
||||||
|
'icon': 'mdi:hvac-off',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'button.m340i_xdrive_deactivate_air_conditioning',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'unknown',
|
||||||
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'M340i xDrive Find vehicle',
|
||||||
|
'icon': 'mdi:crosshairs-question',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'button.m340i_xdrive_find_vehicle',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'unknown',
|
||||||
|
}),
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'attribution': 'Data provided by MyBMW',
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,23 @@
|
|||||||
# serializer version: 1
|
# serializer version: 1
|
||||||
# name: test_entity_state_attrs
|
# name: test_entity_state_attrs
|
||||||
list([
|
list([
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'device_class': 'battery',
|
||||||
|
'friendly_name': 'iX xDrive50 Target SoC',
|
||||||
|
'icon': 'mdi:battery-charging-medium',
|
||||||
|
'max': 100.0,
|
||||||
|
'min': 20.0,
|
||||||
|
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||||
|
'step': 5.0,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'number.ix_xdrive50_target_soc',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '80',
|
||||||
|
}),
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'attribution': 'Data provided by MyBMW',
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
@ -1,6 +1,50 @@
|
|||||||
# serializer version: 1
|
# serializer version: 1
|
||||||
# name: test_entity_state_attrs
|
# name: test_entity_state_attrs
|
||||||
list([
|
list([
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'iX xDrive50 AC Charging Limit',
|
||||||
|
'icon': 'mdi:current-ac',
|
||||||
|
'options': list([
|
||||||
|
'6',
|
||||||
|
'7',
|
||||||
|
'8',
|
||||||
|
'9',
|
||||||
|
'10',
|
||||||
|
'11',
|
||||||
|
'12',
|
||||||
|
'13',
|
||||||
|
'14',
|
||||||
|
'15',
|
||||||
|
'16',
|
||||||
|
'20',
|
||||||
|
'32',
|
||||||
|
]),
|
||||||
|
'unit_of_measurement': <UnitOfElectricCurrent.AMPERE: 'A'>,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'select.ix_xdrive50_ac_charging_limit',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '16',
|
||||||
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'iX xDrive50 Charging Mode',
|
||||||
|
'icon': 'mdi:vector-point-select',
|
||||||
|
'options': list([
|
||||||
|
'IMMEDIATE_CHARGING',
|
||||||
|
'DELAYED_CHARGING',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'select.ix_xdrive50_charging_mode',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'IMMEDIATE_CHARGING',
|
||||||
|
}),
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'attribution': 'Data provided by MyBMW',
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
@ -1,6 +1,30 @@
|
|||||||
# serializer version: 1
|
# serializer version: 1
|
||||||
# name: test_entity_state_attrs
|
# name: test_entity_state_attrs
|
||||||
list([
|
list([
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'iX xDrive50 Climate',
|
||||||
|
'icon': 'mdi:fan',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'switch.ix_xdrive50_climate',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'off',
|
||||||
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'friendly_name': 'iX xDrive50 Charging',
|
||||||
|
'icon': 'mdi:ev-station',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'switch.ix_xdrive50_charging',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'on',
|
||||||
|
}),
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'attribution': 'Data provided by MyBMW',
|
'attribution': 'Data provided by MyBMW',
|
||||||
@ -11,19 +35,19 @@
|
|||||||
'entity_id': 'switch.i4_edrive40_climate',
|
'entity_id': 'switch.i4_edrive40_climate',
|
||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': 'off',
|
'state': 'on',
|
||||||
}),
|
}),
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'attribution': 'Data provided by MyBMW',
|
'attribution': 'Data provided by MyBMW',
|
||||||
'friendly_name': 'i4 eDrive40 Charging',
|
'friendly_name': 'M340i xDrive Climate',
|
||||||
'icon': 'mdi:ev-station',
|
'icon': 'mdi:fan',
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'switch.i4_edrive40_charging',
|
'entity_id': 'switch.m340i_xdrive_climate',
|
||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': 'on',
|
'state': 'off',
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
# ---
|
# ---
|
||||||
|
@ -7,13 +7,10 @@ import pytest
|
|||||||
import respx
|
import respx
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.bmw_connected_drive.coordinator import (
|
|
||||||
BMWDataUpdateCoordinator,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from . import setup_mocked_integration
|
from . import check_remote_service_call, setup_mocked_integration
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_state_attrs(
|
async def test_entity_state_attrs(
|
||||||
@ -31,25 +28,22 @@ async def test_entity_state_attrs(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("entity_id"),
|
("entity_id", "remote_service"),
|
||||||
[
|
[
|
||||||
("button.i4_edrive40_flash_lights"),
|
("button.i4_edrive40_flash_lights", "light-flash"),
|
||||||
("button.i4_edrive40_sound_horn"),
|
("button.i4_edrive40_sound_horn", "horn-blow"),
|
||||||
("button.i4_edrive40_activate_air_conditioning"),
|
|
||||||
("button.i4_edrive40_deactivate_air_conditioning"),
|
|
||||||
("button.i4_edrive40_find_vehicle"),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_update_triggers_success(
|
async def test_service_call_success(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entity_id: str,
|
entity_id: str,
|
||||||
|
remote_service: str,
|
||||||
bmw_fixture: respx.Router,
|
bmw_fixture: respx.Router,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test button press."""
|
"""Test successful button press."""
|
||||||
|
|
||||||
# Setup component
|
# Setup component
|
||||||
assert await setup_mocked_integration(hass)
|
assert await setup_mocked_integration(hass)
|
||||||
BMWDataUpdateCoordinator.async_update_listeners.reset_mock()
|
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
@ -58,20 +52,20 @@ async def test_update_triggers_success(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
target={"entity_id": entity_id},
|
target={"entity_id": entity_id},
|
||||||
)
|
)
|
||||||
assert RemoteServices.trigger_remote_service.call_count == 1
|
check_remote_service_call(bmw_fixture, remote_service)
|
||||||
assert BMWDataUpdateCoordinator.async_update_listeners.call_count == 1
|
|
||||||
|
|
||||||
|
|
||||||
async def test_update_failed(
|
async def test_service_call_fail(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
bmw_fixture: respx.Router,
|
bmw_fixture: respx.Router,
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test button press."""
|
"""Test failed button press."""
|
||||||
|
|
||||||
# Setup component
|
# Setup component
|
||||||
assert await setup_mocked_integration(hass)
|
assert await setup_mocked_integration(hass)
|
||||||
BMWDataUpdateCoordinator.async_update_listeners.reset_mock()
|
entity_id = "switch.i4_edrive40_climate"
|
||||||
|
old_value = hass.states.get(entity_id).state
|
||||||
|
|
||||||
# Setup exception
|
# Setup exception
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
@ -86,7 +80,115 @@ async def test_update_failed(
|
|||||||
"button",
|
"button",
|
||||||
"press",
|
"press",
|
||||||
blocking=True,
|
blocking=True,
|
||||||
target={"entity_id": "button.i4_edrive40_flash_lights"},
|
target={"entity_id": "button.i4_edrive40_activate_air_conditioning"},
|
||||||
)
|
)
|
||||||
assert RemoteServices.trigger_remote_service.call_count == 1
|
assert hass.states.get(entity_id).state == old_value
|
||||||
assert BMWDataUpdateCoordinator.async_update_listeners.call_count == 0
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
(
|
||||||
|
"entity_id",
|
||||||
|
"state_entity_id",
|
||||||
|
"new_value",
|
||||||
|
"old_value",
|
||||||
|
"remote_service",
|
||||||
|
"remote_service_params",
|
||||||
|
),
|
||||||
|
[
|
||||||
|
(
|
||||||
|
"button.i4_edrive40_activate_air_conditioning",
|
||||||
|
"switch.i4_edrive40_climate",
|
||||||
|
"on",
|
||||||
|
"off",
|
||||||
|
"climate-now",
|
||||||
|
{"action": "START"},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"button.i4_edrive40_deactivate_air_conditioning",
|
||||||
|
"switch.i4_edrive40_climate",
|
||||||
|
"off",
|
||||||
|
"on",
|
||||||
|
"climate-now",
|
||||||
|
{"action": "STOP"},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"button.i4_edrive40_find_vehicle",
|
||||||
|
"device_tracker.i4_edrive40",
|
||||||
|
"not_home",
|
||||||
|
"home",
|
||||||
|
"vehicle-finder",
|
||||||
|
{},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
async def test_service_call_success_state_change(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_id: str,
|
||||||
|
state_entity_id: str,
|
||||||
|
new_value: str,
|
||||||
|
old_value: str,
|
||||||
|
remote_service: str,
|
||||||
|
remote_service_params: dict,
|
||||||
|
bmw_fixture: respx.Router,
|
||||||
|
) -> None:
|
||||||
|
"""Test successful button press with state change."""
|
||||||
|
|
||||||
|
# Setup component
|
||||||
|
assert await setup_mocked_integration(hass)
|
||||||
|
hass.states.async_set(state_entity_id, old_value)
|
||||||
|
assert hass.states.get(state_entity_id).state == old_value
|
||||||
|
|
||||||
|
# Test
|
||||||
|
await hass.services.async_call(
|
||||||
|
"button",
|
||||||
|
"press",
|
||||||
|
blocking=True,
|
||||||
|
target={"entity_id": entity_id},
|
||||||
|
)
|
||||||
|
check_remote_service_call(bmw_fixture, remote_service, remote_service_params)
|
||||||
|
assert hass.states.get(state_entity_id).state == new_value
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("entity_id", "state_entity_id", "new_attrs", "old_attrs"),
|
||||||
|
[
|
||||||
|
(
|
||||||
|
"button.i4_edrive40_find_vehicle",
|
||||||
|
"device_tracker.i4_edrive40",
|
||||||
|
{"latitude": 123.456, "longitude": 34.5678, "direction": 121},
|
||||||
|
{"latitude": 48.177334, "longitude": 11.556274, "direction": 180},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
async def test_service_call_success_attr_change(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_id: str,
|
||||||
|
state_entity_id: str,
|
||||||
|
new_attrs: dict,
|
||||||
|
old_attrs: dict,
|
||||||
|
bmw_fixture: respx.Router,
|
||||||
|
) -> None:
|
||||||
|
"""Test successful button press with attribute change."""
|
||||||
|
|
||||||
|
# Setup component
|
||||||
|
assert await setup_mocked_integration(hass)
|
||||||
|
|
||||||
|
assert {
|
||||||
|
k: v
|
||||||
|
for k, v in hass.states.get(state_entity_id).attributes.items()
|
||||||
|
if k in old_attrs
|
||||||
|
} == old_attrs
|
||||||
|
|
||||||
|
# Test
|
||||||
|
await hass.services.async_call(
|
||||||
|
"button",
|
||||||
|
"press",
|
||||||
|
blocking=True,
|
||||||
|
target={"entity_id": entity_id},
|
||||||
|
)
|
||||||
|
check_remote_service_call(bmw_fixture)
|
||||||
|
assert {
|
||||||
|
k: v
|
||||||
|
for k, v in hass.states.get(state_entity_id).attributes.items()
|
||||||
|
if k in new_attrs
|
||||||
|
} == new_attrs
|
||||||
|
@ -7,13 +7,10 @@ import pytest
|
|||||||
import respx
|
import respx
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.bmw_connected_drive.coordinator import (
|
|
||||||
BMWDataUpdateCoordinator,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from . import setup_mocked_integration
|
from . import check_remote_service_call, setup_mocked_integration
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_state_attrs(
|
async def test_entity_state_attrs(
|
||||||
@ -31,33 +28,36 @@ async def test_entity_state_attrs(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("entity_id", "value"),
|
("entity_id", "new_value", "old_value", "remote_service"),
|
||||||
[
|
[
|
||||||
("number.i4_edrive40_target_soc", "80"),
|
("number.i4_edrive40_target_soc", "80", "100", "charging-settings"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_update_triggers_success(
|
async def test_service_call_success(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entity_id: str,
|
entity_id: str,
|
||||||
value: str,
|
new_value: str,
|
||||||
|
old_value: str,
|
||||||
|
remote_service: str,
|
||||||
bmw_fixture: respx.Router,
|
bmw_fixture: respx.Router,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test allowed values for number inputs."""
|
"""Test successful number change."""
|
||||||
|
|
||||||
# Setup component
|
# Setup component
|
||||||
assert await setup_mocked_integration(hass)
|
assert await setup_mocked_integration(hass)
|
||||||
BMWDataUpdateCoordinator.async_update_listeners.reset_mock()
|
hass.states.async_set(entity_id, old_value)
|
||||||
|
assert hass.states.get(entity_id).state == old_value
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"number",
|
"number",
|
||||||
"set_value",
|
"set_value",
|
||||||
service_data={"value": value},
|
service_data={"value": new_value},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
target={"entity_id": entity_id},
|
target={"entity_id": entity_id},
|
||||||
)
|
)
|
||||||
assert RemoteServices.trigger_remote_service.call_count == 1
|
check_remote_service_call(bmw_fixture, remote_service)
|
||||||
assert BMWDataUpdateCoordinator.async_update_listeners.call_count == 1
|
assert hass.states.get(entity_id).state == new_value
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@ -66,7 +66,7 @@ async def test_update_triggers_success(
|
|||||||
("number.i4_edrive40_target_soc", "81"),
|
("number.i4_edrive40_target_soc", "81"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_update_triggers_fail(
|
async def test_service_call_invalid_input(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entity_id: str,
|
entity_id: str,
|
||||||
value: str,
|
value: str,
|
||||||
@ -76,7 +76,7 @@ async def test_update_triggers_fail(
|
|||||||
|
|
||||||
# Setup component
|
# Setup component
|
||||||
assert await setup_mocked_integration(hass)
|
assert await setup_mocked_integration(hass)
|
||||||
BMWDataUpdateCoordinator.async_update_listeners.reset_mock()
|
old_value = hass.states.get(entity_id).state
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
@ -87,8 +87,7 @@ async def test_update_triggers_fail(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
target={"entity_id": entity_id},
|
target={"entity_id": entity_id},
|
||||||
)
|
)
|
||||||
assert RemoteServices.trigger_remote_service.call_count == 0
|
assert hass.states.get(entity_id).state == old_value
|
||||||
assert BMWDataUpdateCoordinator.async_update_listeners.call_count == 0
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@ -99,18 +98,19 @@ async def test_update_triggers_fail(
|
|||||||
(ValueError, ValueError),
|
(ValueError, ValueError),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_update_triggers_exceptions(
|
async def test_service_call_fail(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
raised: Exception,
|
raised: Exception,
|
||||||
expected: Exception,
|
expected: Exception,
|
||||||
bmw_fixture: respx.Router,
|
bmw_fixture: respx.Router,
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test not allowed values for number inputs."""
|
"""Test exception handling."""
|
||||||
|
|
||||||
# Setup component
|
# Setup component
|
||||||
assert await setup_mocked_integration(hass)
|
assert await setup_mocked_integration(hass)
|
||||||
BMWDataUpdateCoordinator.async_update_listeners.reset_mock()
|
entity_id = "number.i4_edrive40_target_soc"
|
||||||
|
old_value = hass.states.get(entity_id).state
|
||||||
|
|
||||||
# Setup exception
|
# Setup exception
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
@ -126,7 +126,6 @@ async def test_update_triggers_exceptions(
|
|||||||
"set_value",
|
"set_value",
|
||||||
service_data={"value": "80"},
|
service_data={"value": "80"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
target={"entity_id": "number.i4_edrive40_target_soc"},
|
target={"entity_id": entity_id},
|
||||||
)
|
)
|
||||||
assert RemoteServices.trigger_remote_service.call_count == 1
|
assert hass.states.get(entity_id).state == old_value
|
||||||
assert BMWDataUpdateCoordinator.async_update_listeners.call_count == 0
|
|
||||||
|
@ -7,13 +7,10 @@ import pytest
|
|||||||
import respx
|
import respx
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.bmw_connected_drive.coordinator import (
|
|
||||||
BMWDataUpdateCoordinator,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from . import setup_mocked_integration
|
from . import check_remote_service_call, setup_mocked_integration
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_state_attrs(
|
async def test_entity_state_attrs(
|
||||||
@ -31,44 +28,58 @@ async def test_entity_state_attrs(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("entity_id", "value"),
|
("entity_id", "new_value", "old_value", "remote_service"),
|
||||||
[
|
[
|
||||||
("select.i3_rex_charging_mode", "IMMEDIATE_CHARGING"),
|
(
|
||||||
("select.i4_edrive40_ac_charging_limit", "16"),
|
"select.i3_rex_charging_mode",
|
||||||
("select.i4_edrive40_charging_mode", "DELAYED_CHARGING"),
|
"IMMEDIATE_CHARGING",
|
||||||
|
"DELAYED_CHARGING",
|
||||||
|
"charging-profile",
|
||||||
|
),
|
||||||
|
("select.i4_edrive40_ac_charging_limit", "12", "16", "charging-settings"),
|
||||||
|
(
|
||||||
|
"select.i4_edrive40_charging_mode",
|
||||||
|
"DELAYED_CHARGING",
|
||||||
|
"IMMEDIATE_CHARGING",
|
||||||
|
"charging-profile",
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_update_triggers_success(
|
async def test_service_call_success(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entity_id: str,
|
entity_id: str,
|
||||||
value: str,
|
new_value: str,
|
||||||
|
old_value: str,
|
||||||
|
remote_service: str,
|
||||||
bmw_fixture: respx.Router,
|
bmw_fixture: respx.Router,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test allowed values for select inputs."""
|
"""Test successful input change."""
|
||||||
|
|
||||||
# Setup component
|
# Setup component
|
||||||
assert await setup_mocked_integration(hass)
|
assert await setup_mocked_integration(hass)
|
||||||
BMWDataUpdateCoordinator.async_update_listeners.reset_mock()
|
hass.states.async_set(entity_id, old_value)
|
||||||
|
assert hass.states.get(entity_id).state == old_value
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"select",
|
"select",
|
||||||
"select_option",
|
"select_option",
|
||||||
service_data={"option": value},
|
service_data={"option": new_value},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
target={"entity_id": entity_id},
|
target={"entity_id": entity_id},
|
||||||
)
|
)
|
||||||
assert RemoteServices.trigger_remote_service.call_count == 1
|
check_remote_service_call(bmw_fixture, remote_service)
|
||||||
assert BMWDataUpdateCoordinator.async_update_listeners.call_count == 1
|
assert hass.states.get(entity_id).state == new_value
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("entity_id", "value"),
|
("entity_id", "value"),
|
||||||
[
|
[
|
||||||
("select.i4_edrive40_ac_charging_limit", "17"),
|
("select.i4_edrive40_ac_charging_limit", "17"),
|
||||||
|
("select.i4_edrive40_charging_mode", "BONKERS_MODE"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_update_triggers_fail(
|
async def test_service_call_invalid_input(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entity_id: str,
|
entity_id: str,
|
||||||
value: str,
|
value: str,
|
||||||
@ -78,7 +89,7 @@ async def test_update_triggers_fail(
|
|||||||
|
|
||||||
# Setup component
|
# Setup component
|
||||||
assert await setup_mocked_integration(hass)
|
assert await setup_mocked_integration(hass)
|
||||||
BMWDataUpdateCoordinator.async_update_listeners.reset_mock()
|
old_value = hass.states.get(entity_id).state
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
@ -89,8 +100,7 @@ async def test_update_triggers_fail(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
target={"entity_id": entity_id},
|
target={"entity_id": entity_id},
|
||||||
)
|
)
|
||||||
assert RemoteServices.trigger_remote_service.call_count == 0
|
assert hass.states.get(entity_id).state == old_value
|
||||||
assert BMWDataUpdateCoordinator.async_update_listeners.call_count == 0
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@ -101,17 +111,19 @@ async def test_update_triggers_fail(
|
|||||||
(ValueError, ValueError),
|
(ValueError, ValueError),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_remote_service_exceptions(
|
async def test_service_call_fail(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
raised: Exception,
|
raised: Exception,
|
||||||
expected: Exception,
|
expected: Exception,
|
||||||
bmw_fixture: respx.Router,
|
bmw_fixture: respx.Router,
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test exception handling for remote services."""
|
"""Test exception handling."""
|
||||||
|
|
||||||
# Setup component
|
# Setup component
|
||||||
assert await setup_mocked_integration(hass)
|
assert await setup_mocked_integration(hass)
|
||||||
|
entity_id = "select.i4_edrive40_ac_charging_limit"
|
||||||
|
old_value = hass.states.get(entity_id).state
|
||||||
|
|
||||||
# Setup exception
|
# Setup exception
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
@ -127,6 +139,6 @@ async def test_remote_service_exceptions(
|
|||||||
"select_option",
|
"select_option",
|
||||||
service_data={"option": "16"},
|
service_data={"option": "16"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
target={"entity_id": "select.i4_edrive40_ac_charging_limit"},
|
target={"entity_id": entity_id},
|
||||||
)
|
)
|
||||||
assert RemoteServices.trigger_remote_service.call_count == 1
|
assert hass.states.get(entity_id).state == old_value
|
||||||
|
@ -26,8 +26,8 @@ from . import setup_mocked_integration
|
|||||||
("sensor.i3_rex_remaining_fuel", IMPERIAL, "1.59", "gal"),
|
("sensor.i3_rex_remaining_fuel", IMPERIAL, "1.59", "gal"),
|
||||||
("sensor.i3_rex_remaining_range_fuel", METRIC, "105", "km"),
|
("sensor.i3_rex_remaining_range_fuel", METRIC, "105", "km"),
|
||||||
("sensor.i3_rex_remaining_range_fuel", IMPERIAL, "65.24", "mi"),
|
("sensor.i3_rex_remaining_range_fuel", IMPERIAL, "65.24", "mi"),
|
||||||
("sensor.i3_rex_remaining_fuel_percent", METRIC, "65", "%"),
|
("sensor.m340i_xdrive_remaining_fuel_percent", METRIC, "80", "%"),
|
||||||
("sensor.i3_rex_remaining_fuel_percent", IMPERIAL, "65", "%"),
|
("sensor.m340i_xdrive_remaining_fuel_percent", IMPERIAL, "80", "%"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_unit_conversion(
|
async def test_unit_conversion(
|
||||||
|
@ -7,13 +7,10 @@ import pytest
|
|||||||
import respx
|
import respx
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.bmw_connected_drive.coordinator import (
|
|
||||||
BMWDataUpdateCoordinator,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from . import setup_mocked_integration
|
from . import check_remote_service_call, setup_mocked_integration
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_state_attrs(
|
async def test_entity_state_attrs(
|
||||||
@ -25,42 +22,45 @@ async def test_entity_state_attrs(
|
|||||||
|
|
||||||
# Setup component
|
# Setup component
|
||||||
assert await setup_mocked_integration(hass)
|
assert await setup_mocked_integration(hass)
|
||||||
BMWDataUpdateCoordinator.async_update_listeners.reset_mock()
|
|
||||||
|
|
||||||
# Get all switch entities
|
# Get all switch entities
|
||||||
assert hass.states.async_all("switch") == snapshot
|
assert hass.states.async_all("switch") == snapshot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("entity_id", "value"),
|
("entity_id", "new_value", "old_value", "remote_service", "remote_service_params"),
|
||||||
[
|
[
|
||||||
("switch.i4_edrive40_climate", "ON"),
|
("switch.i4_edrive40_climate", "on", "off", "climate-now", {"action": "START"}),
|
||||||
("switch.i4_edrive40_climate", "OFF"),
|
("switch.i4_edrive40_climate", "off", "on", "climate-now", {"action": "STOP"}),
|
||||||
("switch.i4_edrive40_charging", "ON"),
|
("switch.iX_xdrive50_charging", "on", "off", "start-charging", {}),
|
||||||
("switch.i4_edrive40_charging", "OFF"),
|
("switch.iX_xdrive50_charging", "off", "on", "stop-charging", {}),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_update_triggers_success(
|
async def test_service_call_success(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entity_id: str,
|
entity_id: str,
|
||||||
value: str,
|
new_value: str,
|
||||||
|
old_value: str,
|
||||||
|
remote_service: str,
|
||||||
|
remote_service_params: dict,
|
||||||
bmw_fixture: respx.Router,
|
bmw_fixture: respx.Router,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test allowed values for switch inputs."""
|
"""Test successful switch change."""
|
||||||
|
|
||||||
# Setup component
|
# Setup component
|
||||||
assert await setup_mocked_integration(hass)
|
assert await setup_mocked_integration(hass)
|
||||||
BMWDataUpdateCoordinator.async_update_listeners.reset_mock()
|
hass.states.async_set(entity_id, old_value)
|
||||||
|
assert hass.states.get(entity_id).state == old_value
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"switch",
|
"switch",
|
||||||
f"turn_{value.lower()}",
|
f"turn_{new_value}",
|
||||||
blocking=True,
|
blocking=True,
|
||||||
target={"entity_id": entity_id},
|
target={"entity_id": entity_id},
|
||||||
)
|
)
|
||||||
assert RemoteServices.trigger_remote_service.call_count == 1
|
check_remote_service_call(bmw_fixture, remote_service, remote_service_params)
|
||||||
assert BMWDataUpdateCoordinator.async_update_listeners.call_count == 1
|
assert hass.states.get(entity_id).state == new_value
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@ -71,18 +71,18 @@ async def test_update_triggers_success(
|
|||||||
(ValueError, ValueError),
|
(ValueError, ValueError),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_update_triggers_exceptions(
|
async def test_service_call_fail(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
raised: Exception,
|
raised: Exception,
|
||||||
expected: Exception,
|
expected: Exception,
|
||||||
bmw_fixture: respx.Router,
|
bmw_fixture: respx.Router,
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test not allowed values for switch inputs."""
|
"""Test exception handling."""
|
||||||
|
|
||||||
# Setup component
|
# Setup component
|
||||||
assert await setup_mocked_integration(hass)
|
assert await setup_mocked_integration(hass)
|
||||||
BMWDataUpdateCoordinator.async_update_listeners.reset_mock()
|
entity_id = "switch.i4_edrive40_climate"
|
||||||
|
|
||||||
# Setup exception
|
# Setup exception
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
@ -91,20 +91,32 @@ async def test_update_triggers_exceptions(
|
|||||||
AsyncMock(side_effect=raised),
|
AsyncMock(side_effect=raised),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Turning switch to ON
|
||||||
|
old_value = "off"
|
||||||
|
hass.states.async_set(entity_id, old_value)
|
||||||
|
assert hass.states.get(entity_id).state == old_value
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
with pytest.raises(expected):
|
with pytest.raises(expected):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"switch",
|
"switch",
|
||||||
"turn_on",
|
"turn_on",
|
||||||
blocking=True,
|
blocking=True,
|
||||||
target={"entity_id": "switch.i4_edrive40_climate"},
|
target={"entity_id": entity_id},
|
||||||
)
|
)
|
||||||
|
assert hass.states.get(entity_id).state == old_value
|
||||||
|
|
||||||
|
# Turning switch to OFF
|
||||||
|
old_value = "on"
|
||||||
|
hass.states.async_set(entity_id, old_value)
|
||||||
|
assert hass.states.get(entity_id).state == old_value
|
||||||
|
|
||||||
|
# Test
|
||||||
with pytest.raises(expected):
|
with pytest.raises(expected):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"switch",
|
"switch",
|
||||||
"turn_off",
|
"turn_off",
|
||||||
blocking=True,
|
blocking=True,
|
||||||
target={"entity_id": "switch.i4_edrive40_climate"},
|
target={"entity_id": entity_id},
|
||||||
)
|
)
|
||||||
assert RemoteServices.trigger_remote_service.call_count == 2
|
assert hass.states.get(entity_id).state == old_value
|
||||||
assert BMWDataUpdateCoordinator.async_update_listeners.call_count == 0
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user