How to add battery level and charging status to a lock template to work in Homekit?

Hi everyone,

can you guys help me with setting up the homekit configuration / template in order to have the battery level and charging status being shown in homekit? It is for a lock template device.

This is what I tried:

lock:
  - platform: template
    name: Car Lock
    value_template: "{{ is_state('lock.car_door_lock', 'locked') }}"
    lock:
      service: lock.lock
      target:
        entity_id: lock.car_door_lock
    unlock:
      service: lock.unlock
      data:
        code: 1234
      target:
        entity_id: lock.car_door_lock
        
homekit:
    entity_config:
      lock.car_lock:
        linked_battery_sensor: sensor.car_battery_sensor

There is an integration from HACS but I have to enter a PIN in order to unlock the car. So I created a template lock with the PIN being a part of it. In the original lock in homekit, battery level and charging status are being displayed. And I’d like to have that in my template lock as well?

Or a different approach: Can I modify a lock (coming from the HACS integration) to always send a data payload with the PIN? Then I would not need a template lock.

Appreciate any hint!

1 Like

:thinking:

data:
  code: '1234'

The integration for my EV has a service call that awaits a PIN code for unlocking the car. This is sent in the data: code: format. Obviously, the PIN is not 1234. Nevertheless, it’s a 4-digit PIN. Security-wise not safe at all. :smiley: