skodaconnect / homeassistant-skodaconnect

Skoda Connect - A home assistant plugin to add integration with your car
Apache License 2.0
222 stars 29 forks source link
custom-component hacs homeassistant skoda-connect

Version PyPi Downloads

IMPORTANT NOTE

This integration currently only supports the old Skoda API compatible with the old Skoda Essentials App.

If you are unable to use the Skoda Essentials account the integration will not work for you. This is the case for new vehicles and/or Skoda accounts.

We are aware the Skoda Essentials app is being deprecated and are working on updating the integration to be compatible with the new API / MySkoda app, but this is a major piece of development work.

Please do not open new issues for this.

Maintainers and contributors needed

Keeping up with changes made by Skoda/VAG to the API requires coders with access to various cars and the ability to reverse engineer changes and new features into this project. Contributions in the form of raised issues and pull requests are much needed in order to maintain the functionality for all different models of Skoda cars.

Contributors and maintainers will naturally drift away from the project once they either no longer own a Skoda or move away from Home Assistant. As a results, there aren't really any long-term maintainers or contributors still active. But we do what we can to keep the project alive and up to date.

For questions, further help or contributions you can join the Discord server at https://discord.gg/826X9jEtCh.

Skoda Connect - A Home Assistant custom component for Skoda Connect/MyŠKODA

If you are new to Home Assistant, please read the Home Assistant documentation first.

This is fork of robinostlund/homeassistant-volkswagencarnet modified to support Skoda Connect/MySkoda through native app API (API calls directly to vwg-connect services)

This integration for Home Assistant will fetch data from Skoda Connect servers related to your Skoda Connect enabled car. Skoda Connect never fetch data directly from car, the car sends updated data to VAG servers on specific events such as lock/unlock, charging events, climatisation events and when vehicle is parked. The integration will then fetch this data from the servers. When vehicle actions fails or return with no response, a force refresh might help. This will trigger a "wake up" call from VAG servers to the car. The scan_interval is how often the integration should fetch data from the servers, if there's no new data from the car then entities won't be updated.

This project contains the Home Assistant custom component code. It depends on https://github.com/skodaconnect/skodaconnect which provides the Python library interacting with the Skoda API.

Supported setups

This integration will only work for your car if you have Skoda Connect/MyŠKODA functionality. Cars using other third party, semi-official, mobile apps such as the "MinSkoda" from ConnectedCars in Denmark won't work. The library used for API communication is reverse engineered from the MySkoda Android app. Initial support has been added for SmartLink and newer style API cars, such as the Enyaq iV.

The car privacy settings must be set to "Share my position" for full functionality of this integration. Without this setting, if set to "Use my position", the sensors for position (device tracker), requests remaining and parking time might not work reliably or at all. Set to even stricter privacy setting will limit functionality even further.

If you encounter problems

If you encounter a problem where the integration can't be setup or if you receive an error that there's unaccepted terms or EULA, it might be because of your mobile app platform. The underlying library is built by reverse engineering the Android App behavior and thus it use the same client configurations as an Android device. If you only use the app on iPhone/iOS devices it might cause issues with this integration.

Possible workarounds:

If this does not work for you and the particular problem you are facing, please open an issue and provide as detailed problem description as possible and relevant debug logs.

What is working, all cars

Additional information/functions VW-Group API ("All" Skodas except Enyaq iV so far)

Additional information/functions Skoda native API (Enyaq iV so far)

Under development and BETA functionality (may be buggy)

What is NOT working

Breaking changes

Installation

Install with HACS (recomended)

If you have HACS (Home Assistant Community Store) installed, just search for Skoda Connect and install it direct from HACS. HACS will keep track of updates and you can easly upgrade to the latest version when a new release is available.

If you don't have it installed, check it out here: HACS

Manual installation

Clone or copy the repository and copy the folder 'homeassistant-skodaconnect/custom_component/skodaconnect' into '[config dir]/custom_components'. Install required python library with (adjust to suit your environment):

pip install skodaconnect

Enable debug logging

For comprehensive debug logging you can add this to your <config dir>/configuration.yaml:

logger:
  default: info
  logs:
    skodaconnect.connection: debug
    skodaconnect.vehicle: debug
    custom_components.skodaconnect: debug
    custom_components.skodaconnect.climate: debug
    custom_components.skodaconnect.lock: debug
    custom_components.skodaconnect.device_tracker: debug
    custom_components.skodaconnect.switch: debug
    custom_components.skodaconnect.binary_sensor: debug
    custom_components.skodaconnect.sensor: debug

Configuration

Configuration in configuration.yaml is now deprecated and can interfere with setup of the integration. To configure the integration, go to Configuration in the side panel of Home Assistant and then select Integrations. Click on the "ADD INTEGRATION" button in the bottom right corner and search/select skodaconnect. Follow the steps and enter the required information. Because of how the data is stored and handled in Home Assistant, there will be one integration per vehicle. Setup multiple vehicles by adding the integration multiple times.

Configuration options

The integration options can be changed after setup by clicking on the "CONFIGURE" text on the integration. The options available are:

Automations

In this example we are sending notifications to an ios device. The Android companion app does not currently support dynamic content in notifications (maps etc.)

Save these automations in your automations file <config dir>/automations.yaml

Use input_select to change pre-heater duration

First create a input_number, via editor in configuration.yaml or other included config file, or via GUI Helpers editor. It is important to set minimum value to 10, maximum to 60 and step to 10. Otherwise the service call might not work.

# configuration.yaml
input_number:
  pheater_duration:
    name: "Pre-heater duration"
    initial: 20
    min: 10
    max: 60
    step: 10
    unit_of_measurement: min

Create the automation, in yaml or via GUI editor. You can find the device id by going to Settings->Devices & Services and then clicking on the device for the Skodaconnect vehicle. The device ID will show in the web browser address bar after "/config/devices/device/". The ID can also be found by using the GUI services editor under developer tools. Choose one of the skodaconnect services and choose your vehicle. Change to YAML mode and copy the device ID.

# automations.yaml
- alias: Pre-heater duration
  description: ""
  trigger:
    - platform: state
      entity_id: input_number.pheater_duration
  condition: []
  action:
    - service: skodaconnect.set_pheater_duration
      data_template:
        device_id: <Your Device ID for vehicle>
        duration: "{{ (states('input_number.pheater_duration') | float ) | round(0) }}"
  mode: single

Charge rate guesstimate

Thanks to @haraldpaulsen An estimated charge rate template sensor based on battery capacity and reported time left. Replace with the name of your vehicle and with battery capacity in Wh.

template:
  - sensor:
    - name: "Charge speed guesstimate"
      state: >
        {% if is_state('switch.skoda_<name>_charging', 'on') %}
          {% set battery_capacity = <battery-size-in-kwh> | int %}
          {% set charge = { "remaining": states('sensor.skoda_<name>_minimum_charge_level') | int - states('sensor.skoda_<name>_battery_level') | int } %}
          {% set timeleft = states('sensor.skoda_<name>_charging_time_left') | int %}
          {% set chargeleft = battery_capacity * charge.remaining / 100  %}
          {% set chargespeed = chargeleft / (timeleft / 60) %}
          {{ chargespeed | round (1) }}
        {% else %}
          0
        {% endif %}
      unit_of_measurement: "kW"
      state_class: measurement

Get notification when your car is on a new place and show a map with start position and end position

Note: only available for iOS devices since Android companion app does not support this yet. This might be broken since 1.0.30 when device_tracker changed behaviour.

- id: notify_skoda_position_change
  description: Notify when position has been changed
  alias: Skoda position changed notification
  trigger:
    - platform: state
      entity_id: device_tracker.kodiaq
  condition: template
    condition: template
    value_template: "{{ trigger.to_state.state != trigger.from_state.state }}"
  action:
    - service: notify.ios_my_ios_device
      data_template:
        title: "Kodiaq Position Changed"
        message: |
          🚗 Skoda Car is now on a new place.
        data:
          url: /lovelace/car
          apns_headers:
            'apns-collapse-id': 'car_position_state_{{ trigger.entity_id.split(".")[1] }}'
          push:
            category: map
            thread-id: "HA Car Status"
          action_data:
            latitude: "{{trigger.from_state.attributes.latitude}}"
            longitude: "{{trigger.from_state.attributes.longitude}}"
            second_latitude: "{{trigger.to_state.attributes.latitude}}"
            second_longitude: "{{trigger.to_state.attributes.longitude}}"
            shows_traffic: true

Announce when your car is unlocked but no one is home

- id: 'notify_skoda_car_is_unlocked'
  alias: Skoda is at home and unlocked
  trigger:
    - entity_id: binary_sensor.vw_carid_external_power
      platform: state
      to: 'on'
      for: 00:10:00
  condition:
    - condition: state
      entity_id: lock.kodiaq_door_locked
      state: unlocked
    - condition: state
      entity_id: device_tracker.kodiaq
      state: home
    - condition: time
      after: '07:00:00'
      before: '21:00:00'
  action:
    # Notification via push message to smartphone
    - service: notify.device
      data:
        message: "The car is unlocked!"
        target:
          - device/my_device
    # Notification via smart speaker (kitchen)
    - service: media_player.volume_set
      data:
        entity_id: media_player.kitchen
        volume_level: '0.6'
    - service: tts.google_translate_say
      data:
        entity_id: media_player.kitchen
        message: "My Lord, the car is unlocked. Please attend this this issue at your earliest inconvenience!"