Garage door swipe switch with open/close sensor button

Hi everyone,

I am trying to figure out how to make a lock button like my Eufy door lock. This requires the switch to be swiped in order to lock/unlock.

I have a Shelly 1 hooked up to my garage door. I also have a zigbee magnetic sensor on the door. What I am trying to do is make a button that looks like the front door to display Garage Door Open/Closed, as well as have the switch need to be swiped.

This is what the front door lock looks like

And this is what it looks like with when the button is pressed.

I have looked at Template Lock - Home Assistant but I have no idea how to use that code. I understand I need to put it in config.yaml, but then I have no idea how to add it to lovelace. I’m still trying to wrap my head around how HA is put together.

My garage door switch ( shelly ) is switch.garagedoor_switch
My garage door sensor is binary_sensor.garagedoor_sensor

Any help is appreciated.

Cheers!

Alright, I got it sorted. For anyone else who needs this information, here is the code.

lock:
  - platform: template
    name: Garage Door
    value_template: "{{ is_state('binary_sensor.garagedoor_sensor', 'off') }}"
    lock:
      service: switch.toggle
      target:
        entity_id: switch.garagedoor_switch
    unlock:
      service: switch.toggle
      target:
        entity_id: switch.garagedoor_switch

I wasn’t restarting home assistant and due to that the entity was not showing up. After a restart it worked.