Custom Integration: Volkswagen WeConnect ID (Europe)

Hi all,

I’m working on my first custom integration. In Europe we use the We Connect ID app to control basic functions of our electric Volkswagens, in the USA the CarNet app is used.

At this moment the integration is in a very early fase but i like to get feedback and help people that have the same car and want to add it to their setup.

  • Sensors for SoC
  • Sensors for Climate
  • Service to set target SoC
  • Service to start climatization with target heat (cool/heat)

Example automations:
Start warming up the cabin when it’s freezing outside

- alias: Car - Start preheating the cabin when it's freezing
  id: 4008ba82-bb35-4b2f-85b3-96dca152efd1 # Make this unique
  trigger:
    - platform: time
      at:
        - "07:00:00"
  condition:
    condition: numeric_state
    entity_id: weather.torentje
    attribute: temperature
    below: 1
  action:
  - service: volkswagen_we_connect_id.volkswagen_id_set_climatisation
    data:
      vin: WVGZZZE2ZMP4201337
      start_stop: start
      target_temp: 20

My advice is to create a seperate automation for when the car actually starts heating up, the VW api is really slow and not really bullit proof.

Send messsage when car is heating up:

automation:
- alias: Car - Notification when car started to heat up the cabin
  id: 919b5fbf-b1c7-41ec-a31f-3c9a14785bf0 # Make this unique
  trigger:
    - platform: state
      entity_id: sensor.volkswagen_id_komo_climatisation_state # Change entities
      to: "heating"
  action:
    - service: notify.mobile_app_mitchells_ifoon_app # Change entities
      data:
        message: "🔥 Komo is heating up the cabin to {{states.sensor.volkswagen_id_komo_target_temperature.state}}°C. It's done at {{ (now()|as_timestamp + (float(states('sensor.volkswagen_id_komo_remaining_climatisation_time')) * 60 ))|timestamp_custom('%H:%M', True) }}." # Change entities or change the message
        data:
          url: "/lovelace-car/car"
          push:
            thread-id: "car-group"

Send messsage when car is done charging:

- alias: Car - Notification when car is done charging
  id: 22a8347c-4001-4795-a3de-71a89a428806 # Make this unique
  trigger:
    - platform: template
      value_template: "{{ states.sensor.volkswagen_id_komo_state_of_charge.state == states.sensor.volkswagen_id_komo_target_state_of_charge.state }}" # Change entities
  action:
    - service: notify.mobile_app_mitchells_ifoon_app # Change entities
      data:
        message: "🔋 Komo is done charging, current range is now {{states.sensor.volkswagen_id_komo_range.state}}km." # Change entities
        data:
          url: "/lovelace-car/car"
          push:
            thread-id: "car-group"

Send messsage when car has an error while charging:

- alias: Car - Notification when car errored
  id: 791366e0-df10-465a-8706-30017d08ea91 # Make this unique
  trigger:
    - platform: state
      entity_id: sensor.volkswagen_id_komo_charging_state # Change entities
      from: "charging"
      to: "error"
  action:
    - service: notify.mobile_app_mitchells_ifoon_app # Change entities
      data:
        message: "🚨 Komo has an error while charging with {{states.sensor.volkswagen_id_komo_range.state}}km range." # Change entities
        data:
          url: "/lovelace-car/car"
          push:
            thread-id: "car-group"

Send messsage when car started charging:

- alias: Car - Notification when car started charging
  id: dadf86c7-fd05-4aff-9891-e3d9f1eaf4dc # Make this unique
  trigger:
    - platform: state
      entity_id: sensor.volkswagen_id_komo_charging_state # Change entities
      to: "charging"
  action:
    - service: notify.mobile_app_mitchells_ifoon_app # Change entities
      data:
        message: "⚡ Komo started charging. It's done at {{ (now()|as_timestamp + (float(states('sensor.volkswagen_id_komo_remaining_charging_time')) * 60 ))|timestamp_custom('%H:%M', True) }} and will have {{states.sensor.volkswagen_id_komo_target_state_of_charge.state}}% battery." # Change entities
        data:
          url: "/lovelace-car/car"
          push:
            thread-id: "car-group"
13 Likes

Released a new version with the login fix from the weconnect lib.

Great work @mitchztm!
A quick question, from what I understand from VW, they are about to introduce more functionality for their Connect ID app. It will be more aligned with their older app for ICE/hybrid cars, in terms of functionality. Are your ambition to implement new features if they are coming, or are you happy with the integration as it is?

1 Like

This integration is a work in progress i will look at ever new available feature and try to implement it.

3 Likes

As told before in the other topic, great effort you did here, thanks again.
I made it like this:

For those who like to know i’ll post the lovelace code, here it is.
Please be awere to change the entities to your own.
I made in my root configuration a folder called “www” and put the pictures in there ( i just googled to an identical vehicle i have and downloaded these pics)
Make a vertical stack card, switch to “view code editor” and past these lines
Then switch back to “view visual editor”, adjust the names and sensors and click on “header” to select your desired picture. After that change your icons as preffered, the ones used are adjusted to my personal prefference.

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: sensor.volkswagen_id_id_4_pro_performance_range
        name: ID4 Actieradius
        icon: mdi:speedometer
      - entity: binary_sensor.volkswagen_id_id_4_pro_performance_plug_connection_state
        name: Connected
      - entity: sensor.volkswagen_id_id_4_pro_performance_charge_rate
        name: Laadsnelheid Km/H
      - entity: sensor.volkswagen_id_id_4_pro_performance_remaining_charging_time
        name: Resterende laadtijd
        icon: mdi:clock-end
    title: Batterij info
    header:
      type: picture
      image: /local/id4-4.jpg
      tap_action:
        action: none
      hold_action:
        action: none
  - type: horizontal-stack
    cards:
      - type: gauge
        entity: sensor.volkswagen_id_id_4_pro_performance_state_of_charge
        min: 0
        max: 100
        name: Accu status
        unit: '%'
        severity:
          green: 60
          yellow: 40
          red: 20
      - type: gauge
        entity: sensor.volkswagen_id_id_4_pro_performance_charge_power
        min: 0
        max: 125
        name: Laadsnelheid
        severity:
          green: 0
          yellow: 80
          red: 110
        unit: kW/H
        needle: true
    header:
type: entities
entities:
  - entity: button.volkswagen_id_id_4_pro_performance_start_climate
    name: Climatisering aan/uit
    secondary_info: last-updated
  - entity: binary_sensor.volkswagen_id_id_4_pro_performance_rear_window_heating_state
    name: Achterruit verwarming
    icon: mdi:thermometer-lines
  - entity: >-
      binary_sensor.volkswagen_id_id_4_pro_performance_front_window_heating_state
    name: Voorruit verwarming
    icon: mdi:thermometer-chevron-up
  - entity: binary_sensor.volkswagen_id_id_4_pro_performance_zone_front_left_enabled
    name: Zone linksvoor
    icon: mdi:thermometer-low
  - entity: binary_sensor.volkswagen_id_id_4_pro_performance_zone_front_right_enabled
    icon: mdi:thermometer-low
    name: Zone rechtsvoor
  - entity: sensor.volkswagen_id_id_4_pro_performance_climatisation_state
    name: Climatisering status
    icon: mdi:air-conditioner
  - entity: sensor.volkswagen_id_id_4_pro_performance_remaining_climatisation_time
    icon: mdi:air-conditioner
    name: Resterende tijd clima
  - entity: sensor.volkswagen_id_id_4_pro_performance_target_temperature_c
    name: Ingestelde temperatuur
title: Climatisering
state_color: true
header:
  type: picture
  image: /local/id4-11.jpg
  tap_action:
    action: none
  hold_action:
    action: none
show_header_toggle: false
5 Likes

I’ve added your example to the info.md file so people get it from HACS as well :slight_smile:

1 Like

What is the difference between this integration and the one that I’m already using?

(No Offence)

That integration does not support the new Electric Volkswagen ID series.
As they mention in the description: homeassistant-volkswagencarnet/README.md at e6bfc83ca46bc1e06700f9d9b1d64de235e86f64 · robinostlund/homeassistant-volkswagencarnet · GitHub

Thanks for that, I should have read a little longer and I would’ve got to that eventually :slight_smile:

Got a 504 from the VW Api again. Think they are working on it.

The 504 is fixed. Also i’ve added a check that only ID cars are added.
Got some issues from other people who had non-ID cars in their account and it broke the integration.

1 Like

Hi guys, and @mitchztm!
I wasn’t happy with the installation of HA I had, so I started up a new installation. But now I have some issues adding your glorious integration.
I added the github link to a custom repository in HACS and downloaded the latest version (0.7.1 I think). Restarted the server and cleared cache, as always.

After the integration was installed, and I have entered my VW credentials, the integration won’t start, I get this error message in the log:

Logger: homeassistant.config_entries
Source: custom_components/volkswagen_we_connect_id/init.py:45
Integration: Volkswagen We Connect ID (documentation)
First occurred: 15:57:44 (1 occurrences)
Last logged: 15:57:44

Error setting up entry Volkswagen We Connect ID for volkswagen_we_connect_id
Traceback (most recent call last):
** File “/usr/src/homeassistant/homeassistant/config_entries.py”, line 327, in async_setup**
** result = await component.async_setup_entry(hass, self)**
** File “/config/custom_components/volkswagen_we_connect_id/init.py”, line 45, in async_setup_entry**
** if car_type.value == RangeStatus.CarType.ELECTRIC:**
AttributeError: ‘bool’ object has no attribute 'value’

Any ideas?

Took a quick look on the init_.py file in Visual Code and there it seems that my credentials aren’t entered? Correct? Also, I didn’t get the option to add the VIN. Should that be entered in some config file instead?

Can you try the new version, i made a lot of changes.

Thanks! I will try the new version, but it is a bit of a struggle.
I removed the integration and started all over from the repository, downloaded 0.0.8 in HACS, restarted the serer and went to Integrations to install VWID. It has been like this for 30 minutes now. :slight_smile:
image
(Sorry for the swedish text).

I will restart everything and start all over

Hmm tried to readd on my instance and did not got that response.
If it takes longer then a minute it’s not okay.

Thanks for checking! I had another try on the old installation again, this time it works a bit better.
I get the login screen (but no field for VIN?)
image

I get the confirmation:
image

But still some error messages:
This error originated from a custom integration.

Logger: custom_components.volkswagen_we_connect_id
Source: custom_components/volkswagen_we_connect_id/init.py:52
Integration: Volkswagen We Connect ID (documentation)
First occurred: 09:15:26 (3 occurrences)
Last logged: 09:16:22

Unexpected error fetching volkswagen_we_connect_id data: ‘bool’ object has no attribute ‘value’
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 187, in _async_refresh
self.data = await self._async_update_data()
File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 147, in _async_update_data
return await self.update_method()
File “/config/custom_components/volkswagen_we_connect_id/init.py”, line 52, in async_update_data
if car_type.value == RangeStatus.CarType.ELECTRIC:
AttributeError: ‘bool’ object has no attribute ‘value’

@mitchztm, I continued to think about this issue. Beside my ID.X I also have a Passat (ICE), that car does not work with ID Connect, obviuosly, it is connect to a different app (We Connect?). However, it is still visible in ID Connect, and maybe that is why I get the error message:
File “/config/custom_components/volkswagen_we_connect_id/init .py”, line 52, in async_update_data
if car_type.value == RangeStatus.CarType.ELECTRIC:
AttributeError: ‘bool’ object has no attribute ‘value’

To summarize, the improvement you made (check for electric vehicle) might be stopping me to install the integration since I have an ICE car visible?!

Sorry for spamming @mitchztm! Just tested to remove the other car from my general VW account. Now the integration works.
It is a good check to rule out ICE car owners, but it is a bit challenging for us that do have an ICE car also. Just food for thoughts.

Thanks for your support!

You can spam me all you want :wink:

My intention was to just skip the ICE cars from adding. Do you have two cars in you HomeAssistant now? Or did it got excluded somewhere else.