Lovelace Restriction Card - Client-side Security

since we don’t have an option to really lock our Tile cards natively (and I want to guard my garage door), I tried the restriction card, and I admit it doesnt look bad. Figured I’d share, as I didnt find many examples for the combination restriction/tile cards myself:

only showing it to several users:

- type: conditional
  conditions:
    - condition: user
      users:
        - !secret admin_m
        - !secret admin_w
        - !secret user_m
  card:
    type: custom:restriction-card
    card:
      type: tile
      entity: cover.garage_deur
      state_content:
        - state
        - current_position
        - last-changed
    condition:
      entity: cover.garage_deur
      value: closed
    restrictions:
      confirm:
        text: 'Garagedeur openen?'
      pin:
        text: 'Voer Pincode in:'
        code: !secret tahoma_secret
        max_retries: 3
        max_retries_delay: 30

my restriction card variables are set globally in the themes:

    restriction-lock-row-margin-left: calc(100% - 25px) #95%
    restriction-regular-lock-color: var(--alert-color) #red
    restriction-lock-opacity: 0.8

Hey,
Is there a way that i protect my entities list
that we can toggle from off to on and that its locked if the switch is on

type: entities
entities:
  - entity: input_boolean.klus_1
  - entity: input_boolean.klus_2

how could i use the restrictions card in this case?
I use this as usecase that the kids can toogle tasks they have done but that they cannot switch off them selfs without the code only toggle on
Could anyone help me with the code? :slight_smile:

Hi can any help me to customize the “lock” icon? Cannot solve it to geht the lock-icon allign right on the button with card_mod.
can anyone help me with this?

image

Below my code:

type: custom:restriction-card
restrictions:
  confirm: null
  pin:
    text: Please enter Pin-Code to access
    code: 12345
card:
  type: custom:button-card
  name: TEST
  aspect_ratio: 4/0.9
  icon: mdi:lan
  tap_action:
    action: navigate
    navigation_path: /dashboard
  card_mod:
    style: |
      ha-card {
      background: rgba(0,0,0,0.1);
      width: 35% !important;
      height: 100% !important;
      margin-left: 65%; !important;
      }

Hey,

im very confused with this card and pretty sure im using it wrong. All im trying to do is blocking a card based on a template-based binary_sensor.

type: custom:restriction-card
restrictions:
  block:
    condition:
      entity: binary_sensor.nas_is_up
      state: 'on'
card:
  type: entities
  entities: []

I tryed out many variations. With and without the “block”. Putting it into the entities card. Setting it ture or false…

No matter what i do i cant lock this card based on my sensor. Some help would be great :slight_smile:

K, i think now i got it. There is no “state” i have to use “value” and an "operator.
Should be something like this

type: custom:restriction-card
restrictions:
  block:
    condition:
      entity: binary_sensor.nas_is_up
      operator: '=='
      value: 'on'
card:
  type: entities
  entities: []

But tell me it its still not the way its supposed to be used :smiley:

Is it possible to only restrict the header of a card? I want to protect the header toggle (show a warning before) while the rest of the card should be clickable without any restrictions:

      - type: entities
        title: Alle Lichter (⚠)
        state_color: true
        show_header_toggle: true
        entities:
        ...

The thing is: the header toggle is linked to all entities listed in the entities section. If I would apply restriction card to a entity (as row) called All lights I can’t take advantage of that header toggle aggregation - but would need a separate script or run a service etc… Every possible workaround coming to my mind gets way too complicated - which is why I hope something is possible from the UI / restriction card side.

Can somebody help me what am I doing wrong, in the pop-up window to I don’t see the values evaluated:

        restrictions:
          block:
            text: I know she is cute, but she already had her meal ;)
            exemptions:
              - user: ec8de46da4594643986abcf16417ea0c
              - user: 3df675cbcf1f435f95333cbc90b64741
          confirm:
            text: >-
              Are you sure you want to dispense one more meal to Unut? She
              already had {{
              states('sensor.feeder_unut_weight_dispensed_today') }} {{
              state_attr('sensor.feeder_unut_weight_dispensed_today',
              'unit_of_measurement') }} today!
        type: custom:restriction-card
        row: true

The card does not support templates.

you can encapsulate this card inside a type: custom:config-template-card, set the variable there and use that in your popup like:

  type: custom:config-template-card
  entities:
    - '[[entity]]'
  variables:
    id: states[ '[[entity]]' ].attributes.friendly_name
  card:
    type: custom:mod-card
    card_mod:
      style:
        .: |
          ha-card {
            --restriction-lock-icon-size: 14px;
            --restriction-regular-lock-color: var(--background-color-on);
            --restriction-success-lock-color: var(--ok-color);
            --restriction-lock-opacity: 0.8;
          }
        restriction-card$: |
          ha-icon {
            display: flex;
            position: absolute;
            top: 8px;
            left: 40px;
            background: red;
            border-radius: 50%;
          }
    card:
      type: custom:restriction-card
      restrictions:
        confirm:
          text: ${'Wil je ' + id + ' schakelen?'}
      card:
        type: '[[type]]'
        entity: '[[entity]]'
        name: '[[name]]'
        tap_action:
          action: toggle

you could ofc use any template.

be aware though the card is reevaluated upon each state change for your variables, so could become a heavy element in your views

1 Like

Greetings everyone,
this is a great solution for blocking.
I wonder if it is possible to hide or mask the IP address of the password request pop up
Thank you

1 Like

Please can someone help me understand why I can’t get restriction-card to toggle an input boolean. No action I do will give a logbook entry.

Have tried both pin protected and plain confirm.
Have tried call-service and action: toggle
Have tried a mix of all the options (shown below) and minimal options.
Plain button without the restriction-card will work.
What am I doing wrong?

type: custom:restriction-card
restrictions:
  confirm: null
  pin:
    code: 1234
    text: TV Lockout PIN code
    retry_delay: 0
    max_retries: unlimited
    max_retries_delay: 0
    exemptions:
      - user: null
card:
  type: button
  show_name: true
  show_icon: true
  entity: input_boolean.tv_lockout
  tap_action:
    action: call-service
    service: input_boolean.toggle
    target:
      entity_id:
        - input_boolean.tv_lockout

Restriction card does not toggle. It only prevents passing mouse events to the inner card.

Thanks. Simple user error.
Obvious now you say it otherwise it would not operate with more complex cards.

Anyone with an idea on this?

Then how can this be done so that it does trigger an input boolean? Or a script? Or something? It really wasn’t clear to me that this is the functionality and I wasted a half hour discovering this only when I found your comment.

What is “this”?
If you place , for instance, Entities card inside restriction-card, provide corresponding tap_action code on the Entities card.

How do I apply themes from themes.yml on a restriction-card ?

Thanks

You apply it to the card that the restriction card is applied to.

type: custom:restriction-card
### not here ###
condition:
  entity: input_boolean.unlock_restrictions
  value: 'off'
restrictions:
  pin:
    code: 1234
card:
  entity: switch.dishwasher
  template: switch_button
  type: custom:button-card
  ### apply your theme here ###

Hi

Can I check if this Restriction Card is still active?

I’m installing from HACS and it doesn’t seem to load. Other cards work fine.

Thanks

It’s still working for me. Clear your browser cache?