Here is the situation, a Schlage bluetoooth lock which is only HomeKit enabled, the lock is HomeKit paired but doesn’t show up in Home Assistant even if the HomeKit (bridge) integration is there.
I also have an AppleTV 4K which acts as a HomeKit Hub (as I can lock or unock from outside).
I followed a trick found on this forum : create a dummy input boolean, expose it to HomeKit (which I did) and then setup some HomeKit Automation to sync the input boolean with the HomeKit Lock.
That’s OK, but I have other locks and this one is showing and acting as an input boolean. I would like it to be seen as a lock so that it’s icon and behaviour is the same as the others i.e. its state is locked or unlocked not on or off.
I think the road to go is templating but I’m not sure this is the right way and I don"t understand all of it.
On the Template Lock page we can read this code :
my dummy input boolean is : ‘input_boolean.back_door_lock_bool’.
Can someone translate this code in plain english, my translation would begin “create a lock which name is Garage door…” but after this I’m stuck.
I have not used the lock function before, so I hope its behavior is similar to switch. So in your case it should look something like this, where the status is depending on the input_boolean state. Since it is a dummy and not a source, I use an extra service to force the dummy to the right state.
Thanks guys, this should work as it looks like what I found elsewhere for different cases but I would like to understand before implementing.
Lets tell you what I get and what I don’t :
lock:
- platform: template
name: Garage door
This must be “create a fake lock which name is Garage door”
Is this part the one that should be triggered when input_boolean.back_door_lock_bool is on ?
1- If so, and if the input boolean is already on, why would I call a service to turn it on ?
2- If we’re talking about a lock, why am I calling a switch.turn_on service and not a lock.lock service ?
The value template determines the state of your lock, if the input_boolean is on, the lock shows the state locked, if the input_boolean is off the lock shows unlocked.
The service in the lock: section is executed when you lock the lock, meaning when the lock is unlocked (input_boolean is off) and you loxk it through the UI for example, it will turn the input_boolean on and the status of the lock will change to locked.
Same goes for the unlock: block.
You’re telling me that I have to deal with my input_boolean within the template ?
But I already have an input boolean as
input_boolean:
back_door_lock_bool:
name: BckDoorLock
icon: mdi:Door
initial: off
This dummy lock works, I mean I can switch it on or off from the UI.
As far as I understand, that’s not the way to do it, I must not make an input boolean as a dummy lock + the template. The template alone is enough to manage all this game ?
What I don’t get is the : If the input boolean is on then switch on input boolean . That doesn’t make sens for me.
No, you need to create the input boolean in order to use it for the lock.
That’s not what happens. When the inout boolean is on, you template lock will be locked, so you can’t lock it, you can only unlock it and when you unlock it, it executes the service to turn the input boolean off.
So it’s for keeping synced the input boolean with the template.
Let me comment the code as I understand it…
lock: # Among locks
- platform: template # One is a fake one
name: Garage door # Which name is Garage door
value_template: "{{ is_state('input_boolean.back_door_lock_bool', 'on') }}" # When input boolean is on...
lock: # This dummy lock is locked
- service: input_boolean.turn_on # and turn on the input boolean (if ever it was off)
entity_id: input_boolean.back_door_lock_bool
- service: switch.turn_on # WHAT SWITCH ? we're only talking of locks and input booleans ??
data:
entity_id: switch.door
unlock: # When the dummy lock is not on
- service: input_boolean.turn_off # Turn an input boolean off
entity_id: input_boolean.back_door_lock_bool #specificaly this input boolean
- service: switch.turn_off
data:
entity_id: switch.door
Another question comes to me : Would’nt it be easier and more elegant to customize my input_boolean as a lock ?
What’s the difference between this method and making a customization from the UI ?
Would it generate the same lines ?
got it ! Thanks.
Yes it matters as this is for sync with HomeKit, so user should be able to lock/unlock from HA, from HomeKit and from the physical lock.