{"id":13588702,"url":"https://github.com/iantrich/restriction-card","last_synced_at":"2026-03-02T06:04:51.077Z","repository":{"id":37984029,"uuid":"215633404","full_name":"iantrich/restriction-card","owner":"iantrich","description":"🔒 Apply restrictions to Lovelace cards","archived":false,"fork":false,"pushed_at":"2024-07-31T15:16:30.000Z","size":3689,"stargazers_count":271,"open_issues_count":12,"forks_count":23,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-14T08:47:16.954Z","etag":null,"topics":["custom-card","home-assistant","lovelace","security"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iantrich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["iantrich"]}},"created_at":"2019-10-16T19:59:16.000Z","updated_at":"2024-10-06T17:58:21.000Z","dependencies_parsed_at":"2024-10-26T00:30:10.313Z","dependency_job_id":null,"html_url":"https://github.com/iantrich/restriction-card","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iantrich%2Frestriction-card","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iantrich%2Frestriction-card/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iantrich%2Frestriction-card/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iantrich%2Frestriction-card/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iantrich","download_url":"https://codeload.github.com/iantrich/restriction-card/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445671,"owners_count":20939958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom-card","home-assistant","lovelace","security"],"created_at":"2024-08-01T15:06:52.508Z","updated_at":"2025-10-26T07:16:20.021Z","avatar_url":"https://github.com/iantrich.png","language":"TypeScript","funding_links":["https://github.com/sponsors/iantrich","https://www.buymeacoffee.com/zJtVxUAgH"],"categories":["Install from Source","Dashboards","TypeScript"],"sub_categories":["Smart Home Automation","Custom Cards"],"readme":"# 🔒 Restriction Card\n\nA card to provide restrictions on Lovelace cards defined within.\n\n## Disclaimer\n\nThis card is not to be used as a means to truly protect an instance. Someone with the means and knowledge will be able to bypass the restrictions presented by this card should they choose to.\n\n[![GitHub Release][releases-shield]][releases]\n[![License][license-shield]](LICENSE.md)\n[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge)](https://github.com/hacs/integration)\n\n![Project Maintenance][maintenance-shield]\n[![GitHub Activity][commits-shield]][commits]\n\n[![Discord][discord-shield]][discord]\n[![Community Forum][forum-shield]][forum]\n\n## Minimum Home Assistant version\n\nHome Assistant version 0.110.0 or higher is required as of release 1.2.0 of restriction-card\n\n## Support\n\nHey dude! Help me out for a couple of :beers: or a :coffee:!\n\n[![coffee](https://www.buymeacoffee.com/assets/img/custom_images/black_img.png)](https://www.buymeacoffee.com/zJtVxUAgH)\n\n## Installation\n\nUse [HACS](https://hacs.xyz) or follow this [guide](https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins)\n\n```yaml\nresources:\n  url: /local/restriction-card.js\n  type: module\n```\n\n## Options\n\n| Name          | Type    | Requirement  | Description                                                                                     |\n| ------------- | ------- | ------------ | ----------------------------------------------------------------------------------------------- |\n| type          | string  | **Required** | `custom:restriction-card`                                                                       |\n| card          | map     | **Required** | Card to render within `restriction-card`                                                        |\n| restrictions  | map     | **Optional** | Additional restrictions. See [Restrictions options](#restrictions-options)                      |\n| exemptions    | list    | **Optional** | List of exemption objects. See [Exemption options](#exemption-options)                          |\n| condition     | map     | **Optional** | Conditional object to make lock active. See [Condition options](#condition-options)             |\n| row           | boolean | **Optional** | Set to true to give a default `margin:left: 24px`                                               |\n| duration      | number  | **Optional** | Duration of unlock in seconds. Default is `5`                                                   |\n| action        | string  | **Optional** | Action type to trigger the unlock. Options are `tap`, `double_tap`, or `hold`. Default is `tap` |\n| locked_icon   | string  | **Optional** | Icon to show when locked. Default is `mdi:lock-outline`                                         |\n| unlocked_icon | string  | **Optional** | Icon to show when unlocked instead of fading the icon away                                      |\n| css_variables | map     | **Optional** | Set to override default theme variables. See [css_variables option](#css_variables-option)    |\n\n## Restrictions options\n\n| Name    | Type | Requirement  | Description                                                               |\n| ------- | ---- | ------------ | ------------------------------------------------------------------------- |\n| confirm | map  | **Optional** | Confirmation unlock restriction. See [Confirm options](#confirm-options) |\n| pin     | map  | **Optional** | Pin code restriction. See [Pin options](#pin-options)                    |\n| block   | map  | **Optional** | Block interaction restriction. See [Block options](#block-options)       |\n| hide    | map  | **Optional** | Hide card restriction. See [Hide options](#hide-options)                |\n\n## Confirm options\n\n| Name       | Type   | Requirement  | Description                                                                                 |\n| ---------- | ------ | ------------ | ------------------------------------------------------------------------------------------- |\n| text       | string | **Optional** | Text to display in confirmation dialog                                                      |\n| exemptions | list   | **Optional** | List of exemption objects. See [Exemption options](#exemption-options)                     |\n| condition  | map    | **Optional** | Conditional object to make restriction active. See [Condition options](#condition-options) |\n\n## Pin options\n\n| Name              | Type   | Requirement  | Description                                                                                                               |\n| ----------------- | ------ | ------------ | ------------------------------------------------------------------------------------------------------------------------- |\n| code               | string/list  | **Required** | Pin code the user needs to enter to unlock. Could be a list of codes                                                                                |\n| text              | string | **Optional** | Text to display in prompt dialog                                                                                          |\n| exemptions        | list   | **Optional** | List of exemption objects. See [Exemption options](#exemption-options)                                                   |\n| condition         | map    | **Optional** | Conditional object to make restriction active. See [Condition options](#condition-options)                               |\n| retry_delay       | number | **Optional** | Number of seconds that you want to delay next attempt to unlock. Default is `0`                                           |\n| max_retries       | number | **Optional** | Number of consecutive invalid retries allowed before blocking for the `max_retries_delay` seconds. Default is `unlimited` |\n| max_retries_delay | number | **Optional** | Number of seconds to block attempts to unlock after the `max_retries` has been reached                                    |\n\n## Block options\n\n| Name       | Type   | Requirement  | Description                                                                                 |\n| ---------- | ------ | ------------ | ------------------------------------------------------------------------------------------- |\n| text       | string | **Optional** | Text to display in alert                                                                    |\n| exemptions | list   | **Optional** | List of exemption objects. See [Exemption options](#exemption-options)                     |\n| condition  | map    | **Optional** | Conditional object to make restriction active. See [Condition options](#condition-options) |\n\n## Hide options\n\n| Name       | Type | Requirement  | Description                                                                                 |\n| ---------- | ---- | ------------ | ------------------------------------------------------------------------------------------- |\n| exemptions | list | **Optional** | List of exemption objects. See [Exemption options](#exemption-options)                     |\n| condition  | map  | **Optional** | Conditional object to make restriction active. See [Condition options](#condition-options) |\n\n## Exemption options\n\n| Name | Type   | Requirement  | Description                                                |\n| ---- | ------ | ------------ | ---------------------------------------------------------- |\n| user | string | **Required** | User id to exempt. This is found in the user profile `ID` |\n\n## Condition options\n\n| Name      | Type   | Requirement  | Description                                                                                         |\n| --------- | ------ | ------------ | --------------------------------------------------------------------------------------------------- |\n| value     | string | **Required** | String representing the state                                                                      |\n| entity    | string | **Required** | Entity to use condition and is what also causes the card to update                                  |\n| attribute | string | **Optional** | Attribute of the entity to use instead of the state                                                |\n| operator  | string | **Optional** | Operator to use in the comparison. Can be `==`,`\u003c=`,`\u003c`,`\u003e=`,`\u003e`,`!=`, or `regex`. Default is `==` |\n\n## Theme variables\n\nThe following variables are available and can be set in your theme to change the appearance of the restriction-card.\nColors can be specified by color name, hexadecimal, rgb, rgba, hsl, hsla, basically anything supported by CSS.\n\n| name                               | Default              | Description                                            |\n| ---------------------------------- | -------------------- | ------------------------------------------------------ |\n| `restriction-regular-lock-color`   | `primary-text-color` | Lock color                                             |\n| `restriction-success-lock-color`   | `primary-color`      | Lock color when unlocked                               |\n| `restriction-blocked-lock-color`   | `error-state-color`  | Lock color when card is blocked                        |\n| `restriction-invalid-lock-color`       | `error-state-color`  | Lock color after an invalid attempt to unlock          |\n| `restriction-lock-margin-left`     | `0px`                | Manually set the left margin of the lock icon (right for RTL)          |\n| `restriction-lock-margin-top`     | `0px`                | Manually set the top margin of the lock icon          |\n| `restriction-lock-row-margin-left` | `24px`               | Manually set the left margin of the lock icon in a row (right for RTL) |\n| `restriction-lock-row-margin-top`  | `0px`                | Manually set the top margin of the lock icon in a row |\n| `restriction-lock-icon-size`       | `24px`               | Lock icon size                                         |\n| `restriction-lock-opacity`         | `0.5`                | Lock icon opacity                                      |\n| `restriction-overlay-background`        | `unset`              | Overlay background when locked                          |\n| `restriction-overlay-row-outline`       | `none`               | Outline for an overlay in a row when locked             |\n| `restriction-overlay-background-blocked`  | `unset`            | Overlay background when blocked                         |\n| `restriction-overlay-row-outline-blocked` | `none`             | Outline for an overlay in a row when blocked            |\n| `restriction-overlay-row-border-radius` | `0`                  | Border radius for an overlay in a row                   |\n\nNote: it is not recommended to set negative values for `*-lock-*-margin-*` variables to prevent a \"lock\" icon to be clipped.\n\n## css_variables option\n\nThe `css_variables` option can be used to override default values of supported [theme variables](#theme-variables).\nAlternatively, these variables can be defined in a custom Frontend theme or by [card-mod](https://github.com/thomasloven/lovelace-card-mod) locally.\nEach entry in `css_variables` option must represent a \"name: value\" pair for a variable which should be overridden where `name` is a name of a variable prefixed by `--`, see an example below:\n```\ncss_variables:\n  --restriction-regular-lock-color: red\n  --restriction-success-lock-color: cyan\n```\nNote: jinja templates are not supported, use card-mod if you need templates.\n\n## Example configurations\n\nSimple lock example\n\n![lock](lock.gif)\n\n```yaml\ntype: custom:restriction-card\ncard:\n  type: thermostat\n  entity: climate.house\n```\n##\nMore complex example\n\n![complex](pin.gif)\n\n```yaml\ntype: custom:restriction-card\nrestrictions:\n  confirm:\n    exemptions:\n      - user: adminid\n  pin:\n    code: 1234\n    exemptions:\n      - user: wifeid\n      - user: adminid\n  block:\n    exemptions:\n      - user: guestid\n      - user: wifeid\n      - user: adminid\nexemptions:\n  - user: ianid\ncard:\n  type: thermostat\n  entity: climate.house\n```\n##\nRow example\n\n![row](row.png)\n\n```yaml\ntype: 'custom:hui-entities-card'\nentities:\n  - card:\n      entity: cover.garage_door\n    restrictions:\n      block: true\n    type: 'custom:restriction-card'\n    row: true\n  - entity: light.kitchen\n```\n##\nOverlay background example\n\nCard locked:\n\n![image](https://github.com/user-attachments/assets/54b64298-ba6f-4687-a704-e63dc2a1b11e)\n```yaml\ntype: custom:restriction-card\ncard:\n  type: entities\n  entities:\n    - entity: switch.test_switch\n```\n\nRow locked:\n\n![image](https://github.com/user-attachments/assets/93752506-b2df-44fa-ae66-b36bdd430f1d)\n```yaml\ntype: entities\nentities:\n  - type: custom:restriction-card\n    row: true\n    card:\n      entity: switch.test_switch\n```\n\nCard blocked:\n\n![image](https://github.com/user-attachments/assets/a9336776-a2ea-4689-b801-fa43e64ab001)\n```yaml\ntype: custom:restriction-card\nrestrictions:\n  block: true\ncard:\n  type: entities\n  entities:\n    - entity: switch.test_switch\n```\n\nRow blocked:\n\n![image](https://github.com/user-attachments/assets/0ea65870-45a5-4a60-9aa8-97ce8b697934)\n```yaml\ntype: entities\nentities:\n  - type: custom:restriction-card\n    restrictions:\n      block: true\n    row: true\n    card:\n      entity: switch.test_switch\n```\n\nTheme file:\n```yaml\n  restriction-overlay-background: repeating-linear-gradient( -45deg, transparent 0 10px,var(--user-restriction-card-mask,rgba(255,0,0,0.07)) 10px 20px)\n  restriction-overlay-background-blocked: repeating-linear-gradient( -45deg, transparent 0 10px,var(--user-restriction-card-mask,rgba(127,127,127,0.07)) 10px 20px)\n  restriction-lock-opacity: 0\n  restriction-overlay-row-border-radius: 4px\n  restriction-overlay-row-outline: 1px solid rgba(255,0,0,0.1)\n  restriction-overlay-row-outline-blocked: 1px solid rgba(127,127,127,0.1)\n```\n\n##\nExample with `css_variables`\n\n![изображение](https://github.com/user-attachments/assets/e28a9d6b-db32-48e9-84f8-ab36c4bf5fb5)\n```\ntype: entities\nentities:\n  - type: custom:restriction-card\n    row: true\n    css_variables:\n      \"--restriction-overlay-background\": \u003e-\n        repeating-linear-gradient( -45deg, transparent 0\n        10px,var(--user-restriction-card-mask,rgba(255,0,0,0.07)) 10px 20px)\n      \"--restriction-lock-opacity\": 0\n      \"--restriction-overlay-row-border-radius\": 4px\n      \"--restriction-overlay-row-outline\": 1px solid rgba(255,0,0,0.1)\n    card:\n      entity: switch.test_switch\n```\n\n##\nMultiple pin codes example\n```\n...\nrestrictions:\n  pin:\n    code:\n      - abc1234\n      - 1234\n      - \"0000\"\n      - 5656\n      - 12\n      - \"0012\"\n    text: Enter pin to unlock\n...\n```\nNotes:\n1. Numerical values with leading zeros may be mistreated. To avoid this, wrap values in quotes.\n2. Dependently on a presence of alpha-numeric pin codes (like `abcd`, `abcd1234`, `12 34`, `12.24`, `12,34`) in the `code` option, a particular \"enter pin\" dialog is shown: if all values are numerical - a numerical keypad is shown, otherwise - a simple input-box allowing to input any characters.\n\n\n##\nAlterations by card-mod:\n\nIf an internal card/row's elements have `z-index` \u003e 0, it may cause issues like \"an inner card/row is not blocked (fully or partly)\".\n\nThis may be fixed by card-mod:\n```\ntype: custom:mod-card\ncard_mod:\n  style:\n    restriction-card $: |\n      #overlay {\n        z-index: 2 !important;\n      }\ncard:\n  type: custom:restriction-card\n  restrictions: ...\n  card:\n    type: alarm-panel\n    entity: alarm_control_panel.xxx\n```\nIn this example the `alarm-panel` card has a \"Disarm\" button with `z-index: 1` which makes it \"not lockable\".\n\n\n## [Troubleshooting](https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins)\n\n[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-cards/restriction-card.svg?style=for-the-badge\n[commits]: https://github.com/custom-cards/restriction-card/commits/master\n[discord]: https://discord.gg/5e9yvq\n[discord-shield]: https://img.shields.io/discord/330944238910963714.svg?style=for-the-badge\n[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge\n[forum]: https://community.home-assistant.io/t/lovelace-restriction-card-client-side-security/142889\n[license-shield]: https://img.shields.io/github/license/custom-cards/restriction-card.svg?style=for-the-badge\n[maintenance-shield]: https://img.shields.io/badge/maintainer-Ian%20Richardson%20%40iantrich-blue.svg?style=for-the-badge\n[releases-shield]: https://img.shields.io/github/release/custom-cards/restriction-card.svg?style=for-the-badge\n[releases]: https://github.com/custom-cards/restriction-card/releases\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiantrich%2Frestriction-card","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiantrich%2Frestriction-card","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiantrich%2Frestriction-card/lists"}