Capabilities
Lock
Domain lock: states, services, device classes and features.
Entity ids in this domain look like lock.<object_id>.
Use in preferences
{ key: 'device', label: 'Device', type: 'entity', domainFilter: 'lock', required: true }States
getState() returns the raw token. subscribe filters, entity.is() and matchesState() also accept the friendly label the app shows (any case; spaces, hyphens and underscores interchangeable).
| Device class | unlocked | locked | unlocking | locking |
|---|---|---|---|---|
| any | Unlocked | Locked | Unlocking | Locking |
subscribe($g.device, { to: 'unlocked' }, onChange);
subscribe($g.device, { to: 'Unlocked' }, onChange); // same thing, by label
if ($g.device.is('Unlocked')) { /* … */ }Services
Curated for smart apps (also offered by the wizard action catalog):
| Service | Parameters | Description |
|---|---|---|
lock | — | Lock |
toggle | — | Toggle |
unlock | — | Unlock |
await $g.device.lock();Attributes
| Attribute | Type | Description |
|---|---|---|
batteryLevel | number | Percent. |
isLow | boolean | Low-battery flag. |