How to create a lock with lock template with only the unlock action?

My lock is a simple switch, which I use as a push button to unlock my gates. Therefore, I have no sensors to determine its state (lock or unlocked), and I also don’t have any device for locking it.

Can someone please help me to write a lock template that fulfills my needs?

I’m with something like:

# Example configuration.yaml entry
lock:
  - platform: template
    name: Gate
    value_template: "{{ true }}"
    lock:
      service: script.do_nothing
    unlock:
      service: switch.turn_on
      target:
        entity_id: switch.sonoff_1000e3edaa

But the problem is that HA (and therefore Google Assistant when integrated) will still accept commands like “lock”, without they doing anything actually.

And most importantly, in optimistic mode, the doors will appear as locked when the lock action executes. While I could disable the optimistic mode, I still like to use it for unlock, because my gate gets actually unlocked after calling “unlock”.

1 Like

Hi,
I’m interested in your request: have you solved it? Have you found a solution?

regards

Not really. I created a cover template with door device class that does nothing on close action.