Volvo2Mqtt: Connect your AAOS Volvo 🚙

It solved it self, so to say. I checked the logs of the various Volvo sensors and noticed that the engine sensor had reported it was on, while the car was parked. The sensor reports now not active state and the app works normal. So that must be it but why the sensor reported active suddenly is a mystery.

1 Like

I was hoping to get this more refined before sharing, but since I’m in the US and Volvo shut off our API access, I can’t get it better, but I thought someone else might like it.

I was using the volvo2mqtt in conjunction with the wallbox evse to control the rate of charging my 2022 C40. I could set a departure time and a target charge level and it would adjust the amps provided by the wallbox to get the C40 to my target charge just as I wanted to leave. This would help make my batteries nice and warm. I also had it crank up the amps if I turned on the climate controls. It’s my first shot at a complicated automation so I know it is ruff. I’m also new to posting things here so if there’s a better place for something like this, let me know.

alias: c40 Above Target Charge
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.wallbox_portal_status_description_2
    from: null
    id: wallbox_state
  - platform: state
    entity_id:
      - sensor.volvo_??????_battery_charge_level
    id: c40_battery_level_change
  - platform: state
    entity_id:
      - input_number.c40_target_charge
    id: c40_target_charge_change
  - platform: device
    device_id: ??????
    domain: device_tracker
    entity_id: ????
    type: leaves
    zone: zone.home
    id: c40 left home
  - platform: device
    device_id: ????
    domain: device_tracker
    entity_id: ???????
    type: enters
    zone: zone.home
    id: c40 arrives home
  - platform: device
    type: turned_on
    device_id: ?????
    entity_id: ??????
    domain: switch
    id: c40_ac_on
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - wallbox_state
          - condition: state
            entity_id: sensor.wallbox_portal_status_description_2
            state: Ready
        sequence:
          - device_id: ????
            domain: number
            entity_id: ???
            type: set_value
            value: 48
          - type: turn_on
            device_id: ???
            entity_id: ????
            domain: switch
      - conditions:
          - condition: or
            conditions:
              - condition: trigger
                id:
                  - c40_battery_level_change
              - condition: trigger
                id:
                  - c40_target_charge_change
          - condition: device
            device_id: ?????
            domain: device_tracker
            entity_id: ????
            type: is_home
          - condition: template
            value_template: >-
              {{ (states('sensor.volvo_??????_battery_charge_level')
              | float ) >= ( states('input_number.c40_target_charge') | float )
              }}
          - condition: numeric_state
            entity_id: sensor.volvo_??????_battery_charge_level
            above: input_number.c40_target_charge
            enabled: false
          - condition: state
            entity_id: sensor.wallbox_portal_status_description_2
            state: Charging
            enabled: false
        sequence:
          - type: turn_off
            device_id: ?????
            entity_id: ?????
            domain: switch
      - conditions:
          - condition: or
            conditions:
              - condition: trigger
                id:
                  - c40_battery_level_change
              - condition: trigger
                id:
                  - c40_target_charge_change
          - condition: device
            device_id: ?????
            domain: device_tracker
            entity_id: ?????
            type: is_home
          - condition: numeric_state
            entity_id: sensor.volvo_?????_battery_charge_level
            below: input_number.c40_target_charge
          - condition: device
            type: is_off
            device_id: ????
            entity_id: ?????
            domain: switch
            enabled: false
        sequence:
          - variables:
              c40_target_amp: >-
                {{ (((75 * (((states('input_number.c40_target_charge')|int) -
                (states('sensor.volvo_??????_battery_charge_level')|int))/100))*1000)
                / ((((as_timestamp(states('input_datetime.c40_departure'))) -
                now().timestamp())/60)/60))/210 }}
          - service: notify.mobile_app_pixel_8_pro
            data:
              message: "{{ c40_target_amp }}"
            enabled: false
          - service: number.set_value
            data:
              value: "{{ c40_target_amp }}"
            target:
              entity_id: number.wallbox_portal_max_charging_current_2
          - type: turn_on
            device_id: ????
            entity_id: ?????
            domain: switch
          - service: input_number.set_value
            data: {}
            target:
              entity_id: input_number.thor_target_amp
            enabled: false
      - conditions:
          - condition: trigger
            id:
              - c40 left China
        sequence:
          - service: input_number.set_value
            data:
              value: 60
            target:
              entity_id: input_number.c40_target_charge
          - device_id: ??????
            domain: number
            entity_id: ????
            type: set_value
            value: 48
          - type: turn_on
            device_id: ???
            entity_id: ????
            domain: switch
      - conditions:
          - condition: trigger
            id:
              - c40 arrives home
        sequence:
          - device_id: ????
            domain: number
            entity_id: ????
            type: set_value
            value: 6
      - conditions:
          - condition: trigger
            id:
              - c40_ac_on
          - condition: device
            device_id: ???
            domain: device_tracker
            entity_id: ????
            type: is_home
        sequence:
          - type: turn_on
            device_id: ????
            entity_id: ????
            domain: switch
          - device_id: ????
            domain: number
            entity_id: ?????
            type: set_value
            value: 48
          - service: input_number.set_value
            data:
              value: 100
            target:
              entity_id: input_number.c40_target_charge
          - service: input_datetime.set_datetime
            data: {}
            target:
              entity_id: input_datetime.c40_departure
trace:
  stored_traces: 20
mode: single
1 Like

Hi,

Awesome add-on! My entities are constantly flapping in HA. The state is available for like 10 seconds and then show unavailable for 30 seconds and that cycle keeps on going. Did any encounter this? What can I do?
image

I see this in the logs:
Dec 11 12:55:12 volvo2mqtt [108] - WARNING: MQTT disconnected, reconnecting automatically
Dec 11 12:56:14 volvo2mqtt [108] - WARNING: MQTT disconnected, reconnecting automatically
Dec 11 12:57:15 volvo2mqtt [108] - WARNING: MQTT disconnected, reconnecting automatically
Dec 11 12:58:16 volvo2mqtt [108] - WARNING: MQTT disconnected, reconnecting automatically
Dec 11 12:59:17 volvo2mqtt [108] - WARNING: MQTT disconnected, reconnecting automatically

And this in my mqtt logs:
702296794: New connection from 172.17.0.1:46832 on port 1883.
1702296794: New client connected from 172.17.0.1:46832 as volvoAAOS2mqtt (p2, c1, k60).
1702296809: Client volvoAAOS2mqtt closed its connection.
1702296855: New connection from 172.17.0.1:46930 on port 1883.
1702296855: New client connected from 172.17.0.1:46930 as volvoAAOS2mqtt (p2, c1, k60).
1702296870: Client volvoAAOS2mqtt closed its connection.
1702296916: New connection from 172.17.0.1:47008 on port 1883.
1702296916: New client connected from 172.17.0.1:47008 as volvoAAOS2mqtt (p2, c1, k60).
1702296931: Client volvoAAOS2mqtt closed its connection.

I am getting this message in the log:

“s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
Dec 16 13:50:58 volvo2mqtt [106] - INFO: Starting volvo2mqtt version v1.8.21
Dec 16 13:50:58 volvo2mqtt [106] - WARNING: VCCAPIKEY ****************** isn’t working! Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application.
Dec 16 13:50:58 volvo2mqtt [106] - WARNING: No working VCCAPIKEY found, waiting 10 minutes. Then trying again!”

I am pretty sure i have the right key. I have only entered the primary key, not the secondary

Is the problem perhaps that i did not publish the app i made on the Volvo site?

Using MQTT add on
Located in the Netherlands

Same VCC-API-KEY issue here in Finland. Installed the add-on today, made a VCC API account and generated my API App (showing “Only for testing”), using Primary key for the AddOn but with error.

I think that there could be few lines more about the API creation in the README to clarify the pricess. Example is it needed to publish the App, which of the two key to use etc…

Hope to get this working as the legacy VolvoOnCall was not working as I swapped my old Volvo SensusOS car to a new with AAOS.

It take some time until the key is ready to use.
The primary key is correct, there is no need to publish your app.

1 Like

Thank you for your response. I will wait a couple of days.

The message in the Volvo2MQTT log has changed. It now reads:

“Dec 20 18:27:57 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 300 seconds.
Dec 20 18:32:57 volvo2mqtt [106] - INFO: Sending mqtt update…
Dec 20 18:32:57 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 300 seconds.
Dec 20 18:37:57 volvo2mqtt [106] - INFO: Sending mqtt update…
Dec 20 18:37:58 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 300 seconds.”

So, it looks like its working but i can’t find any Volvo related entities?

Look at that, so it has. I restarted the app, and now I am hetting A LOT of emtities frim my car. It just toom like 2 days to start working.

So restart the app.

EDIT: Problem solved! I am using the MQTT add-on but i forgot to tell the MQTT INTEGRATION to connect to the add on. It all works perfectly now.

I have a 2023 XC40 full electric

Solved Problem:
I restarted the Volvo2mqtt app and in the log i see a lot of messages like: success! Window front left is supported!

But when i look for an entity “binary_sensor.volvo” for example, nothing is found…

I am running HA on Virtual Machine, could this be the problem?

Can somebody help me with my issue from a few days ago?

I have it working by just following the instructions of the docker setup, and then you can get the data via the MQTT integration in HA. I have a Mosquitto MQTT broker running in a separate container for which I added the (login) data.

Maybe my question is a bit off-topic but I using the MQTT integration in HA with pleasure, thanks for the good work to make this possible.
Now I want to sent my volvo car data to ABRP route planner. I have issues with google maps now and then while ABRP is very convient to use.
I don’t now if the service to sent the car data to ABRP can be implemented into the Volvo2Mqtt. Otherwise it would be sufficient to me to program it as a service and use a automation to sent it every 10sec. So far this works from a browser:

https://api.iternio.com/1/tlm/send?api_key=****&token=*******0&tlm={“utc”:1553807658,“soc”:90.4,“soh”:97.7,“speed”:0,“lat”:29.564,“lon”:-95.025,“elevation”:50,“is_charging”:0,“power”:13.2,“ext_temp”:25,“batt_temp”:25,“car_model”:" volvo:xc40:20:75",“current”:36.66,“voltage”:360}’

Any help to program this automation in HA would be very helpful.

Thanks, I created a docker application in the end, just in case it’s of use to anyone else.

version: '3'

services:
    volvo2mqtt:
        image: ghcr.io/dielee/volvo2mqtt:1.8.22
        network_mode: host
        environment:
            - CONF_updateInterval=900
            - CONF_babelLocale=en_GB
            - 'CONF_mqtt=@json { "broker": "192.168.x.x", 
                "username": "user", 
                "password": "password",
                "port": 1883}'
            - 'CONF_volvoData=@json {"username": "[email protected]", 
                "password": "secret", 
                "vccapikey": ["myapikey", 
                                "anotherapikey"], 
                "odometerMultiplier": 1,
                "averageSpeedDivider": 1,
                "vin": "VIN",
                "averageFuelConsumptionMultiplier": 10}'
            - CONF_debug=false
            - TZ=Europe/London
1 Like

I didn´t get it - how can i link my VIN with the Volvo Developer Account?
I´m using my private email address for Volvo App Login and Google Auth for Dev portal.

Just use the rest_command for this link

Just found this and worked perfect, you can add 2022 S90 PHEV to the working car list.

It is working fine for my XC90 T8 2023 except for the sunroof status. In both states (open diagonally or fully open) the state remained closed after a couple of refreshes. Normal windows were working fine.

Does anyone else experience the same issue? Or are there people where the sunroof status just works fine?

In case someone else is wondering how he nmcrae85 set this up, I found this way which worked for me (there are special layout grid cards also available):
use vertical-stack as the basis, then add the image card as the first row, and proceed with vertical/horizontal stacks as required. I’ve chosen a slightly different arrangement

type: vertical-stack
cards:
  - type: picture
    image_entity: image.volvo_xc60_exterior_image
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-lock-card
        entity: lock.volvo_xc60_lock_status
        fill_container: true
        name: Lock State
      - type: vertical-stack
        cards:
          - type: custom:mushroom-entity-card
            entity: sensor.volvo_xc60_electric_range
            name: Electric Range
          - type: custom:mushroom-entity-card
            entity: sensor.volvo_xc60_battery_charge_level
            name: Charge Level
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-entity-card
        entity: device_tracker.volvo_xc60_location
        name: Location
      - type: custom:mushroom-entity-card
        entity: sensor.volvo_xc60_charging_connection_status
        name: Connection Status
      - type: custom:mushroom-entity-card
        entity: sensor.volvo_xc60_charging_system_status
        name: System Status
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-entity-card
        entity: sensor.volvo_xc60_distance_to_empty_tank

      - type: custom:mushroom-entity-card
        entity: sensor.volvo_xc60_odometer

  - type: horizontal-stack
    cards:
      - type: custom:mushroom-entity-card
        entity: sensor.volvo_xc60_estimated_charging_finish_time

      - type: custom:mushroom-entity-card
        entity: sensor.volvo_xc60_estimated_charging_time

  - type: horizontal-stack
    cards:
      - type: custom:mushroom-entity-card
        entity: switch.volvo_xc60_climate_status


as you can see I am using the “Mushroom” Collection for the cards

@darek_203 @baybod since you asked how to get this look

I have my username, password and vccapikey in Volvo config options.

Do I also need to use MQTT broker settings? It says
“Leave the settings as they are if you are using the MQTT Mosquitto Addon”
Do I still need to use a Docker?

From log:
Jan 13 20:24:46 volvo2mqtt [106] - INFO: Success! API Backend status is supported by your vehicle.
Jan 13 20:24:48 volvo2mqtt [106] - INFO: Sending mqtt update…
Jan 13 20:24:48 volvo2mqtt [106] - ERROR: API Call failed. Status Code: 401. Error: {
“status”: 401,
“error”: {
“message”: “Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application.”

I read it can take a while for the code to be active, is that the case here?