Skip to content

Commit

Permalink
Support for sending destinations to car (dependent on tillsteinbach/W…
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFox committed Sep 20, 2024
1 parent 97a8360 commit 7683e51
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
36 changes: 36 additions & 0 deletions custom_components/volkswagen_we_connect_id/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ async def volkswagen_id_set_ac_charge_speed(call: ServiceCall) -> None:
):
_LOGGER.error("Cannot send ac speed request to car")

@callback
async def volkswagen_id_send_destinations(call: ServiceCall) -> None:

vin = call.data["vin"]
if 'destinations' in call.data:
if (
await hass.async_add_executor_job(
send_destinations,
vin,
_we_connect,
call.data["destinations"],
)
is False
):
_LOGGER.error("Cannot send destination to car")

# Register our services with Home Assistant.
hass.services.async_register(
DOMAIN, "volkswagen_id_start_stop_charging", volkswagen_id_start_stop_charging
Expand All @@ -177,6 +193,9 @@ async def volkswagen_id_set_ac_charge_speed(call: ServiceCall) -> None:
hass.services.async_register(
DOMAIN, "volkswagen_id_set_ac_charge_speed", volkswagen_id_set_ac_charge_speed
)
hass.services.async_register(
DOMAIN, "volkswagen_id_send_destinations", volkswagen_id_send_destinations
)

return True

Expand Down Expand Up @@ -361,6 +380,23 @@ def set_climatisation(
return True


def send_destinations(
call_data_vin, api: weconnect.WeConnect,
destinations: str | list | dict
) -> bool:
"""Send destination to your volkswagen."""

for vin, vehicle in api.vehicles.items():
if vin == call_data_vin:
try:
vehicle.controls.sendDestinations.value = destinations
_LOGGER.info("Sended destination call to the car")
except Exception as exc:
_LOGGER.error("Failed to send request to car - %s", exc)
return False
return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""

Expand Down
35 changes: 35 additions & 0 deletions custom_components/volkswagen_we_connect_id/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,38 @@ volkswagen_id_set_ac_charge_speed:
options:
- "maximum"
- "reduced"

volkswagen_id_send_destinations:
name: Volkswagen ID Send Destinations
description: Send destination or a route to the car.
fields:
vin:
name: VIN
description: Vehicle identification number for the car.
required: true
example: WVGZZZA1ZMP001337
selector:
text:
destinations:
name: Destinations
description: A destination or route to send to the car. Takes a list of destination dicts or a single destination dict. `geoCoordinate` is required, everything else is optional and for display purposes only.
required: true
example: |
- geoCoordinate:
latitude: 44.5905594
longitude: -104.7178527
- name: VW Museum
geoCoordinate:
latitude: 52.4278793
longitude: 10.8077433
- name: Autostadt
address:
country: Germany
street: Stadtbrücke
zipCode: 38440
city: Wolfsburg
geoCoordinate:
latitude: 52.429380
longitude: 10.791520
selector:
object:

0 comments on commit 7683e51

Please sign in to comment.