Home

Awesome

🔒 Restriction Card

A card to provide restrictions on Lovelace cards defined within.

Disclaimer

This 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.

GitHub Release License hacs_badge

Project Maintenance GitHub Activity

Discord Community Forum

Minimum Home Assistant Version

Home Assistant version 0.110.0 or higher is required as of release 1.2.0 of restriction-card

Support

Hey dude! Help me out for a couple of :beers: or a :coffee:!

coffee

Installation

Use HACS or follow this guide

resources:
  url: /local/restriction-card.js
  type: module

Options

NameTypeRequirementDescription
typestringRequiredcustom:restriction-card
cardmapRequiredCard to render within restriction-card.
restrictionsmapOptionalAdditional restrictions. See Restrictions Options.
exemptionslistOptionalList of exemption objects. See Exemption Options.
conditionmapOptionalConditional object to make lock active. See Condition Options.
rowbooleanOptionalSet to true to give a default margin:left: 24px
durationnumberOptionalDuration of unlock in seconds. Default is 5
actionstringOptionalAction type to trigger the unlock. Options are tap, double_tap, or hold. Default is tap
locked_iconstringOptionalIcon to show when locked. Default is mdi:lock-outline
unlocked_iconstringOptionalIcon to show when unlocked instead of fading the icon away

Restrictions Options

NameTypeRequirementDescription
confirmmapOptionalConfirmation unlock restriction. See Confirm Options.
pinmapOptionalPin code restriction. See Pin Options.
blockmapOptionalBlock interaction restriction. See Block Options.
hidemapOptionalHide card restriction. See Hide Options..

Confirm Options

NameTypeRequirementDescription
textstringOptionalText to display in confirmation dialog
exemptionslistOptionalList of exemption objects. See Exemption Options.
conditionmapOptionalConditional object to make restriction active. See Condition Options.

Pin Options

NameTypeRequirementDescription
codestringRequiredPin code the user needs to enter to unlock
textstringOptionalText to display in prompt dialog
exemptionslistOptionalList of exemption objects. See Exemption Options.
conditionmapOptionalConditional object to make restriction active. See Condition Options.
retry_delaynumberOptionalNumber of seconds that you want to delay next attempt to unlock. Default is 0
max_retriesnumberOptionalNumber of consecutive invalid retries allowed before blocking for the max_retries_delay seconds. Default is unlimited
max_retries_delaynumberOptionalNumber of seconds to block attempts to unlock after the max_retries has been reached

Block Options

NameTypeRequirementDescription
textstringOptionalText to display in alert
exemptionslistOptionalList of exemption objects. See Exemption Options.
conditionmapOptionalConditional object to make restriction active. See Condition Options.

Hide Options

NameTypeRequirementDescription
exemptionslistOptionalList of exemption objects. See Exemption Options.
conditionmapOptionalConditional object to make restriction active. See Condition Options.

Exemption Options

NameTypeRequirementDescription
userstringRequiredUser id to exempt. This is found in the user profile ID.

Condition Options

NameTypeRequirementDescription
valuestringRequiredString representing the state.
entitystringRequiredEntity to use condition and is what also causes the card to update
attributestringOptionalAttribute of the entity to use instead of the state.
operatorstringOptionalOperator to use in the comparison. Can be ==,<=,<,>=,>,!=, or regex. Default is ==.

Theme Variables

The following variables are available and can be set in your theme to change the appearance of the lock. Can be specified by color name, hexadecimal, rgb, rgba, hsl, hsla, basically anything supported by CSS.

nameDefaultDescription
restriction-regular-lock-colorprimary-text-colorLock color
restriction-success-lock-colorprimary-colorLock color when unlocked
restriction-blocked-lock-colorerror-state-colorLock color when card is blocked
restriction-invalid--colorerror-state-colorLock color after an invalid attempt to unlock
restriction-lock-margin-left0pxManually bump the left margin of the lock icon
restriction-lock-row-margin-left24pxManually bump the left margin of the lock icon in rows
restriction-lock-row-margin-top0pxManually bump the top margin of the lock icon in rows
restriction-lock-icon-size24pxLock icon size
restriction-lock-opacity0.5Lock icon opacity

Example Configurations

Simple Lock example

lock

type: custom:restriction-card
card:
  type: thermostat
  entity: climate.house

More complex example

complex

type: custom:restriction-card
restrictions:
  confirm:
    exemptions:
      - user: adminid
  pin:
    code: 1234
    exemptions:
      - user: wifeid
      - user: adminid
  block:
    exemptions:
      - user: guestid
      - user: wifeid
      - user: adminid
exemptions:
  - user: ianid
card:
  type: thermostat
  entity: climate.house

Row example

row

type: 'custom:hui-entities-card'
entities:
  - card:
      entity: cover.garage_door
    restrictions:
      block: true
    type: 'custom:restriction-card'
    row: true
  - entity: light.kitchen

Special Consideration for Input Selects: If you find that the restriction card is blocking something you don't want blocked like an input select, try adjusting the z-index using mod-card

card:
  type: custom:mod-card
  card_mod:
    style: |
      ha-card {
        z-index: 7;
        }
  card:
    type: custom:restriction-card

Troubleshooting