Mercedes Me Component

Hello Renee,

https://diagnoseapparatuur.nl/kenniscentrum/obd-obd1-obd2-eobd

Thanks for the info Rene, then it was just not me.

Looking forward to see what the new properties will add

BR
Recon

I published a bugfix release v0.6.3 to solve the “protobuf” issues with the appletv integration in HA2022.02. This is not a longterm fix for sure - looks like I’m in the dependency hell now too :frowning:

Hi Nico,

don’t understand your link? This component has no relation to the odb interface or the related old MBme adapters. I’m focussed just on the cloud integration.

If I remember correct the author of the iobroker MB integration tried to integrate the old odb adapters. https://github.com/TA2k/ioBroker.mercedesme

BR
Rene

Hi,

thanks for reporting this error. I’ll change it in the next release to kW.

BR
Rene

commit: https://github.com/ReneNulschDE/mbapi2020/commit/c102beacff3c1c42c50aa560cb74870d47727199

Hi, sorry for late reply. Here is how I setup the Google sheet integration: Writting sensors' values to Google Sheets - #85 by otmezger

One problem is that I have to recreate the token once a week, but can live with it.

I have a automation that triggers when sensor.charging power is above 0.1, the action:
service: shell_command.record_sensors_startcharge
data:
sensor01: START_CHARGE
sensor02: ‘{{ now().strftime("%Y-%m-%d") }}’
sensor03: ‘{{ now().strftime("%H:%M") }}’
sensor04: ‘’’{{ states(’‘sensor.carlocation’’) }}’’’
sensor05: ‘{{ state_attr(’‘sensor._range_electric’’,’‘soc’’) }}’
sensor06: ‘{{ states(’‘sensor._odometer’’) }}’
sensor07: ‘{{ state_attr(’‘sensor._range_electric’’,’‘chargingPower’’) }}’

The

shell command in file /config/includes/shell_commands/record_sensors_sc.yaml:
record_sensors_startcharge:
python3 /config/includes/shell_scripts/gsheets_write_startcharge.py {{sensor01}} {{sensor02}} {{sensor03}} {{sensor04}} {{sensor05}} {{sensor06}} {{sensor07}}

And the specific rows in the shellscript:
sensor01 = sys.argv[1]
sensor02 = sys.argv[2]
sensor03 = sys.argv[3]
sensor04 = sys.argv[4]
sensor05 = sys.argv[5]
sensor06 = sys.argv[6]
sensor07 = sys.argv[7]

range_ = ‘Charges!A2:A’ # TODO: Update placeholder value.
value_input_option = ‘USER_ENTERED’ # TODO: Update placeholder value.
insert_data_option = ‘’ # TODO: Update placeholder value.
value_range_body = {“values”: [[sensor01, sensor02, sensor03, sensor04, sensor05, sensor06, sensor07]]}

And then I have a end charge command/script that triggers and logs some information on next line in the sheet. I have some calculations done there also

I have solved this in the other direction via a google sheets app script and the HA history Rest API. So Google sheets is asking HA to get all records.

function getCarHistory() {
  
  var ha_longlive_access_token = "eyJ0eXAiOiJK....";
  var ha_url = "https://URL_TO_HA";
  var entity_id = "device_tracker.REPLACE_device_tracker"
  
  var plusOptions = {
    "headers" : {
      "Authorization" : "Bearer " + ha_longlive_access_token
    }
  };
  
  var url = ha_url + "/api/history/period/2020-02-05T08:00:00?filter_entity_id=" + entity_id + "&end_time=2022-12-31"
  var response = UrlFetchApp.fetch(url, plusOptions);
  //Logger.log(response.getContentText());
  
  var results = JSON.parse(response.getContentText());
  var output = []
  var lastitem = ""
  
  results.forEach(function(list,i) {
    list.forEach(function(elem,j) {
      //Logger.log(elem["entity_id"])
      var entity_id = elem["entity_id"];
      var state = elem["state"];
      var latitude = elem["attributes"]["latitude"];
      var longitude = elem["attributes"]["longitude"];
      var timestamp = elem["attributes"]["timestamp"];
      var last_changed = elem["last_changed"];
      if (lastitem != timestamp) {
        output.push([entity_id, state, latitude, longitude, timestamp, last_changed]);
      }
      lastitem = timestamp    
    });
  });

  var len = output.length;
  //Logger.log(len)
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();

  // clear any previous content
  sheet.getRange(2,1,3000,6).clearContent();
  
  // paste in the values
  sheet.getRange(2,1,len,6).setValues(output);
}

First of all thanks for this great integration!
I have two cars registered in the mercedesme app, but only one appears in the Home Assistant.
Is that a known limitation of the integration at the moment or am I doing something wrong?

Thanks!

Hi @florian-forster ,

the integration supports multiple cars as long as they are available in one single account (secondary driver). Not supported are the older Bluetooth MB-Me devices.

Please give us more information like your region, logs, car config. You can enable the logging on debug level via the HA-config (see readme on github) and you can also enable the “Save debug messages” in the options of the integration. Restart HA, wait 2min and share the logs via private message if you prefer.
BR
Rene

Hi @ReneNulschDE
first of all, many thanks for this great custom component.
I’m quite new to it but it seems to be working nicely with my S206.
However, after a restart of my HA system, all the entities are “not available” afterwards. As I’m doing nightly automated backups of my HA VM where this one gets stopped and then freshly booted after backup has completed, it’s a bit a pity that for some reason the integration does not work anymore.
Using your latest version on HA 2022.2.9

Any hints are much appreciated! Thanks.

@ReneNulschDE Thank you for this component! I have everything except for the Aux Heat working on my EQC. I have added an issue on GitHub too, but thought I’d mention it here in case anybody else has this working and can tell me what I am doing wrong. Unlocking the doors and getting info is no problem, but the Aux heat switch (which should work as aux cool in the summer) is not doing anything.

How do you have it set up? You know it’s a service call I presume. Here’s a simple on/off on lovelace:

  - type: picture-elements
    elements:
      - type: service-button
        title: Deactivate
        service: mbapi2020.preheat_stop
        service_data:
          vin: xxx
        target: {}
        style:
          top: 80%
          left: 80%
      - type: service-button
        title: Activate
        service: mbapi2020.preheat_start
        service_data:
          vin: xxx
        target: {}
        style:
          top: 20%
          left: 20%

I’m only trying to use it with the switch in untouched Lovelace so far:

Edit: Btw is it possible to get opening of the hatch in there too? That would be great, I could put a photo sensor connected via an ESP32 for the Pi that I have in the car so I could use it as it’s done with cars that come with keyless entry (mine has keyless go, not entry). And do you know how much data this integration uses? I’m considering connecting a separate Pi with only this integration and MQTT to an 4G USB modem, so I can use that for opening and locking the car until I get a permanent solution that uses the CAN Bus (which is probably half a year away since the most likely candiate, AutoPi is unavailable for some months).

Hi @Mastiff ,

for the EQC (or other hybrids) you have to use the preheat_start/stop instead of auxheat_start/stop. (auxiliary heating is a secondary combustion heating)

BR
Rene

I do not know a way to do this via API. Is this possible in your MB-App?

BR
Rene

The MB Server Api will send every 15 seconds a data packet of ~100 Bytes. The rest is depended on the usage of your car. If the car has a status change of one of the sensors, the MB Server will send a data packet of ~500 Bytes. A connection refresh happens every 4 hours → 2 KB. Each HA startup will produce around 500KB (depending on the amount of cars)

Hope this helps
BR
Rene

Thanks for the tip! That worked! So I have to create my own switch for that, or can I change the integration to use that instead?

Ah, sorry. I thought it was possible to open the hatch from the app, it seems it’s not…

And I see, that’s data that I used way back in the days of my USRobotics Sportster modem, so that shouldn’t eat too much, thanks!

Hi @iHaveAstream ,

What do you do to get in working again? The sensors are unavailable until the component is loaded and should not take longer then 30seconds depending on region and car capabilities. (note to myself: try to understand and implement the restorestate functionality of HA)

BR
Rene

I use a lovelace button or automation (depending on weather, calendar and battery state) to call the service (see the example from Richard or the others in this thread). A switch will make this topic complicated because you have 3-4 status values.

I see. :slight_smile: OK, thanks a lot for the help! I guess I’ll build a separate page for the car in Lovelace with the stuff I want, like I’ve done for my home theater, garage and boat.

1 Like