How to integrate my Cupra Born?

It’s installed automatically in the background by the component, but if you’ve installed the original VW component you’ve probably got an incorrect, non-forked version. Search the logs for “weconnect-python”.

Not finding anything mentioning weconnect-python… Starting to feel like a noobie here :sweat_smile:

Edit: Updating HA from 2023.3.5 tot 2023.3.6 has somehow fixed being able to configure the integration. Now getting a 500 error when retrieving data. Hopefully this is something that will be resolved automatically

Yes, upgrading HA clears out all of the Python libraries and forces them to redownload, so it will have cleared out your conflict.

Can you share the 500 error you’re seeing? (mine is working ok today)

Good to hear yours is working okay :slight_smile:
I see the following in the logs (I masked the VIN, but it’s the right one):

2023-03-28 11:03:06.841 ERROR (SyncWorker_0) [weconnect] Failed to retrieve data for VIN ************: Could not fetch data. Status Code was: 500
2023-03-28 11:03:06.845 ERROR (SyncWorker_0) [weconnect] Could not fetch data. Status Code was: 500
2023-03-28 11:05:06.854 ERROR (MainThread) [custom_components.volkswagen_we_connect_id] Timeout updating weconnect
2023-03-28 11:05:16.865 WARNING (MainThread) [homeassistant.components.binary_sensor] Setup of binary_sensor platform volkswagen_we_connect_id is taking over 10 seconds.
2023-03-28 11:05:16.869 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform volkswagen_we_connect_id is taking over 10 seconds.
2023-03-28 11:05:16.873 WARNING (MainThread) [homeassistant.components.number] Setup of number platform volkswagen_we_connect_id is taking over 10 seconds.
2023-03-28 11:05:16.876 WARNING (MainThread) [homeassistant.components.device_tracker] Setup of device_tracker platform volkswagen_we_connect_id is taking over 10 seconds.
2023-03-28 11:05:45.890 ERROR (SyncWorker_1) [weconnect] Failed to retrieve data for VIN ************: Could not fetch data. Status Code was: 500
2023-03-28 11:05:45.894 ERROR (SyncWorker_1) [weconnect] Could not fetch data. Status Code was: 500
2023-03-28 11:06:06.866 ERROR (MainThread) [homeassistant.components.binary_sensor] Setup of platform volkswagen_we_connect_id is taking longer than 60 seconds. Startup will proceed without waiting any longer.
2023-03-28 11:06:06.871 ERROR (MainThread) [homeassistant.components.sensor] Setup of platform volkswagen_we_connect_id is taking longer than 60 seconds. Startup will proceed without waiting any longer.
2023-03-28 11:06:06.876 ERROR (MainThread) [homeassistant.components.number] Setup of platform volkswagen_we_connect_id is taking longer than 60 seconds. Startup will proceed without waiting any longer.
2023-03-28 11:06:06.879 ERROR (MainThread) [homeassistant.components.device_tracker] Setup of platform volkswagen_we_connect_id is taking longer than 60 seconds. Startup will proceed without waiting any longer.

Can you confirm that you are seeing a weconnect-python version in your logs now? Should be just once, at startup. I assume you’ve at least managed to do the initial login and have the list of entities in HA under devices and services?

After this, can you see if you can try debug to find out which call is failing:

logger:
  default: warn
  logs:
    homeassistant.components.recorder: warn #debug
    custom_components.volkswagen_we_connect_id: debug
    weconnect: debug

We have seen situations in the past where certain cars at certain versions behave differently on the API, so this might be a localised issue for you. Has this ever worked for you, and how new is your car?

Unfortunately not seeing a weconnect-python version in the logs. Yesterday I have entered my username and password and it started to configure, but I have no entities available.

This has worked just before I started updating. My car is from december 2021.
I’m going to configure the logger and will report back.

Edit: Okay I now see the weconnect-python version is 0.49.16. Rest of the log can be found here and here.

Yeah, looks like your car is blowing up here:

DEBUG:weconnect:Retrieved data from url: https://ola.prod.code.seat.cloud.vwgroup.com/v1/vehicles/<vin>/status
DEBUG:weconnect:{"lights": "off", "engine": "off", "hood": {"open": "false", "locked": "false"}, "trunk": {"open": "false", "locked": "true"}, "doors": {"frontLeft": {"open": "false", "locked": "true"}, "frontRight": {"open": "false", "locked": "true"}, "rearLeft": {"open": "false", "locked": "true"}, "rearRight": {"open": "false", "locked": "true"}}, "windows": {"frontLeft": "closed", "frontRight": "closed", "rearLeft": "closed", "rearRight": "closed"}}

This is taken from my debug logs on the console, and I don’t see this in yours. I’m guessing that your car, being quite an early one, probably doesn’t support lock status which is why the most recent updates has broken it.

I notice that your car is missing state from the capabilities list here, when compared to my car:

{"capabilities": [{"id": "mapUpdate", "status": [], "expirationDate": "2032-03-09T23:59:59Z"}, {"id": "routing", "status": [], "expirationDate": "2032-03-09T23:59:59Z"}, {"id": "parkingInformation", "status": [], "expirationDate": "2032-03-09T23:59:59Z"}, {"id": "automation", "status": [], "expirationDate": "2032-03-09T23:59:59Z"}, {"id": "onlineSpeech", "status": [], "expirationDate": "2032-03-09T23:59:59Z"}, {"id": "chargingStations", "status": [], "expirationDate": "2032-03-09T23:59:59Z"}, {"id": "trafficInformation", "status": [], "expirationDate": "2032-03-09T23:59:59Z"}, {"id": "charging", "status": [], "expirationDate": "2032-03-09T23:59:59Z"}, {"id": "webRadio", "status": [], "expirationDate": "2032-03-09T23:59:59Z"}, {"id": "climatisation", "status": [], "expirationDate": "2032-03-09T23:59:59Z"}]}

I suspect that either your in-car hardware, or software level does not return lock status (boo!) and as such it’s failing the call. Can you confirm if the official app shows door lock / window status for you? For my car (mid-2022), this shows up as a yellow “unlocked” only when unlocked, but otherwise doesn’t really show much else:

Can you also send me your “services” page from the official app? (scroll down on main page)

Edit: Having pondered this over lunch, I’m pretty sure from earlier work that the above is correct and that vehicles not advertising “state” capability cannot provide lock, window and engine status information. On this basis, there’s a new version available here, which will detect this and not attempt to load this data - would appreciate it if you could test it. As always, just drop over the top of your existing custom component and restart HA. No need to mess around with anything else.

Thanks! Just installed the latest version and that works like a charm! Thank you for looking into this :smiley:
Everything is working fine, except the ability to set Target State of Charge and Target Temperature are missing.

The car is getting a software update tomorrow, so hopefully I get more entities in HA later :slight_smile:

Excellent, good news. Would you mind confirming your car’s software version before and after the update. Will be interesting to see what (if anything) gets changed as a result…

Surprised you can’t see the target charge and temperature. Can you do this in the official app?

At work I can see exactly how many kWh I have charged on the charging station and I think it would be great to see this again HA. I have tried to do this via a Riemann sum and a utility meter but unfortunately this does not work.
Has anyone already made a sensor that adds up the total power of a charge ?

Okay the update took longer than expected, but today I got the car back and I can say it’s a nice upgrade. Setting the target temperature and charge in HA are fixed and entities like odometer, location and door lock status are now available! Before update:

Hardware: H20
Software: 0796
ABT hardware: H43
ABT software: 6074
Navigation database: 20.7
Media-codec: 3.1.4

Available entities in HA: about 29

After update:

Hardware: H20
Software: 0561
ABT hardware: H43
ABT software: 6085
Navigation database: 22.9
Media-codec: 3.1.4

Available entities in HA: 59!

2 Likes

Ah, VW. Where the software version goes down but new features get added :slight_smile:

Glad this is all working for you. Hopefully will help others having similar issues, and glad to hear that the component automatically picked up your additional capabilities and turned on the new features.

2 Likes

I’m also seeing some problems… My car is arriving in the beginning of may, but I wanted to set this up beforehand. Setup of the profile is done. Could that cause these problems?

The logs are from the version released march 28th, found here, and I just copied the volkswagen_we_connect_id folder to custom components and restarted HA.

I only get two fields, username and password, and the option for VW or Cupra.
Unexpected error

Traceback (most recent call last):
  File "/config/custom_components/volkswagen_we_connect_id/config_flow.py", line 75, in async_step_user
    info = await validate_input(self.hass, user_input)
  File "/config/custom_components/volkswagen_we_connect_id/config_flow.py", line 51, in validate_input
    await hass.async_add_executor_job(we_connect.update)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/weconnect/weconnect.py", line 176, in update
    self.__api.update(updateCapabilities=updateCapabilities, updatePictures=updatePictures, force=force, selective=selective)
  File "/usr/local/lib/python3.10/site-packages/weconnect/api/cupra/api.py", line 39, in update
    self.updateVehicles(updateCapabilities=updateCapabilities, updatePictures=updatePictures, force=force, selective=selective)
  File "/usr/local/lib/python3.10/site-packages/weconnect/api/cupra/api.py", line 45, in updateVehicles
    data = self.__fetcher.fetchData(url, force)
  File "/usr/local/lib/python3.10/site-packages/weconnect/fetch.py", line 74, in fetchData
    raise RetrievalError(f'Could not fetch data. Status Code was: {statusResponse.status_code}')
weconnect.errors.RetrievalError: Could not fetch data. Status Code was: 403

The charging station at work shows how many kWh I have charged in total during a charge, I now also wanted to process this in HA so that I can see how much I have charged in total at public charging stations.

The Cupra Born provides a sensor (sensor.cupra_born_charge_power) with a measurement unit kW
Created a Riemann sum integral sensor with helpers and created a utility meter, because I have to go from Kw to kWh and reset to 0 per day.

Yesterday I put my car at the charging station at work and after finish immediately took a picture of the total charged kWh and compared it at home with what was in HA.
According to the charging station at work, I have charged 31.36 kWh (I can now also see this in the lease company’s app) and according to the sensor I created in HA 109.36 kWh.

The sensor I created in HA starts at 0 and then runs straight to 90.21 kWh from there it steps up to 109.36 kWh. If I look at the difference between 90.21 kWh and 109.36 kWh, I don’t get 31.36 kWh, but 19.15 kWh (109.36 kWh - 90.21 kWh)

Been trying all morning to understand what is not going well now.
Does anyone have an idea what is not going well or a working solution to show the total KWh charged per charge?

More info about the sensors
sensor.kwh_sensor (Riemann som integrale sensor)

state_class: total
source: sensor.cupra_born_charge_power
unit_of_measurement: kWh
device_class: energy
icon: mdi:chart-histogram
friendly_name: kwh sensor

sensor.batterij_kwh (utility meter)

state_class: total_increasing
source: sensor.kwh_sensor
status: collecting
last_period: '109.36'
last_valid_state: None
meter_period: daily
cron pattern: 0 0 * * *
last_reset: '2023-03-30T22:00:00.010763+00:00'
unit_of_measurement: kWh
device_class: energy
icon: mdi:counter

Almost certainly, your issue is that your car isn’t properly registered with you, which is something that (at least in my own experience) you can only do when physically sat in it. A good starting point is to get the official app working first. If you can get this working, this integration should probably work without issue. Have you tried this?

Unfortunately, I’m away for a bit otherwise I’d have tried this myself. When I get back, if you’ve not solved it, I’ll have a go myself as it looks quite a useful thing to be able to do.

1 Like

No problem. There’s no cow on the ice, as we say in Sweden :sweat_smile:
The app is working fine though there is no car as you know. I won’t look further into this, unless you ask me to try something, before I have the car :slight_smile:

1 Like

Ahh sweet, I’ve just updated to the latest version of this branch and most features are working on my early edition Born on the 1st version of the software. Hassio now works better than the cupra app!

When I say most features… I mean the ones I know my cars crappy software supports

Hi
I’ve wanted to do exactly the same and record the kWhs put into the charge.
I initially tried our approach using the Riemann sum sensor and the cupra.born.charge.power enitity, which fed into HA utility meter helper. Suffice to say, i gave up because it’s just not accurate enough despite trying lots of different permutations.

My current solution is to have my granny charger plugged into a zigbee smart plug that has power monitoring, and capture the ‘cumulative charge’ stat in a HA utility meter helper. This works and matches the calculated input (kWh x hours of charging).
I also use the new HA Google Docs integration to log my daily Cupra charge amount on a google sheets doc (which also captures my house elec + gas usage and solar generation stats).

There are a couple of downsides to this approach:
Firstly, I have my granny charger mounted in a waterproof function box on the side of my house (more for security than anything else, as the charger is waterproof) and adding a smart plug adds bulk.
Secondly, you need a high quality smart plug that can handle the sustained load (3Kw/13a for my granny charger) and has a reliable signal connection to the house. I’ve been through a few different smart plugs and I’m currently using a Tuya 20A. My previous Tuya 13A and 16A plugs would randomly turn off - ? due to load. Also, they will drop off the zigbee network occasionally and by default return to power off when reconnecting, stopping the charge cycle. My latest 20A Tuya plug can be set to restore it’s power on reconnection. so far it’s been much more reliable but if i have any problems i’ll switch to one of my Philips smartthings plugs which seem to be far better built, but i’d rather have use a cheaper Tuya plugs if running a EV charger through them shortens their lifespan.

In the future, i plan to get a proper EV charger like a Zappi, which i’ll be able to pull the charging stats directly into HA.
I could also get a zigbee CT clamp power monitor and attach it around the 32A line for the EV charger power supply, but would struggle to fit another CT clamp in my already crowded fuse box.

For the VW ID cars, there is a ‘VW Friend’ github plugin (that shares the same base code as this) that can log charging and driving sessions, but i don’t think the Cupra’s are compatible.
Possibility for a Cupra branch?

1 Like

Unfortunately I can’t place a charging station at home, otherwise that would be the easiest solution. Hopefully there will be another solution.