Combined Sensor/Lock Template

I’m trying to create a template that’s kind of a combination of a sensor and a lock (or switch). It’s a combination of a door lock and door open sensor.

I can create a template sensor easy enough:

  • “Open” when door sensor is open
  • “Locked” when door sensor is closed and door lock is locked
  • “Unlocked” otherwise

What I’d like to do is combine this in a single template entity with a lock/switch to control the door lock.

  • If the door is “Open”, no control allowed
  • If the door sensor is closed, the entity has the ability to lock/unlock the door lock

Can something like this be achieved with the current template system?

1 Like

Here’s how I do it:

Use a conditional card in the Lovelace UI to display the lock entity but only if the binary_sensor reports the door is closed. If the binary_sensor reports the door is open, the lock entity is hidden.

Thanks for the quick reply.

Just tried that and it works. In order to show the door “Open” I guess I’d create another conditional card that’s only visible when the door is open (so it’s shown instead of the lock control). Ideally I’d like to get both front and rear door showing on the same card - doesn’t look like that can be done with conditional.

What about entity filter card?
Also good idea… Could cleanup my frontend and only show one icon at a time … thanks.

I’m using a combination of conditional and entity-filter cards to get the job done.

Here’s how it appears when the (laundry) door is open. The lock controls are hidden. The security controls are hidden as well.

Screenshot%20from%202019-09-02%2022-01-40

This is its appearance when the door is closed. The controls for the lock are now visible but not the security controls (because the door is unlocked). In addition, the door’s status disappears because I’m only interested in seeing when a door is open, not closed.

Screenshot%20from%202019-09-02%2022-02-29

When the door is locked, the security controls become visible.

Screenshot%20from%202019-09-02%2022-03-21

The goal is to hide controls when it makes no sense to use them (lock doors that are still open or arm the security system when doors/windows/locks are open/unlocked).

Got it working the way I wanted. I created 4 different conditional cards, one for each scenario of front/rear doors opened/closed. Garage door is only a sensor so it’s always a sensor in the card. Front and Rear door are sensors when the door is open and lock controls when the door is closed.

This way ends up only showing a single entity on the page which includes the info/control of all 3 doors.

Hello, some years later I am trying to achieve the same result but I would like to achieve it with a template since I would like to expose the device to HomeKit later on.
Is it possible to do with current template functions?

1 Like