Mercedes Me Component

Hi @iptvcld,

the timestamp is the last update on the MB server side. I read this timestamp from the received message and its not calculated in the component.

To double check: Could you enable the "DEBUG - Save files " setting in the integration option dialog? Restart HA. After few seconds you’ll find “vep*.json” files in your custom_components/mbapi2020/messages-folder . Search for gasTankLevel in these files and convert the timestamp into normal datetime (https://www.unixtime.de/)

Is it newer in the files?

BR
Rene

Rene,

Is it normal for the device to have a battery association?

Hi @rmertz3282,

I assume that is again the multiple VIN for one car problem. Could you send me again one of your vep* and md*-files (please use a large vep-file) - via private message.

let me try to build a configuration, so that we can merge these different VINs into one car.

BR
Rene

Background:
The last 2 cars in your screenshot are collected via the rest service. The two cars with the battery are reported via the websocket connection. If I remember correct then some parts of the vin are the same.

In Google Play it’s “Mercedes me 2020 Asia Pacific”

Everything works in the actual Android app ok, and I got success message entering en-AU and AU in the Integration but no entities got discovered.

Logs show the following errors continually:

2021-02-08 10:05:32 ERROR (MainThread) [custom_components.mbapi2020.oauth] Error requesting data from https://keycloak.risingstars.daimler.com/auth/realms/Daimler/protocol/openid-connect/token:

2021-02-08 10:05:32 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved

Traceback (most recent call last):

File "/config/custom_components/mbapi2020/websocket.py", line 117, in async_connect

headers = await self._websocket_connection_headers()

File "/config/custom_components/mbapi2020/websocket.py", line 218, in _websocket_connection_headers

token = await self.oauth.async_get_cached_token()

File "/config/custom_components/mbapi2020/oauth.py", line 121, in async_get_cached_token

token_info = await self.async_refresh_access_token(token_info["refresh_token"])

File "/config/custom_components/mbapi2020/oauth.py", line 77, in async_refresh_access_token

token_info = self._add_custom_values_to_token_info(token_info)

File "/config/custom_components/mbapi2020/oauth.py", line 147, in _add_custom_values_to_token_info

token_info["expires_at"] = int(time.time()) + token_info["expires_in"]

TypeError: 'NoneType' object is not subscriptable

UPDATE: Reloaded HA again and the above errors have disappeared however still no entities are appearing

Thanks; just did that and the timestamp shows as 27.01.2021 - 14:44:26

"gasTankLevel": {
            "timestamp": "1611755066",
            "status": 4,
            "nil_value": true,
            "timestamp_in_ms": "1611755066000",
            "service_ids": [
              505
            ]

Hi,

could you please set the region to North America and test again? Looks like that Asia-Pacific is using the same environment like NA.

Thx
Rene

status=4 means not available

Hi Rene, Deleting the Integration and re-adding with North America as region did the trick.

Thanks for the help.
You mentioned some testing what needed to be done, I don’t mind helping if I have the features, let me know what you need.

UPDATE: Although the integration seems to be working I’m getting alot of the following errors every second which is filling the error logs

2021-02-09 10:36:25 ERROR (MainThread) [custom_components.mbapi2020.websocket] Could not connect to wss://websocket-prod.risingstars.daimler.com/ws, retry in 10 seconds...

And then every 5 mins the following as well

2021-02-09 10:30:25 ERROR (MainThread) [custom_components.mbapi2020.oauth] Error requesting data from https://keycloak.risingstars.daimler.com/auth/realms/Daimler/protocol/openid-connect/token: 400, message='Bad Request', url=URL('https://keycloak.risingstars.daimler.com/auth/realms/Daimler/protocol/openid-connect/token')
2021-02-09 10:30:25 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/mbapi2020/oauth.py", line 181, in _async_request
resp.raise_for_status()
File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1000, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://keycloak.risingstars.daimler.com/auth/realms/Daimler/protocol/openid-connect/token')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/config/custom_components/mbapi2020/websocket.py", line 117, in async_connect
headers = await self._websocket_connection_headers()
File "/config/custom_components/mbapi2020/websocket.py", line 218, in _websocket_connection_headers
token = await self.oauth.async_get_cached_token()
File "/config/custom_components/mbapi2020/oauth.py", line 121, in async_get_cached_token
token_info = await self.async_refresh_access_token(token_info["refresh_token"])
File "/config/custom_components/mbapi2020/oauth.py", line 75, in async_refresh_access_token
token_info = await self._async_request(method="post", url=url, data=data, headers=headers)
File "/config/custom_components/mbapi2020/oauth.py", line 185, in _async_request
raise RequestError(f"Error requesting data from {url}: {err}")
custom_components.mbapi2020.errors.RequestError: Error requesting data from https://keycloak.risingstars.daimler.com/auth/realms/Daimler/protocol/openid-connect/token: 400, message='Bad Request', url=URL('https://keycloak.risingstars.daimler.com/auth/realms/Daimler/protocol/openid-connect/token')

Is it anything to be concerned about?

Peter

Hi,

i have published the version 0.4.2.

New:

  • Initial support for the region Asia Pacific (early version)

@sidplayos2: Could you update, remove the integration, restart HA and add it again? Please select the region Asia-Pacific in the initial dialog

Changes:

  • The binary sensors (liquidRangeCritical, warningbrakefluid, warningwashwater, warningcoolantlevellow, warningenginelight, tirewarninglamp) have the device_class = problem now. This should better reflect the current state in the frontend.

BTW: The component is available in the official HACS catalog now. So no need to use the custom-Repo-link anymore.

BR
Rene

Hi Rene,

Thanks for a great component. I found it really useful when I first used it last year but was pleased to see it back again now. I’m just having an issue with my door status.

In my sensors the lock sensor shows the following (with the cars doors locked):

doorStatusOverall: 1
doorlockstatusvehicle: 2
doorlockstatusdecklid: false
decklidstatus: false
rooftopstatus: 2
doorstatusfrontleft: false
engineHoodStatus: false
doorstatusfrontright: false
doorlockstatusfrontright: false
doorLockStatusOverall: 0
doorlockstatusgas: false
doorlockstatusfrontleft: false

So in my sensor.yaml I add the following:

      car_lock_front_left:
        friendly_name: Lock Front Left
        value_template: >-
          {% if is_state_attr('sensor.car_lock', 'doorlockstatusfrontleft', 'false')%}
             Closed
          {% else %}
             Open
          {% endif %}

Regardless of whether I enter false in the template or true, the sensor it creates always shows the doors as being open:

sensor.car_lock_front_left Open friendly_name: Lock Front Left icon: mdi:car-door

Am I doing something wrong here?

Ian

Thanks @IanC,

Please check against the boolean value.

{% if is_state_attr('sensor.car_lock', 'doorlockstatusfrontleft', False)%}

BR
Rene

Ah thank you Rene. A simple mistake which really had me head scratching. I think its an age thing :slight_smile:

Many thanks.
Ian

1 Like

Hi Rene,

That seems to be working great as of now with the new Asia-Pacific setting. Good to see you can add AU to your supported list now :slight_smile:

1 Like

Excellent component Rene, thank you.

I installed today to pair with my new EQC. I got one, then 4 then 8 then 11 entities, which is great.

One issue is that Mercedes has screwed up in sending range, trip and odometer data always with km as units, even when you have set the car to miles. On MBUX and MercedesMe, the data is correctly shown, but in the entity, it always has the km suffix. My workaround is to create a partner entity in node-red without the units suffix.

Just for clarity, if the car says the range is 180 miles, the data is transferred as 180 km. There’s no conversion.

Does anyone know if this is particular to EQC or all MB?

Does your HA instance use imperial or metric? When you first installed HA you selected this.
Most components are automatically converted for you based on this setting, if applicable.

However In the MB app (North America at least) you have speed - km/h or mph, fuel - km/l or mpg, temp Celsius or Fahrenheit, and pressure -bar/psi. Have you selected your preference under settings?

Yes. It’s a UK model and arrived set up for our unique mix where we use miles for range, trips and economy, but metric for distance to intersections and temperature, etc. This is normal for all car manufacturers.

The values are displayed correctly in the car and on the MercedesMe App, but in the data transferred into HA, (see object below), the ‘units’ value is miles.

If I use this entity in lovelace, the 187 (below) appears always as ‘187 km’. You cannot apply units to it or a suffix. It always shows km even though it is 187 miles. As I said I used node red to pick out the attribute and store it in a new entity, but this is cumbersome and inefficient.

{"_msgid":“cb0efcfb.b7e0d”,“payload”:“187”,“topic”:"",“data”:{“entity_id”:“sensor.wd70kwf_range_electric”,“state”:“187”,“attributes”:{“car”:“WD70KWF”,“vin”:“W1K2938902F022320”,“original_value”:“301”,“distance_unit”:“MILES”,“retrievalstatus”:“VALID”,“timestamp”:“2021-02-10T14:30:11”,“unit”:“MILES”,“precondActive”:false,“maxrange”:“197.6”,“distanceElectricalStart”:“2.2”,“chargingstatus”:“3”,“electricconsumptionreset”:“1.3”,“selectedChargeProgram”:“0”,“distanceElectricalReset”:“28.4”,“soc”:“95”,“chargingactive”:false,“electricconsumptionstart”:“0.6”,“unit_of_measurement”:“km”,“friendly_name”:“WD70KWF Range Electric”,“icon”:“mdi:ev-station”},“last_changed”:“2021-02-10T14:30:13.780541+00:00”,“last_updated”:“2021-02-10T14:30:13.780541+00:00”,“context”:{“id”:“7ebd67f348be674bed730dbc8cacc60d”,“parent_id”:null,“user_id”:null},“timeSinceChangedMs”:24062,“original_state”:“187”}}

I think you need to use the attribute “original_value” since 301 / 0.621371 = 187. I had the same problem with the odometer reading as I’m also in the UK so made my sensor like this:

    sensors:
      odometer_miles:
        friendly_name: Odometer in Miles
        value_template: '{{ ((states.sensor.car_odometer.attributes.original_value | float * 0.621371)) | round(0) }}'
1 Like

Ian beat me to it.

I think this is your best option.

1 Like

Thanks. This is a better solution than mine! I hadn’t played with templates yet but I use node red for lots of things. Went for my comfort zone!

Thanks again.

Your welcome. This is a great component but I’m spending far too much time playing with it :slight_smile:

1 Like