mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Fix BMW Connected Drive (#60938)
* Bump bimmer_connected to 0.8.5 * Always update HA states after service execution * Fix BMW device tracker & vehicle_finder service * Add charging_end_time sensor * Fix pylint & pytest * Remove unneeded DEFAULT_OPTION * Revert adding charging_end_time & state_attributes * Don't delete option data for CONF_USE_LOCATION * Remove stale string Co-authored-by: rikroe <rikroe@users.noreply.github.com>
This commit is contained in:
parent
e34d982bdb
commit
380c1a4be9
@ -35,7 +35,6 @@ from .const import (
|
||||
CONF_ACCOUNT,
|
||||
CONF_ALLOWED_REGIONS,
|
||||
CONF_READ_ONLY,
|
||||
CONF_USE_LOCATION,
|
||||
DATA_ENTRIES,
|
||||
DATA_HASS_CONFIG,
|
||||
)
|
||||
@ -65,7 +64,6 @@ SERVICE_SCHEMA = vol.Schema(
|
||||
|
||||
DEFAULT_OPTIONS = {
|
||||
CONF_READ_ONLY: False,
|
||||
CONF_USE_LOCATION: False,
|
||||
}
|
||||
|
||||
PLATFORMS = [
|
||||
@ -215,13 +213,10 @@ def setup_account(
|
||||
password: str = entry.data[CONF_PASSWORD]
|
||||
region: str = entry.data[CONF_REGION]
|
||||
read_only: bool = entry.options[CONF_READ_ONLY]
|
||||
use_location: bool = entry.options[CONF_USE_LOCATION]
|
||||
|
||||
_LOGGER.debug("Adding new account %s", name)
|
||||
|
||||
pos = (
|
||||
(hass.config.latitude, hass.config.longitude) if use_location else (None, None)
|
||||
)
|
||||
pos = (hass.config.latitude, hass.config.longitude)
|
||||
cd_account = BMWConnectedDriveAccount(
|
||||
username, password, region, name, read_only, *pos
|
||||
)
|
||||
@ -258,6 +253,13 @@ def setup_account(
|
||||
function_call = getattr(vehicle.remote_services, function_name)
|
||||
function_call()
|
||||
|
||||
if call.service in [
|
||||
"find_vehicle",
|
||||
"activate_air_conditioning",
|
||||
"deactivate_air_conditioning",
|
||||
]:
|
||||
cd_account.update()
|
||||
|
||||
if not read_only:
|
||||
# register the remote services
|
||||
for service in _SERVICE_MAP:
|
||||
|
@ -13,7 +13,7 @@ from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from . import DOMAIN
|
||||
from .const import CONF_ALLOWED_REGIONS, CONF_READ_ONLY, CONF_USE_LOCATION
|
||||
from .const import CONF_ALLOWED_REGIONS, CONF_READ_ONLY
|
||||
|
||||
DATA_SCHEMA = vol.Schema(
|
||||
{
|
||||
@ -115,10 +115,6 @@ class BMWConnectedDriveOptionsFlow(config_entries.OptionsFlow):
|
||||
CONF_READ_ONLY,
|
||||
default=self.config_entry.options.get(CONF_READ_ONLY, False),
|
||||
): bool,
|
||||
vol.Optional(
|
||||
CONF_USE_LOCATION,
|
||||
default=self.config_entry.options.get(CONF_USE_LOCATION, False),
|
||||
): bool,
|
||||
}
|
||||
),
|
||||
)
|
||||
|
@ -35,7 +35,7 @@ async def async_setup_entry(
|
||||
|
||||
for vehicle in account.account.vehicles:
|
||||
entities.append(BMWDeviceTracker(account, vehicle))
|
||||
if not vehicle.status.is_vehicle_tracking_enabled:
|
||||
if not vehicle.is_vehicle_tracking_enabled:
|
||||
_LOGGER.info(
|
||||
"Tracking is (currently) disabled for vehicle %s (%s), defaulting to unknown",
|
||||
vehicle.name,
|
||||
@ -83,6 +83,6 @@ class BMWDeviceTracker(BMWConnectedDriveBaseEntity, TrackerEntity):
|
||||
self._attr_extra_state_attributes = self._attrs
|
||||
self._location = (
|
||||
self._vehicle.status.gps_position
|
||||
if self._vehicle.status.is_vehicle_tracking_enabled
|
||||
if self._vehicle.is_vehicle_tracking_enabled
|
||||
else None
|
||||
)
|
||||
|
@ -2,7 +2,7 @@
|
||||
"domain": "bmw_connected_drive",
|
||||
"name": "BMW Connected Drive",
|
||||
"documentation": "https://www.home-assistant.io/integrations/bmw_connected_drive",
|
||||
"requirements": ["bimmer_connected==0.8.2"],
|
||||
"requirements": ["bimmer_connected==0.8.5"],
|
||||
"codeowners": ["@gerard33", "@rikroe"],
|
||||
"config_flow": true,
|
||||
"iot_class": "cloud_polling"
|
||||
|
@ -21,8 +21,7 @@
|
||||
"step": {
|
||||
"account_options": {
|
||||
"data": {
|
||||
"read_only": "Read-only (only sensors and notify, no execution of services, no lock)",
|
||||
"use_location": "Use Home Assistant location for car location polls (required for non i3/i8 vehicles produced before 7/2014)"
|
||||
"read_only": "Read-only (only sensors and notify, no execution of services, no lock)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ beautifulsoup4==4.10.0
|
||||
bellows==0.29.0
|
||||
|
||||
# homeassistant.components.bmw_connected_drive
|
||||
bimmer_connected==0.8.2
|
||||
bimmer_connected==0.8.5
|
||||
|
||||
# homeassistant.components.bizkaibus
|
||||
bizkaibus==0.1.1
|
||||
|
@ -257,7 +257,7 @@ base36==0.1.1
|
||||
bellows==0.29.0
|
||||
|
||||
# homeassistant.components.bmw_connected_drive
|
||||
bimmer_connected==0.8.2
|
||||
bimmer_connected==0.8.5
|
||||
|
||||
# homeassistant.components.blebox
|
||||
blebox_uniapi==1.3.3
|
||||
|
@ -3,10 +3,7 @@ from unittest.mock import patch
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components.bmw_connected_drive.config_flow import DOMAIN
|
||||
from homeassistant.components.bmw_connected_drive.const import (
|
||||
CONF_READ_ONLY,
|
||||
CONF_USE_LOCATION,
|
||||
)
|
||||
from homeassistant.components.bmw_connected_drive.const import CONF_READ_ONLY
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
@ -28,7 +25,7 @@ FIXTURE_CONFIG_ENTRY = {
|
||||
CONF_PASSWORD: FIXTURE_USER_INPUT[CONF_PASSWORD],
|
||||
CONF_REGION: FIXTURE_USER_INPUT[CONF_REGION],
|
||||
},
|
||||
"options": {CONF_READ_ONLY: False, CONF_USE_LOCATION: False},
|
||||
"options": {CONF_READ_ONLY: False},
|
||||
"source": config_entries.SOURCE_USER,
|
||||
"unique_id": f"{FIXTURE_USER_INPUT[CONF_REGION]}-{FIXTURE_USER_INPUT[CONF_REGION]}",
|
||||
}
|
||||
@ -137,14 +134,13 @@ async def test_options_flow_implementation(hass):
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={CONF_READ_ONLY: False, CONF_USE_LOCATION: False},
|
||||
user_input={CONF_READ_ONLY: False},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
CONF_READ_ONLY: False,
|
||||
CONF_USE_LOCATION: False,
|
||||
}
|
||||
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user