Lock
The more-info view of a lock, with a big lock switch and a separate, confirmed button to open the door.
The main control of a lock is a big vertical control switch. Locked is at the top, unlocked at the bottom, with a closed and an open padlock as icons. The switch takes the color of the state, like green for locked.
While the lock is locking or unlocking, the icon pulses, so you see that something is happening even before the state changes.
Some locks can also open the door, not just unlock it. The front door lock above supports that, so it gets an Open door button below the switch. Opening a door is not something you want to do by accident, so it takes two taps:
- Select Open door. The button changes to Really open?.
- Select it again within a few seconds to open the door. The button shows Done for a moment, then returns to Open door.
When you wait too long, the button goes back to Open door by itself.
- Jammed: the switch is replaced by a large icon of the jammed lock, with Unlock and Lock buttons below it, so you can try again in either direction.
- Unknown: the switch becomes two separate buttons, Lock and Unlock, since there is no state to put the switch in.
- Open, opening, locking, or unlocking: Open door is disabled, because the door is already open or busy.
- When a lock needs a code, Home Assistant asks for it in a separate dialog before it locks, unlocks, or opens. A code stored in the entity settings skips that question.
- Locking and unlocking are one gesture on the same switch. Opening the door is kept apart, as a button with its own confirmation, because it can't be undone by flipping the switch back.
The view is more-info-lock in src/dialogs/more-info/controls/more-info-lock.ts. The switch is ha-state-control-lock-toggle in src/state-control/lock/. The helpers, like canOpen and callProtectedLockService, and the LockEntityFeature enum are in src/data/lock.ts.
Source: more-info-lock.ts