Audi connect - Sensor Status - display issue

Hi,
I have the Audi Connect Integration for Home Assistant up an running and getting the values from the car. So far so good!
Now I have tried to display them on a Dashboard, but obviously the values are not getting recognized properly so the icons are not changing once the values are changing. Using the picture element card:

type: picture-elements
elements:
  - type: conditional
    conditions:
      - entity: binary_sensor.audi_q4_sportback_e_tron_plug_lock_state
        attribute: Plug Status
        state: Eingesteckt
      - entity: binary_sensor.audi_q4_sportback_e_tron_plug_lock_state
        attribute: Charge Type
        state_not: AC_BASIC
    elements:
      - type: icon
        icon: mdi:ev-plug-type2
        tap_action: none
        double_tap_action: none
        hold_action: none
        style:
          top: 77%
          left: 22%
          color: green
  - type: conditional
    conditions:
      - entity: binary_sensor.audi_q4_sportback_e_tron_plug_lock_state
        attribute: Plug Status
        state_not: Eingesteckt
    elements:
      - type: icon
        icon: mdi:ev-plug-type2
        tap_action: none
        double_tap_action: none
        hold_action: none
        style:
          top: 77%
          left: 22%
          color: red
  - type: conditional
    conditions:
      - condition: state
        entity: binary_sensor.audi_q4_sportback_e_tron_doors_lock
        state: Abgeschlossen
    elements:
      - type: icon
        icon: mdi:lock
        tap_action: none
        double_tap_action: none
        hold_action:
          action: call-service
          service: script.unlock_q4
        style:
          top: 7%
          left: 90.5%
          color: black
  - type: conditional
    conditions:
      - condition: state
        entity: binary_sensor.audi_q4_sportback_e_tron_doors_lock
        state_not: Abgeschlossen
    elements:
      - type: icon
        icon: mdi:lock-open-variant
        tap_action: none
        double_tap_action: none
        hold_action:
          action: call-service
          service: script.lock_q4
        style:
          top: 7%
          left: 90.5%
          color: "#039be5"
  - type: state-label
    entity: lock.audi_q4_sportback_e_tron_door_lock
    style:
      left: 45%
      top: 50%
  - type: state-label
    entity: sensor.audi_q4_sportback_e_tron_mileage
    style:
      left: 21%
      top: 90%
      color: black
    prefix: "Kilometerstand: "
image: /api/image/serve/ed32bc059b540d206def58761cc837b5/512x512
title: Audi Q4

The account is registered in Germany so values are partially received in German obviously.

As you can see on the screen shot door lock status as well as charge connector status are show wrong although the condition seems to be fulfilled.
Do you have any ideas?

br
F.


Although the web interface gives you user-friendly state descriptors that reflect the kind of information the sensor is meant to tell you, like Eingesteckt and Abgeschlossen, these are binary_sensor entities that have only two states. In Home Assistant, those states are generically called “on” and “off”–and that’s the case whether the binary_sensor is telling you about door locks, lights, or whatever else.

I suspect that your problem is that you are using the user-friendly descriptors in your dashboard configuration, rather than the “on” and “off” that the logic engine that drives the dashboard conditions is expecting.

To figure out exactly what you should be calling the states in your dashboard state condition, go to Developer Tools → Template Editor, and use the states function to see what the actual state of each sensor is called. For example:

{{ states('binary_sensor.audi_q4_sportback_e_tron_plug_lock_state') }}

I suspect that when the Entities dashboard says “Abgeschlossen” (and I’m relying on Google translate here, so bear with me…), you’ll see states report off.

The “Plug Status” attribute on binary_sensor.audi_q4_sportback_e_tron_plug_lock_state is a different matter. Although it is an attribute of a binary_sensor, it is not constrained to the two possibilities (“on” and “off”) that the state of that sensor must use. To see if you’ve got the right value for the attribute, you can use:

{{ state_attr('binary_sensor.audi_q4_sportback_e_tron_plug_lock_state', 'Plug Status') }}

If the result is null, it means you’ve got the wrong attribute name. You can see all of the attributes by looking up the entity in Developer Tools → States.

Hopefully this sends you in the right direction.

Appreciate your support, I already had something similar in mind but didn´t know where to look at as I am just starting to get familiarized with HA.

Your post got me motivated to put some simple car-related UI on my dashboard, and I verified that the configuration should indeed use the “on”/“off.”

This is actually fairly easy to err on. If you edit the dashboard using the GUI, the Visibility state conditions are presented to you in the user-friendly terms (“Unlocked,” etc.). But when you pull up the code editor, you can see that it’s using “on” as the state in the code.

You are right, just did the changes and it is working now as expected!

Can you please open issues here: GitHub - audiconnect/audi_connect_ha: Adds an audi connect integration to home assistant

Maybe similar topic: Confusion between lock entities · Issue #534 · audiconnect/audi_connect_ha · GitHub

And there is also a topic already ongoing with binary_sensors: fix: BinarySensors external_power & climatisation_state & charging_state by Kolbi · Pull Request #536 · audiconnect/audi_connect_ha · GitHub