ReneNulschDE / mbapi2020

Custom Component to integrate MercedesME devices into Home-Assistant
Other
149 stars 29 forks source link

getVin #143

Closed dm82m closed 11 months ago

dm82m commented 11 months ago

Hey Rene,

thanks for your integration. I created an automation to open and lock my car doors. For that I need to provide the vin. Would it be possible to provide the vin for the car through your integration? Or otherwise provide a direct lock service for the car? Would help me to get rid of changing the vin manually in my automations each time my next car change occurs.

best Dirk

ReneNulschDE commented 11 months ago

Hi Dirk,

Each sensor has an attribute for the vin and car.

image

Could you not just use this?

Or use the new Template Sensor that you can find in the Helper-UI to create your own sensor.

Let me know when you need more help or join the HA community. There is a long thread for this component.

BR René

dm82m commented 11 months ago

Ahhh, was not aware that it is available as attribute. This solves everything for me. Thanks.

dm82m commented 11 months ago

For all potentially searching for how to do that:

action:
    - if:
        - condition: template
          value_template: "{{ states('lock.dima_car_lock') == 'locked'}}"
      then:
        - service: mbapi2020.doors_unlock
          data:
            vin: "{{ state_attr('lock.dima_car_lock', 'vin')  }}"
      else:
        - service: mbapi2020.doors_lock
          data:
            vin: "{{ state_attr('lock.dima_car_lock', 'vin')  }}"