Mercedes Me Component

I seem to be getting a problem that has borked this integration:

2022-01-19 09:45:48 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry mbapi2020 for mbapi2020
Traceback (most recent call last):
File "/config/custom_components/mbapi2020/api.py", line 73, in _request
resp.raise_for_status()
File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('https://bff-prod.risingstars.daimler.com/v1/vehicle/self/masterdata')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 313, in async_setup
result = await component.async_setup_entry(hass, self) # type: ignore
File "/config/custom_components/mbapi2020/__init__.py", line 118, in async_setup_entry
masterdata = await mercedes.client.api.get_user_info()
File "/config/custom_components/mbapi2020/api.py", line 83, in get_user_info
return await self._request("get", "/v1/vehicle/self/masterdata")
File "/config/custom_components/mbapi2020/api.py", line 76, in _request
raise RequestError(f"Error requesting data from {url}: {err}")
custom_components.mbapi2020.errors.RequestError: Error requesting data from https://bff-prod.risingstars.daimler.com/v1/vehicle/self/masterdata: 404, message='Not Found', url=URL('https://bff-prod.risingstars.daimler.com/v1/vehicle/self/masterdata')
2022-01-19 12:17:01 ERROR (MainThread) [homeassistant.components.system_health] Error fetching info
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/system_health/__init__.py", line 68, in get_integration_info
data = await registration.info_callback(hass)
File "/config/custom_components/mbapi2020/system_health.py", line 21, in system_health_info
client = hass.data[DOMAIN]
KeyError: 'mbapi2020'

Hi Richard, please update to the latest version. See the messages from last Friday. MB has changed the API and the new version is available since Friday too.

BR
Rene

yeah, my bad…i’d updated the integration but not restarted home assistant as i got distracted.
apologies

Hi TobiasBlo
Yes, would be grea if you could share your automation content for that Export
Thanks

Hi all,

I’m not able to toggle my ignition, doors (lock/unlock) & the heater. I have no clue what is going wrong, logs aren’t telling anything.

This is my pop-up code (front-end):


    - type: horizontal-stack
      cards:
        - type: 'custom:button-card'
          entity: switch.mercedes_ac
          style: |
             ha-card { 
             border-radius: 5px;
             background-color: #262628;
             --paper-item-icon-active-color': 'rgb(245,25,25)
             }
          tap_action:
           confirmation: Are you sure ?
           action: toggle
          show_state: false
          show_label: false
          show_name: false
          
        - type: 'custom:button-card'
          entity: switch.mercedes_ignition
          style: |
             ha-card { 
             border-radius: 5px;
             background-color: #262628;
             --paper-item-icon-active-color': 'rgb(245,25,25)
             }
          tap_action:
           confirmation: Are you sure ?
           action: toggle
          show_state: false
          show_label: false
          show_name: false
        - type: 'custom:button-card'
          entity: switch.mercedes_lock
          style: |
             ha-card { 
             border-radius: 5px;
             background-color: #262628;
             '--paper-item-icon-active-color': 'rgb(245,25,25)'
             }
          tap_action:
           confirmation: Are you sure ?
           action: toggle
          show_state: false
          show_label: false
          show_name: false

type or paste code here

and here is my switch config:

  - platform: template
    switches:
      mercedes_ac:
        value_template: "{{ is_state('input_boolean.fake_state_ac', 'on') }}"
        turn_on:
        - service: input_boolean.turn_on
          target:
            entity_id: input_boolean.fake_state_ac
        - service: script.turn_on
          target:
            entity_id: script.clima_on
        turn_off:
        - service: input_boolean.turn_off
          target:
            entity_id: input_boolean.fake_state_ac
        - service: script.turn_on
          entity_id: script.clima_off
        icon_template: '{%- if is_state("switch.mercedes_ac", "on") %}mdi:radiator{% else %}mdi:radiator-off{%- endif %}'

      mercedes_lock:
        value_template: "{{ is_state('input_boolean.fake_state_lock', 'on') }}"
        turn_on:
        - service: input_boolean.turn_on
          target:
            entity_id: input_boolean.fake_state_lock
        - service: script.turn_on
          target:    
            entity_id: script.carlock_open
        turn_off:
        - service: input_boolean.turn_off
          target:
            entity_id: input_boolean.fake_state_lock
        - service: script.turn_on
          target:
            entity_id: script.carlock_lock
        icon_template: '{%- if is_state("sensor.2_amu_833_lock", "0") %}mdi:car-door{% else %}mdi:car-door-lock{%- endif %}'
        
        #ensor.my_car_lock_status", "on") %}mdi:car-door{% else %}mdi:car-door-lock{%- endif %}'
      
      mercedes_ignition:
        value_template: "{{ is_state('input_boolean.fake_state_ignition', 'on') }}"
        turn_on:
        - service: input_boolean.turn_on
          target:
            entity_id: input_boolean.fake_state_ignition
        - service: script.turn_on
          target:    
            entity_id: script.ignition_on
        turn_off:
        - service: input_boolean.turn_off
          target:
            entity_id: input_boolean.fake_state_ignition
        - service: script.turn_on
          target:
            entity_id: script.ignition_off
        icon_template: '{%- if is_state("switch.mercedes_ignition", "on") %}mdi:engine-outline{% else %}mdi:engine-outline-off{%- endif %}'    

Has anyone got any clue what I’m doing wrong ?

Thanks a lot in advance,

Kr,

Bart

Hi, I really tried solving this on my own but I can’t for the life of me figure it out. I had everything working then about a month ago I noticed all my entities were overwritten back to default. It doesn’t matter how many times I update them if I restart home assistant they update to the original entity names and my configurations won’t work. I’m just replacing the VIN with C43 as I have always done but for some reason they just keep getting overwritten. Thoughts?

I can’t seem to control the AuxHeat through the integration. I have a Switch and can click on it and but turns off directly. Anybody has the same ?
image

It’s not an entity that can be directly switched in HA. It requires a service call.

Thanks, will check it out

Anyone have any idea why this is happening? I don’t think I changed anything as this was working for several months and suddenly would reset every time I restarted.

Hi,

does your car support the AuxHeater (secondary heater) or do you have PreClimateControl in your car? The switch is for AuxHeater only.

Enable the debug log of the component to check for errors.

BR
Rene

Hi @jackgithome ,

could you share some more details?

What is your HA version?
What is your MBAPI2020 version?
What is your region?
How do you change the entity names?
Is the vin stable or does it change after restart?

BR
Rene

I have HA version 2021.12.9
MBAPI V 0.6.0
Region US
I update entities by going into the configuration menu - > Devices and services → clicking on the 17 entities in the MBAPI integration ->click on 1 of the names/entities → then remove the VIN and replace it with c43.
I restarted and noted the VIN, it appears to stay the same.

Thanks!

Anyone please ?

Hi,

Looks like I have added a bug/feature that affects the US-region only. There was one feature request to remove old cars from the config and I have implemented this in v0.6. This removal runs potentially to early for the US-region.

Do you see “Removing car from device registry: …” in your log (log level: info)?

BR
Rene

@ReneNulschDE Hi René, can you have a look at the code please ?

Hi,

sure, I can - but could please simplify it first a little bit and explain what you are trying to achieve. In case you have problems with the switches then please test it without all this custom lovelace stuff first and let us work on one switch only. Please add the code of the related input_helper too.

BR
Rene

New Release v0.6.1

Bugfix:

  • (US-Region) Cars get deleted from device registry (see) (@jackgithome thanks for reporting)
  • (US-Region) Sensors are not created after first setup (see) (@JonathanJCasey thanks for your help, I’ll improve it step by step)

Add:

  • New sensor “Charging Power” (was and still is an attribute) - Prep for Energy Dashboard support in one of the following releases
1 Like

Hi Rene,

First of all thanks big time for your help. What I want to achieve is to be able to start my heater in my MB using Home assistant. I have a button that gives me the state of my mercedes (locked versus unlocked) and by pressing the button I get a pop-up with the visuals of the Mercedes Benz state (the one with the car and all the sensors) and also 3 buttons :slight_smile:

  • lock / unlock
  • start ignition
  • start heater

Let’s indeed start with one button: the one to start of stop the heater.

First of all, I created an input_boolean as follows:

fake_state_ac:
   name: status clima

Second of all, I created a switch:

  - platform: template
    switches:
      mercedes_ac:
        value_template: "{{ is_state('input_boolean.fake_state_ac', 'on') }}"
        turn_on:
        - service: input_boolean.turn_on
          target:
            entity_id: input_boolean.fake_state_ac
        - service: script.turn_on
          target:
            entity_id: script.mercedes_ac_on
        turn_off:
        - service: input_boolean.turn_off
          target:
            entity_id: input_boolean.fake_state_ac
        - service: script.turn_on
          entity_id: script.mercedes_ac_off
        icon_template: '{%- if is_state("switch.2_amu_833_auxheat", "on") %}mdi:radiator{% else %}mdi:radiator-off{%- endif %}'


The scripts AC ON/OFF are declared as follows in my scripts.yaml file:

mercedes_ac_on:
  alias: Start MB Heater
  sequence:
    - service: mbapi2020.auxheat_start
      data:
        vin: W1N1673171A316237

mercedes_ac_off:
  alias: Start MB Heater
  sequence:
    - service: mbapi2020.auxheat_stop
      data:
        vin: W1N1673171A316237

And of course, a button in my pop-up:

    - type: horizontal-stack
      cards:
        - type: 'custom:button-card'
          entity: switch.mercedes_ac
          style: |
             ha-card { 
             border-radius: 5px;
             background-color: #262628;
             --paper-item-icon-active-color': 'rgb(245,25,25)
             }
          tap_action:
           confirmation: Are you sure ?
           action: toggle
          show_state: false
          show_label: false
          show_name: false
 

But somehow, it doesn’t work, and I can’t point where the failure is…

Thanks in advance for your help !

Kr,

Bart

Does the switch work outside of your custom lovelace card?