Mercedes Me Component

Hi Richard,;

I’m not getting the values for my tire pressure:

  car_tire_pressure_rear_left:
        friendly_name: Tire pressure Rear Left
        value_template: '{{ states.binary_sensor.2_amu_833_tire_warning.attributes.tirepressureRearLeft }}'
      car_tire_pressure_rear_right:
        friendly_name: Tire pressure Rear Right
        value_template: '{{ states.binary_sensor.2_amu_833_tire_warning.attributes.tirepressureRearRight }}'
      car_tire_pressure_front_left:
        friendly_name: Tire pressure Front Left
        value_template: '{{ states.binary_sensor.2_amu_833_tire_warning.attributes.tirepressureFrontLeft }}'
      car_tire_pressure_front_right:
        friendly_name: Tire pressure Front Right
        value_template: '{{ states.binary_sensor.2_amu_833_tire_warning.attributes.tirepressureFrontRight }}'

I’ll keep getting this error:

Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: expected token ‘end of print statement’, got ‘_amu_833_tire_warning’) for dictionary value @ data[‘sensors’][‘car_tire_pressure_front_left’][‘value_template’]. Got ‘{{ states.binary_sensor.2_amu_833_tire_warning.attributes.tirepressureFrontLeft }}’
invalid template (TemplateSyntaxError: expected token ‘end of print statement’, got ‘_amu_833_tire_warning’) for dictionary value @ data[‘sensors’][‘car_tire_pressure_front_right’][‘value_template’]. Got ‘{{ states.binary_sensor.2_amu_833_tire_warning.attributes.tirepressureFrontRight }}’
invalid template (TemplateSyntaxError: expected token ‘end of print statement’, got ‘_amu_833_tire_warning’) for dictionary value @ data[‘sensors’][‘car_tire_pressure_rear_left’][‘value_template’]. Got ‘{{ states.binary_sensor.2_amu_833_tire_warning.attributes.tirepressureRearLeft }}’
invalid template (TemplateSyntaxError: expected token ‘end of print statement’, got ‘_amu_833_tire_warning’) for dictionary value @ data[‘sensors’][‘car_tire_pressure_rear_right’][‘value_template’]. Got ‘{{ states.binary_sensor.2_amu_833_tire_warning.attributes.tirepressureRearRight }}’. (See ?, line ?).

Been working on this the whole day :slight_smile:

Any idea ?

Kr,

Bart

I have the exact same problem, no “.mercedesme-token-cache” is created in my config folder. running Home assistant OS on rpi fyi.

Error log:
2021-12-22 22:45:48 ERROR (MainThread) [custom_components.mbapi2020.oauth] Error requesting data from https://id.mercedes-benz.com/as/token.oauth2: 400, message=‘Bad Request’, url=URL(‘https://id.mercedes-benz.com/as/token.oauth2’)
2021-12-22 22:45:48 ERROR (MainThread) [custom_components.mbapi2020] Authentication failed. Please reauthenticate.

Well it looks like it’s not recognising the entity name “binary_sensor.2_amu_833_tire_warning”
Is it definitely correct? Does it expose the attributes you expect in Developer Tools?

Incidentally, since the time that mobiledude did his templates that I copied, Rene added many attributes as sensors. So it’s not strictly necessary to create templates for all of the attributes you want

Hi Richard,

That’s exactly what I was thinking, but the entity “binary_sensor.2_amu_833_tire_warning” is correctly mentioned in the entities:

Any other idea ?
Kr,

Bart

Hi Sam,

please make sure that you run version 0.5.14 and restart HA after the update. Then please authenticate or delete the integration (plus restart of HA) and add it again.

BR
Rene

Hi Bart,

please use the state_attr() function to select the value.

value_template: '{{ state_attr("binary_sensor.2_amu_833_tire_warning", "tirepressureRearLeft") }}'

Check the yellow warning boxes here too :slight_smile:

BR
Rene

PS: I have created an issue in the HA-core repo. Problem is that the entityId starts with a numeric value.

Hi,

I’m wondering, how have you transformed the state-badge (displaying the fuel %) into a gauge badge ?
Could you help me out ?

Kr,

Bart

I can certainly try. I actually used the flex-horsehoe card nested inside the picture element card.

Here is the relevant code.

              - type: custom:flex-horseshoe-card
                entities:
                  - entity: sensor.221804_fuel_level
                    decimals: 1
                    unit: '%'
                    area: Fuel
                show:
                  horseshoe_style: colorstopgradient
                layout:
                  states:
                    - id: 0
                      entity_index: 0
                      xpos: 50
                      ypos: 60
                      styles:
                        - font-size: 4em;
                  areas:
                    - id: 0
                      entity_index: 0
                      xpos: 50
                      ypos: 35
                      styles:
                        - font-size: 3em;
                        - opacity: 0.8;
                horseshoe_scale:
                  min: 0
                  max: 100
                color_stops:
                  '25': red
                  '40': yellow
                  '60': green
                style:
                  top: 70%
                  left: 0%
                  width: 7em
                  height: 8em
                  transform: none
                  '--ha-card-background': transparent

@weemaba999 If you’re interested. I actually took my dashboard one step further and made a custom button card that when pressed opens a popup that summarizes all of my data. Very handy in a mobile view.

image

2 Likes

Hi @rmertz3282,

That looks VERY AWESOME !!! very nice done ! If it’s not too much trouble, I’d love to have a look at the config

Kr,

Bart

I use the decluttering card a lot but I think you can figure out what is happening.

              - type: 'custom:decluttering-card'
                template: car_template
                variables:
                  - entity: device_tracker.la221804_device_tracker
                  - person: person.ranman
                  - image: GLS450
                  - name: GLS
                  - filter: '*la221804*'
                  - fuel_level: sensor.la221804_fuel_level
                  - ignition: sensor.la221804_ignition_state

Then the template. Notice I’m using several other nested cards within the pop-up.

# lovelace_gen

  car_template:
    card:
      type: 'custom:button-card'
      entity: '[[entity]]'
      entity_picture: '/local/images/[[image]].png'
      show_entity_picture: true
      name: '[[name]]'
      size: 100%
      template:
        - picture_button
        - car_button
      styles:
        card:
          - '--paper-card-background-color': 'rgba(40, 40, 40)'
          - box-shadow: >
              [[[ if (states['[[ignition]]'].state == '4') return "0px 0px 10px
              3px crimson"; return "none"; ]]]
      tap_action:
        action: fire-dom-event
        browser_mod:
          command: popup
          title:  Status
          card:
            type: 'custom:vertical-stack-in-card'
            cards:
              - type: 'custom:auto-entities'
                card:
                  type: glance
                  show_name: false
                  state_color: true
                filter:
                  include:
                    - entity_id: '[[filter]]'
                  exclude:
                    - entity_id: '*device*'
                    - entity_id: '*closed*'
                    - entity_id: '*starter*'
                sort:
                  method: name
              - type: map
                entities:
                  - entity: '[[entity]]'
                  - entity: '[[person]]'
                aspect_ratio: '16:9'
                default_zoom: 12.5
                hours_to_show: 24
      custom_fields:
        fuel:
          card:
            type: 'custom:flex-horseshoe-card'
            entities:
              - entity: '[[fuel_level]]'
                attribute: temperature
                decimals: 1
                unit: '%'
                area: Fuel
            show:
              horseshoe_style: colorstopgradient
            layout:
              states:
                - id: 0
                  entity_index: 0
                  xpos: 50
                  ypos: 60
                  styles:
                    - font-size: 4em;
              areas:
                - id: 0
                  entity_index: 0
                  xpos: 50
                  ypos: 35
                  styles:
                    - font-size: 3em;
                    - opacity: 0.8;
            horseshoe_scale:
              min: 0
              max: 100
            color_stops:
              '25': red
              '40': yellow
              '60': green
            style:
              top: 75%
              left: 0%
              width: 7em
              height: 8em
              transform: none
              '--ha-card-background': transparent

And the car button template


# lovelace_gen

  car_button:
    aspect_ratio: 1/1
    state:
      - value: "on"
        styles:
          card:
            - "--paper-card-background-color": "rgba(40, 40, 40)"
            - box-shadow: 0px 0px 10px 3px var(--button-card-light-color)
          name:
            - color: white
          state:
            - color: white
          label:
            - color: white
      - value: "off"
        styles:
          label:
            - color: "rgba(0, 0, 0, 0.0)"
    styles:
      custom_fields:
        fuel:
          - bottom: 10%
          - right: 0%
          - height: 45px
          - width: 52%
          - position: absolute
      grid:
        - grid-template-areas: '"i l" "n n" "s s" "fuel fuel"'
        - grid-template-columns: 1fr
        - grid-template-rows: 1fr auto auto min-content

1 Like

very nice Robert,

Do you also have an idea how to change the color of the icon, depending wether it’s locked = green and unlocked = red ?

Thx in advance,

Bart

I think you’ll have to do that from Lovelace (and quite possibly only with something like lovelace_gen), I don’t think it’s possible to set icon color from sensor definitions.

Hi all! I have an A 250 e with pre-entry climate control functions, but I can’t find the pre-entry switches in my HA entities at all. Does this function have some country/vehicle-specific restrictions I’m not aware of?

Hi @SamiJalopino ,

welcome and thanks for using this custom component.

There are two types of preconditioning: Aux-Heating and Pre-Conditioning

Depending on your car config you can call HA-Services with a button (or automation) for example:

Pre-Conditioning (for e-cars)

type: button
tap_action:
  action: call-service
  service: mbapi2020.preheat_start
  service_data:
    vin: VINOFYOURCAR
  target: {}

Pre-Heating (for cars with a secondary aux heating engine)

type: button
tap_action:
  action: call-service
  service: mbapi2020.auxheat_start
  service_data:
    vin: VINOFYOURCAR
  target: {}

See the docs for some more details and options.

BR
Rene

Excellent! Thanks Rene, I’ll give it a go.

Hi all,

first of all happy new year and thank you to the active and inactive users of this component. The latest stats showing that every day a new user is joining the club (btw: thanks for sharing the HA analytics/usage data).

Around 4 years ago, I got my first MB car and I tried to integrate the car data into Home Assistant. Over the time, I learned some basic python, MB changed their app landscape a lot (to the better of course) and I tried to keep the speed of all the HA changes.

As some of you know, this component does not use the official MB API’s. Main reasons are that the inofficial APIs deliver much more data and the updates come in near to realtime.

Nevertheless, it should be clear that the MB-Dev team can close the door whenever they want. And as I know, that some MB-devs reading this thread: Thanks to the MB-Dev team, for the great development in the last years and thanks for not shutting down the possibility to use my own data in the application that I like.

Let me give you some insights what is planned for the next months (as long as MB is on the friendly side):

  1. Adding some new services to control the interior esp. interior lighting. This needs some refactoring of the component load process, the MB-API is not the fastest here and a reauth is needed and I try to find out a way to do this without big interruptions.
  2. I want to learn more about Lovelace and therefore I plan to deliver the component with some preconfigured UI components. (Thanks to all the contributors in the thread here - I learned a lot)
  3. Fix the HA-units vs. MB-units problem - my plan is to add an option where you can swith between HA-unit sytem and MB-App-unit sytem.

What else do you want to see?

Thanks again - you’re active involvement here gives me the motivation to move on.

BR
Rene

PS: If you like the integration give it a star on the Github-repo…

4 Likes

Hi Rene,
In the meantime I pretty much tried everything even completely re-installed HA and got the to same issue. Do you have any other options to try ? Thanks!

This error originated from a custom integration.

Logger: custom_components.mbapi2020.oauth
Source: custom_components/mbapi2020/oauth.py:246
Integration: MercedesME 2020 (documentation, issues)
First occurred: 1:21:00 PM (1 occurrences)
Last logged: 1:21:00 PM

Error requesting data from https://id.mercedes-benz.com/as/token.oauth2: 400, message=‘Bad Request’, url=URL(‘https://id.mercedes-benz.com/as/token.oauth2’)

Hello, I have been having issues with this integration and can’t seem to find the cause.

I have tried to install it both ways (Copying to my config folder, and via HACS)

I authenticate and it pull my device model and year, but I do not see any entities.

The SUV is MY22
Firmware: Star2.3

Logger: custom_components.mbapi2020.client
Source: custom_components/mbapi2020/client.py:556
Integration: MercedesME 2020 (documentation, issues)
First occurred: 11:29:01 PM (5 occurrences)
Last logged: 11:45:30 PM

  • Can’t start engine for car . VIN unknown or feature not availabe for this car

Thanks in advance!

Hi @janz ,

Are you based in Europe or Noram? Does the feature work in the IOS/Android app? MY22 means model year 22?

can you enable “DEBUG ONLY: Enable save server messages to the messages folder” in the options of the integration. Restart your HA, wait 3minutes and send me the files out of the custom_integrations/mbapi2020/messages folder?

BR
Rene