Mercedes Me Component

Hi,

the error is expected currently. Normally, the websocket connection is recreated after this error. Do you get updates after the error?

I have to work on the websocket connections, but this takes longer at testing takes hours until the server closes the connection.

BR
Rene

Hi,

to be open, I’m not sure it what countries this integration is working. Based the featureflags the app receives from MB it looks like that the app (and therefore this integration) is tested internally in the US.

I do not expect a solution for 2017 US-cars soon. My last integration (GitHub - ReneNulschDE/mbapipy: MercedesME platform as a Custom Component for Home Assistant.) works with US cars starting 2019.

Sorry, looks like that I will not have solution to this.

BR
Rene

1 Like

Hi,

As I wrote, I assume the component does not work for Noram currently. Please check https://github.com/ReneNulschDE/mbapipy if your car is 2019 or newer.

BR
Rene

Hi,

looks like this is an older car with a Bluetooth adapter. Right? If so, please do not expect any support with this component. But you can take a look on IOBROKER. This Home-Automation system has an integration to the Bluetooth adapter integration created by https://github.com/TA2k/. (Yes, we worked together behind the scenes and shared our knowledge)

If you would like to build an integration, feel free to send a PR on my github account.

BR
Rene

Perhaps it’s possible to use a websocket proxy for testing? Should make it easier to simulate the connection being dropped or closing.

I am so thankfull @ReneNulschDE is working on this!
Based on some inspiration, code and images from this forum I created this picture elements card.

  1. I used this code, to create sensors out of the attributes from the integration

NOTE: adjust it with your own sensors ofcourse!!

## this yaml file creates seperate sensors in HA for the attributes derrived from the Benz sensors. Credits to Rene Nulsch for creating this awesome MercedesMe integration!
## I am not a programmer, this is all derrived from everywhere around the forum, re-use of images, inspiration and code.
## For me, having a splitted Home Assistant config I created this yaml file, named it mercedessensor.yaml and placed it in my sensors directory within home assistant
## I guess it can be part of your configuration file as well..... 


- platform: template
  sensors:
    car_tire_pressure_rear_left:
      friendly_name: Tire pressure Rear Left
      value_template: '{{ states.binary_sensor.g_646_lz_tire_warning.attributes.tirepressureRearLeft }}'
    car_tire_pressure_rear_right:
      friendly_name: Tire pressure Rear Right
      value_template: '{{ states.binary_sensor.g_646_lz_tire_warning.attributes.tirepressureRearRight }}'
    car_tire_pressure_front_left:
      friendly_name: Tire pressure Front Left
      value_template: '{{ states.binary_sensor.g_646_lz_tire_warning.attributes.tirepressureFrontLeft }}'
    car_tire_pressure_front_right:
      friendly_name: Tire pressure Front Right
      value_template: '{{ states.binary_sensor.g_646_lz_tire_warning.attributes.tirepressureFrontRight }}'
    
    
    car_lock_front_right:
      friendly_name: Lock Front Right
      value_template: >-
        {% if is_state_attr('sensor.g_646_lz_lock', 'doorlockstatusfrontright', false)%}
            Closed
        {% else %}
            Open
        {% endif %}
      icon_template: >
        {% if is_state_attr('sensor.g_646_lz_lock', 'doorlockstatusfrontright', false)%}
          mdi:lock-outline
        {% else %} 
          mdi:lock-open-variant-outline
        {% endif %}

    car_lock_front_left:
      friendly_name: Lock Front Left
      value_template: >-
        {% if is_state_attr('sensor.g_646_lz_lock', 'doorlockstatusfrontleft', false)%}
            Closed
        {% else %}
            Open
        {% endif %}
      icon_template: >
        {% if is_state_attr('sensor.g_646_lz_lock', 'doorlockstatusfrontleft', false)%}
          mdi:lock-outline
        {% else %} 
          mdi:lock-open-variant-outline
        {% endif %}

    car_lock_rear_right:
      friendly_name: Lock Rear Right
      value_template: >-
        {% if is_state_attr('sensor.g_646_lz_lock', 'doorlockstatusrearright', false)%}
            Closed
        {% else %}
            Open
        {% endif %}
      icon_template: >
        {% if is_state_attr('sensor.g_646_lz_lock', 'doorlockstatusrearright', false)%}
          mdi:lock-outline
        {% else %} 
          mdi:lock-open-variant-outline
        {% endif %}

    car_lock_rear_left:
      friendly_name: Lock Rear Left
      value_template: >-
        {% if is_state_attr('sensor.g_646_lz_lock', 'doorlockstatusrearleft', false)%}
            Closed
        {% else %}
            Open
        {% endif %}
      icon_template: >
        {% if is_state_attr('sensor.g_646_lz_lock', 'doorlockstatusrearleft', false)%}
          mdi:lock-outline
        {% else %} 
          mdi:lock-open-variant-outline
        {% endif %}

    car_lock_trunk:
      friendly_name: Lock trunk
      value_template: >-
        {% if is_state_attr('sensor.g_646_lz_lock', 'decklidstatus', false)%} 
            Closed
        {% else %}
            Open
        {% endif %}
      icon_template: >
        {% if is_state_attr('sensor.g_646_lz_lock', 'decklidstatus', false)%} 
          mdi:lock-outline
        {% else %}
          mdi:lock-open-variant-outline
        {% endif %}

    car_lock_hood:
      friendly_name: Lock hood
      value_template: >-
        {% if is_state_attr('sensor.g_646_lz_lock', 'hoodStateRollup', false)%} 
            Closed
        {% else %}
            Open
        {% endif %}
      icon_template: >
        {% if is_state_attr('sensor.g_646_lz_lock', 'hoodStateRollup', false)%} 
          mdi:lock-outline
        {% else %}
          mdi:lock-open-variant-outline
        {% endif %}

    car_window_front_left:
      friendly_name: Window Front Left
      value_template: >-
        {% if is_state_attr('binary_sensor.g_646_lz_windows_closed', 'windowstatusfrontleft', '2')%} 
            Closed
        {% else %}
            Open
        {% endif %}
      icon_template: >
        {% if is_state_attr('binary_sensor.g_646_lz_windows_closed', 'windowstatusfrontleft', '2')%} 
          mdi:window-closed
        {% else %}
          mdi:window-open
        {% endif %}

    car_window_front_right:
      friendly_name: Window Front Right
      value_template: >-
        {% if is_state_attr('binary_sensor.g_646_lz_windows_closed', 'windowstatusfrontright', '2')%} 
            Closed
        {% else %}
            Open
        {% endif %}
      icon_template: >
        {% if is_state_attr('binary_sensor.g_646_lz_windows_closed', 'windowstatusfrontright', '2')%} 
          mdi:window-closed
        {% else %}
          mdi:window-open
        {% endif %}

    car_window_rear_left:
      friendly_name: Window Rear Left
      value_template: >-
        {% if is_state_attr('binary_sensor.g_646_lz_windows_closed', 'windowstatusrearleft', '2')%} 
            Closed
        {% else %}
            Open
        {% endif %}
      icon_template: >
        {% if is_state_attr('binary_sensor.g_646_lz_windows_closed', 'windowstatusrearleft', '2')%} 
          mdi:window-closed
        {% else %}
          mdi:window-open
        {% endif %}

    car_window_rear_right:
      friendly_name: Window Rear Right
      value_template: >-
        {% if is_state_attr('binary_sensor.g_646_lz_windows_closed', 'windowstatusrearright', '2')%} 
            Closed
        {% else %}
            Open
        {% endif %}
      icon_template: >
        {% if is_state_attr('binary_sensor.g_646_lz_windows_closed', 'windowstatusrearright', '2')%} 
          mdi:window-closed
        {% else %}
          mdi:window-open
        {% endif %}
        
    car_window_sunroof:
        friendly_name: Window Sunroof
        value_template: >-
          {% if is_state_attr('sensor.g_646_lz_lock', 'sunroofstatus', '0')%} 
            Closed
          {% else %}
            Open
          {% endif %}
        icon_template: >
          {% if is_state_attr('sensor.g_646_lz_lock', 'sunroofstatus', '0')%} 
            mdi:checkbox-blank-circle-outline
          {% else %}
            mdi:checkbox-marked-circle-outline
          {% endif %}

  1. upload this picture to your www directory of HA. I made it transparant. :wink:

download PNG here: https://ibb.co/vYJmQ0j

  1. next I used the following yaml in the picture elements card.
## This is the card yaml, based on a picture-elements card. just create one in yourlovelace dashboard and copy and past in your card.

elements:
  - entity: sensor.g_646_lz_fuel_level
    prefix: ''
    style:
      transform: 'translate(-50%, -50%) scale(1.3, 1.3)'
      color: lightgrey
      left: 15%
      top: 17%
    type: state-label
  - entity: sensor.g_646_lz_odometer
    prefix: ' '
    style:
      transform: 'translate(-50%, -50%) scale(1.3, 1.3)'
      color: lightgrey
      left: 39%
      top: 17%
    type: state-label
  - entity: sensor.car_window_sunroof
    style:
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      '--paper-item-icon-color': null
      left: 57%
      top: 17.5%
    type: state-icon
  - entity: binary_sensor.g_646_lz_tire_warning
    prefix: ''
    style:
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      color: '#FFFFFF'
      left: 66.5%
      top: 17.5%
    type: state-icon
  - entity: binary_sensor.g_646_lz_low_brake_fluid_warning
    prefix: ''
    style:
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      color: '#FFFFFF'
      left: 76%
      top: 17.5%
    type: state-icon
  - entity: binary_sensor.g_646_lz_low_coolant_level_warning
    prefix: ''
    style:
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      color: '#FFFFFF'
      left: 85.5%
      top: 17.5%
    type: state-icon
  - entity: binary_sensor.g_646_lz_low_wash_water_warning
    prefix: ''
    style:
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      color: '#FFFFFF'
      left: 95%
      top: 17.5%
    type: state-icon
  - entity: sensor.car_tire_pressure_front_right
    style:
      transform: 'translate(-50%, -50%) scale(0.8, 0.8)'
      color: lightgrey
      left: 38%
      top: 32%
    type: state-label
  - entity: sensor.car_tire_pressure_rear_right
    style:
      transform: 'translate(-50%, -50%) scale(0.8, 0.8)'
      color: lightgrey
      left: 84%
      top: 32%
    type: state-label
  - entity: sensor.car_tire_pressure_front_left
    style:
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      color: lightgrey
      left: 38%
      top: 90%
    type: state-label
  - entity: sensor.car_tire_pressure_rear_left
    style:
      transform: 'translate(-50%, -50%) scale(0.8, 0.8)'
      color: lightgrey
      left: 84%
      top: 90%
    type: state-label
  - entity: sensor.car_lock_front_right
    style:
      '--paper-item-icon-color': white
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      left: 61%
      top: 38%
    type: state-icon
  - entity: sensor.car_lock_rear_right
    style:
      '--paper-item-icon-color': white
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      left: 68%
      top: 38%
    type: state-icon
  - entity: sensor.car_lock_front_left
    style:
      '--paper-item-icon-color': white
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      left: 61%
      top: 83%
    type: state-icon
  - entity: sensor.car_lock_rear_left
    style:
      '--paper-item-icon-color': white
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      left: 68%
      top: 83%
    type: state-icon
  - entity: sensor.car_lock_trunk
    style:
      '--paper-item-icon-color': white
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      left: 95%
      top: 60%
    type: state-icon
  - entity: sensor.car_window_front_right
    style:
      '--paper-item-icon-color': lightgrey
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      left: 56%
      top: 31%
    type: state-icon
  - entity: sensor.car_window_rear_right
    style:
      '--paper-item-icon-color': lightgrey
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      left: 73%
      top: 31%
    type: state-icon
  - entity: sensor.car_window_front_left
    style:
      '--paper-item-icon-color': lightgrey
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      left: 56%
      top: 90%
    type: state-icon
  - entity: sensor.car_window_rear_left
    style:
      '--paper-item-icon-color': lightgrey
      transform: 'translate(-50%, -50%) scale(0.7, 0.7)'
      left: 73%
      top: 90%
    type: state-icon
  - entity: binary_sensor.g_646_lz_park_brake_status
    prefix: ''
    style:
      transform: 'translate(-50%, -50%) scale(0.6, 0.6)'
      color: '#FFFFFF'
      left: 11%
      top: 42%
    type: state-icon
  - entity: binary_sensor.g_646_lz_windows_closed
    prefix: ''
    style:
      transform: 'translate(-50%, -50%) scale(0.6, 0.6)'
      color: '#FFFFFF'
      left: 11%
      top: 52%
    type: state-icon
  - entity: sensor.g_646_lz_lock
    prefix: ''
    style:
      color: '#FFFFFF'
      left: 11%
      top: 64%
    type: state-label
  - entity: device_tracker.g_646_lz_device_tracker
    prefix: ''
    style:
      color: lightgrey
      left: 11%
      top: 77%
    type: state-label
image: /local/mercnew.png
type: picture-elements

Enjoy playing around…moving around the sensors can create sometimes headaches :-). I would love to see more variants on this. I am not happy with the lock status 2, but since my programming skills are limited…it takes some time to figure thinks out hehehehe.

18 Likes

I will try to keep an eye on it.

1 Like

Im somewhat new to HACS but would it be possible to convert something like this into a hacs frontend component?

Also is that even possible in general?
Im guessing the missing sensors would cause problems, right?

Awesome work @ReneNulschDE, I guess we will have to sign up to Mercedes me and try it!

Happy New Year everyone :smiley:

1 Like

I am from the Netherlands, and this is the app I use:

I can login on the website of Mercedes.me and see my car, and some basic information.

The app is really minimal, not as much information as for the big brother cars… :wink: but battery level, how much milage left and total milage is there.

Hi, this app is using a different API set. Sorry, but I can’t help here. However, maybe some other devs in this thread could help.

Working brilliantly, thank you @ReneNulschDE!

I normally log in with phone number, which actually did work (sent me a code), but errored when entering the code into the integration setup.
I logged in with email instead, which of course worked.

This is beautiful, got it up and running! Gunna customise.

Could I ask you upload the transparent image somewhere? It only lets me download as a jpeg and loses the transparency.

Thanks a lot! :smiley:

here you go: https://ibb.co/vYJmQ0j

1 Like

Much appreciated!

regarding the lock status being 2, i’ve added the following to my yaml file:

      car_lock_status:      
        friendly_name: Car Lock Status
        value_template: >-
            {% if is_state('sensor.g_646_lz_lock', '2')%}
                Closed
            {% else %}
                Open
            {% endif %}

and then this on my dashboard:

- entity: sensor.car_lock_status
    prefix: ''
    style:
      color: '#FFFFFF'
      left: 11%
      top: 64%
    type: state-label

after restarting i then got “Closed or Open” after the lock symbol.

Hi Rene,

I guess you have quoted me by accident here.

But I can document the values for chargingstatus here for others who may want to use it. This was done by comparing to the mercedes me app:

chargingstatus = 0 means charging
chargingstatus = 1 means charging finished
chargingstatus = 2 ?? unknown
chargingstatus = 3 means charging cable disconnected
chargingstatus = 4 means charging error

Not sure about “2” and other potential states (5,6, …) though.

Maybe you can add that to the README @

Let me share my Mercedes dashboard here in the hope that it will be an inspiration for other implementations. Not super pretty and some logic is implemented in nodered, but you may get the idea.

Not charging:

Charging:

I have a Shelly Plug S deployed to start / stop charging that gives me the wattage and temperature and can be switched on/off. The end time is calculated from the range_electric sensor using nodered.

6 Likes

I’ve also changed the kPa to PSI and odometer to miles. Still new to HASS so this is helping me learn YAML & templates.

Thanks guys.

1 Like

Could you share your Mercedes image please? I’ve been trying to find one like that for ages! Thanks

1 Like

Cool! :sunglasses: keep enhancing!!:+1:t2: