mirror of
https://github.com/home-assistant/core
synced 2024-08-02 23:40:32 +02:00
Add selectors to BMW Connected Drive service definitions (#47065)
Co-authored-by: rikroe <rikroe@users.noreply.github.com>
This commit is contained in:
parent
e1538594cd
commit
dfe21eb78f
@ -11,6 +11,7 @@ from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
CONF_DEVICE_ID,
|
||||
CONF_NAME,
|
||||
CONF_PASSWORD,
|
||||
CONF_REGION,
|
||||
@ -18,7 +19,7 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import discovery
|
||||
from homeassistant.helpers import device_registry, discovery
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
from homeassistant.helpers.event import track_utc_time_change
|
||||
@ -51,7 +52,12 @@ ACCOUNT_SCHEMA = vol.Schema(
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({DOMAIN: {cv.string: ACCOUNT_SCHEMA}}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
SERVICE_SCHEMA = vol.Schema({vol.Required(ATTR_VIN): cv.string})
|
||||
SERVICE_SCHEMA = vol.Schema(
|
||||
vol.Any(
|
||||
{vol.Required(ATTR_VIN): cv.string},
|
||||
{vol.Required(CONF_DEVICE_ID): cv.string},
|
||||
)
|
||||
)
|
||||
|
||||
DEFAULT_OPTIONS = {
|
||||
CONF_READ_ONLY: False,
|
||||
@ -207,8 +213,15 @@ def setup_account(entry: ConfigEntry, hass, name: str) -> BMWConnectedDriveAccou
|
||||
|
||||
def execute_service(call):
|
||||
"""Execute a service for a vehicle."""
|
||||
vin = call.data[ATTR_VIN]
|
||||
vin = call.data.get(ATTR_VIN)
|
||||
device_id = call.data.get(CONF_DEVICE_ID)
|
||||
|
||||
vehicle = None
|
||||
|
||||
if not vin and device_id:
|
||||
device = device_registry.async_get(hass).async_get(device_id)
|
||||
vin = next(iter(device.identifiers))[1]
|
||||
|
||||
# Double check for read_only accounts as another account could create the services
|
||||
for entry_data in [
|
||||
e
|
||||
|
@ -6,14 +6,20 @@
|
||||
light_flash:
|
||||
name: Flash lights
|
||||
description: >
|
||||
Flash the lights of the vehicle. The vehicle is identified via the vin
|
||||
(see below).
|
||||
Flash the lights of the vehicle. The vehicle is identified either via its
|
||||
device entry or the VIN. If a VIN is specified, the device entry will be ignored.
|
||||
fields:
|
||||
device_id:
|
||||
name: Car
|
||||
description: The BMW Connected Drive device
|
||||
selector:
|
||||
device:
|
||||
integration: bmw_connected_drive
|
||||
vin:
|
||||
name: VIN
|
||||
description: >
|
||||
The vehicle identification number (VIN) of the vehicle, 17 characters
|
||||
required: true
|
||||
description: The vehicle identification number (VIN) of the vehicle, 17 characters
|
||||
advanced: true
|
||||
required: false
|
||||
example: WBANXXXXXX1234567
|
||||
selector:
|
||||
text:
|
||||
@ -21,14 +27,20 @@ light_flash:
|
||||
sound_horn:
|
||||
name: Sound horn
|
||||
description: >
|
||||
Sound the horn of the vehicle. The vehicle is identified via the vin
|
||||
(see below).
|
||||
Sound the horn of the vehicle. The vehicle is identified either via its
|
||||
device entry or the VIN. If a VIN is specified, the device entry will be ignored.
|
||||
fields:
|
||||
device_id:
|
||||
name: Car
|
||||
description: The BMW Connected Drive device
|
||||
selector:
|
||||
device:
|
||||
integration: bmw_connected_drive
|
||||
vin:
|
||||
name: VIN
|
||||
description: >
|
||||
The vehicle identification number (VIN) of the vehicle, 17 characters
|
||||
required: true
|
||||
description: The vehicle identification number (VIN) of the vehicle, 17 characters
|
||||
advanced: true
|
||||
required: false
|
||||
example: WBANXXXXXX1234567
|
||||
selector:
|
||||
text:
|
||||
@ -38,14 +50,20 @@ activate_air_conditioning:
|
||||
description: >
|
||||
Start the air conditioning of the vehicle. What exactly is started here
|
||||
depends on the type of vehicle. It might range from just ventilation over
|
||||
auxiliary heating to real air conditioning. The vehicle is identified via
|
||||
the vin (see below).
|
||||
auxiliary heating to real air conditioning. The vehicle is identified either via its
|
||||
device entry or the VIN. If a VIN is specified, the device entry will be ignored.
|
||||
fields:
|
||||
device_id:
|
||||
name: Car
|
||||
description: The BMW Connected Drive device
|
||||
selector:
|
||||
device:
|
||||
integration: bmw_connected_drive
|
||||
vin:
|
||||
name: VIN
|
||||
description: >
|
||||
The vehicle identification number (VIN) of the vehicle, 17 characters
|
||||
required: true
|
||||
description: The vehicle identification number (VIN) of the vehicle, 17 characters
|
||||
advanced: true
|
||||
required: false
|
||||
example: WBANXXXXXX1234567
|
||||
selector:
|
||||
text:
|
||||
@ -53,14 +71,20 @@ activate_air_conditioning:
|
||||
find_vehicle:
|
||||
name: Find vehicle
|
||||
description: >
|
||||
Request vehicle to update the gps location. The vehicle is identified via the vin
|
||||
(see below).
|
||||
Request vehicle to update the GPS location. The vehicle is identified either via its
|
||||
device entry or the VIN. If a VIN is specified, the device entry will be ignored.
|
||||
fields:
|
||||
device_id:
|
||||
name: Car
|
||||
description: The BMW Connected Drive device
|
||||
selector:
|
||||
device:
|
||||
integration: bmw_connected_drive
|
||||
vin:
|
||||
name: VIN
|
||||
description: >
|
||||
The vehicle identification number (VIN) of the vehicle, 17 characters
|
||||
required: true
|
||||
description: The vehicle identification number (VIN) of the vehicle, 17 characters
|
||||
advanced: true
|
||||
required: false
|
||||
example: WBANXXXXXX1234567
|
||||
selector:
|
||||
text:
|
||||
|
Loading…
Reference in New Issue
Block a user