Mercedes Me Component

hi,

the tankLevelAdBlue is an attribute of the fuelLevel sensor:

1 Like

unfortunately, this is not provided by the API. One of my core concepts developing this component is to show what the MB-API provides. Currently, one endpoint provides the start time and a different endpoint provides the weekday.

Yes, this could be calculated in a way:

  • if departureTimeWeekday = now().weekday() and DepartureTime <= currentTime = Today + DepartureTime
  • else: calculate date based on next weekday = departureTimeWeekday + DepartureTime

Should be an easy template.

2 Likes

Hi renè,
I also have Adblue in my class C 2017 but I don’t see it in the attributes, it’s possible it’s not exposed for my model
immagine

thanks

Hi Alessio,

the available data is depended on your car and the software packages that you have subscribed/payed for. Whenever the data is not available in the app, then it can’t be available in the integration - The component is using the same API or better is trying to act like the app. In case you see it in the app, but not in the integration - let me know and we can dive deeper :slight_smile:
BR
Rene

PS: You can enable the special “DEBUG: Save…” option in the integration settings and take a look into the text files that are produced to see whats available…

thanks,
I honestly expected to see it but now that I’ve checked nenache in the car’s on-board computer there is no this entry.
It’s not a relevant thing but if there was it was one more thing.

Gotcha

For those interested:

{% set depart_weekday = state_attr('sensor.licenseplate_departure_time', 'departureTimeWeekday') | int %}
{% set depart_time = states('sensor.licenseplate_departure_time') %}
{% set days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] %}
{% if now().weekday() == depart_weekday and today_at(depart_time) >= now() -%}
  {{ depart_time }}
{% else -%}
  {{ days[depart_weekday] }} {{ depart_time }}
{% endif %}

Will display e.g. 18:00 if it’s planned for today and Wed 18:00 if it’s planned for next Wednesday.


{% set depart_weekday = state_attr('sensor.licenseplate_departure_time', 'departureTimeWeekday') | int %}
{% set depart_time = states('sensor.licenseplate_departure_time') %}

{% if depart_weekday == now().weekday() and today_at(depart_time) >= now() -%}
  {{ depart_time }}
{% else -%}
  {%- set depart_hour = strptime(depart_time, "%H:%M").hour -%}
  {%- set depart_minute = strptime(depart_time, "%H:%M").minute -%}
  {{ (now() + timedelta(days = (7 + depart_weekday - now().weekday()) % 7))
      .replace(hour = depart_hour)
      .replace(minute = depart_minute)
      .strftime('%Y-%m-%d %H:%M') }}
{% endif %}

This one will print the departure hour (e.g., 18:00) if it’s planned for today and a timestap like 2023-03-09 18:00 if the depature time is in on a different date.




Using device_class: timestamp, HA will also nicely format the output of the sensor for you when displayed in a card.
Do note you need to use .isoformat() instead of strftime() and you’ll need to replace {{ depart_time }} with {{ today_at(depart_time).isoformat() }} as well.


image

1 Like

Hi, good approach. Small hint: this will not work if you use the T12H format in the MB-App.

You could add the variable:
{% set depart_minutes = state_attr('sensor.licenseplate_departure_time', 'original_value') | int %}

and replace
today_at(depart_time)
with
today_at(timedelta( minutes = depart_minutes ))

and your second templates need some adjustment too…
Replace:

  {%- set depart_hour = strptime(depart_time, "%H:%M").hour -%}
  {%- set depart_minute = strptime(depart_time, "%H:%M").minute -%}

with

  {%- set depart_hour = today_at(timedelta( minutes = depart_minutes )).hour -%}
  {%- set depart_minute = today_at(timedelta( minutes = depart_minutes )).minute -%}

Note to myself: The unit T12H is not supported by the component and there is a warning in the HA-log. I have to add this…… Done

1 Like

WOW you saved my life as I spent a few hours to play with the old Mercedes me component and was not able to get it work! Thanks.

1 Like

I can confirm there is no other configuration needed here in Australia. Actually I learned all the HA stuff from your youtube channel! Thanks.

I have published a new version 0.9.0.

This release adds support for the Chinese Market. Chinese users can select “China” as a region in the onboarding dialog

Other fixes:

  • Remove warning “Unknown unit T12H found. Please report via issue .www.github.com/renen…”
  • Support to login via mobile phone - use the format “+(country code phonenumber) without spaces” example: +4916212345

Special thanks to @gnep88 for the PR and tests

1 Like

I feel like this could be optimised even further using

{% set depart_minutes = state_attr('sensor.2_ctn_812_departure_time', 'original_value') | int %}
{% set depart_time = today_at(timedelta(minutes = depart_minutes)) %}

The module trick also does wonders.




{% set depart_weekday = state_attr('sensor.licenseplate_departure_time', 'departureTimeWeekday') | int %}
{% set depart_minutes = state_attr('sensor.licenseplate_departure_time', 'original_value') | int %}
{% set depart_time = today_at(timedelta(minutes = depart_minutes)) %}
{% if depart_weekday == now().weekday() and depart_time < now() %}
  {{ (depart_time + timedelta(days = 7)).isoformat() }}
{% else -%}
  {{ (depart_time + timedelta(days = (depart_weekday - now().weekday()) % 7)).isoformat() }}
{%endif %}

I’m sure this is simple when you know how, but I’m trying to put maxSoc into a card, with buttons to change it. I know that I see it with sensor.mastiff_state_of_charge and then the MaxSoc as the parameter. But how do I do that? sensor.mastiff_state_of_charge.MaxSoc is of course not working, and neither is sensor.mastiff_state_of_charge_MaxSoc.

I’m guessing I should just use the service in an automation, one for each from 50 to 100, and then use that with buttons. Or can I get a service into a card so I can do it directly? The service is:

service: mbapi2020.battery_max_soc_configure
data:
  max_soc: "80"
  vin: ***********************

Check my earlier reply: Mercedes Me Component - #1513 by DezeStijn

Thank you very much, looks slick! I’ll get to that tomorrow evening, when I have some spare time to integrate it.

Edit: @DezeStijn I took a quick look at it now, put it in the config file and got the slider. Only it doesn’t do anything. It is consistent, though. It will stay on the number it’s set to when I restart Hass, it just doesn’t have anything with the actual max SOC to do. I have put my VIN in place of the Secret VIN number, but should I do anything else? Calling the service from Services works, but the slider is not affected:

Edit 2: I found at least one brain fart, I had to replace lisenceplate with mastiff. That should give me the correct input, but not yet. I also tried to replace maxSocLowerLimit with maxSoc since that seemed more logical to set, but that didn’t help either. I have also found that the first time I fire the actual service directly after a Hass restart it does not seem to work. Second time and then after that works.

As I’ve mentioned in my post, the slider doesn’t appear to follow changes to the charging target done via the app (yet). I need to look further into this.
It doesn’t look like the charge target is exposed via this integration. My car is currently charging to 80%, yet sensor.licenseplate_state_of_charge > MaxSocLowerLimit still shows 50.

But the automation triggered by changing the slider should affect the charge target of the car.

No, that’s what I was trying to say, but I see that wasn’t very clear. It doesn’t change anything in the car. But you are looking at the wrong number for the sensor. MacSocLowerLimit is always 50, because that just means the lowest you can set the max charge to in the app. The number you want is the one I said, replacing it with just maxSoc. Try this in the template window:

{{ state_attr('sensor.mastiff_state_of_charge', 'maxSoc') | int }}

Only replace mastiff with the name you have given your car. Btw is yours an EQC as well, or is it another model?

My state_of_charge sensor doesn’t appear to have a maxSoc attribute.
Makes sense that would be the attribute I’d need for my automation.

EQB, btw

That was very strange! I thought they were the same in that respect. This is my my template, it changes with the app literally in the same second.

Here’s the SOC attributes:

Can this be something in the integration that hasn’t taken a new update or something into account? It must be there, or you wouldn’t be able to update it from the app.

Can anybody else here check it on an EQB, or another car than the EQC, like EQA or EQS or EQE? I belive the EQC was the first to come with this system, in 2019, so it may be that the reason is that my charging system is older.

the missing maxSOC was reported on github for an EQA some time ago. EQC and EQE have it.

maxSoc is also depending on the activated service (686) “Charging”, “Programming charging and pre-climate controls” (or something like that)

1 Like

I see! Well, then it’s not unknown. And that is one service that’s free for the life of the car, I believe. I recently had to reactivate some services (I dropped a few, like the traffic info, I very rarely drive where that is of any help), but that one did not run out. But it can be activated and deactivated from the app, even though I don’t think that’s he problem because then it wouldn’t be possible to change the charging target from the Mercedes app either.