Mercedes Me Component

New release: v0.8.4 - Fix Config_flow

Bugfix:

  • Fix Error in Config Flow “NameError: name ‘_LOGGER’ is not defined”

Hi @ReneNulschDE

I’ll check out v0.8.2 to see how it looks like now.
But wouldn’t make it more sense to expose e.g. a nextDeparture sensor that provides the next (planned) departure time as yyyy-mm-ddThh:mm (UTC or localised with timezone)? That can easily be parsed in HA using strptime() into whatever data the user needs (data, time, weekday, …).

Hi All,

I was wondering if i could get some help with setting up charging Scheduling (by setting the max charging limit) via homeassistant and Mercedes Me integration for my EQA. Firstly, is it possible to do this through Mercedes me?

I’ve looked in to what is available and can see “maxSocLowerLimit: 50” … However, this doesn’t seem to be in line with the app. when i change the charge percentage in the app it doesn’t update here. I also wasn’t able to update the value. This is the first time i’ve ever tried to set the value of an entity (outside of the basics) via home assistant so i may be doing something wrong.

Any help would be greatly appreciated.

Thanks
Asim

Hi Asim,

you can’t set the maxSocLowerLimit with this component currently. However the maxSoc can be configured with HA Service “MercedesME 2020: battery_max_soc_configure”

That’s exactly what i was looking for! Thanks

See Manage Mercedes EV battery charge target from Home Assistant :: Sequr for an example.

I have however noticed that mbapi2020.battery_max_soc_configure won’t update the maxSocLowerLimit attribute of sensor.licenseplate_state_of_charge. So that part of my automation doesn’t fully function yet.

2 Likes

For some reason tankLevelAdBlue is not showing up as a sensor. All other info is visible. Any one can help me?
(and yes, my car has adblue)

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