Lovelace Restriction Card - Client-side Security

I still don’t understand and there are no examples in the github docs or here. How do I block interaction with the entity unless an input boolean is off.

Edit. Never mind. Got it sorted.

Any clue why I get the huge space between the entities?

image

entities:
  - card:
      entities:
        - switch.ha_dockermon
      type: 'custom:hui-entities-card'
    type: 'custom:restriction-card'
  - card:
      entities:
        - switch.deepstack
      type: 'custom:hui-entities-card'
    type: 'custom:restriction-card'
  - card:
      entities:
        - switch.portainer
      type: 'custom:hui-entities-card'
    type: 'custom:restriction-card'
show_header_toggle: false
title: Docker Containers
type: 'custom:hui-entities-card'

Would it be because of the “card” section that is added for each?

Any chance you could share the working example? This stuff is very obtuse :wink: Thanks!

  - card:
      entity: switch.cinema_subwoofer
      state_color: true
    row: true
    type: 'custom:restriction-card'
    restrictions:
      block: true
    condition:
      entity: input_boolean.unlock_restrictions
      value: 'off'
1 Like
entities:
  - card:
      entity: switch.ha_dockermon
    type: 'custom:restriction-card'
    row: true
  - card:
      entity: switch.deepstack
    type: 'custom:restriction-card'
    row: true
  - card:
      entity: switch.portainer
    type: 'custom:restriction-card'
    row: true
show_header_toggle: false
title: Docker Containers
type: entities
1 Like

Hi all

I’m just trying to replace a simple toggle-lock-entity-row with this card

An example:

- entity: light.osram_3
  type: custom:toggle-lock-entity-row

Is it correct to do this way?

- card:
    entity: light.osram_3
  restrictions:
    block: true
  type: 'custom:restriction-card'
  row: true
  action: double_tap

I’ve tried, but after the red lock blink I can’t change the light state.
I’ve also tried adding

duration: 10

but with no success.

What is the right way?

Thanks

remove

  restrictions:
    block: true

That blocks it outright

1 Like

Thanks!

I tried to follow the examples, but I haven’t think about it…

Thanks… that did the trick! Keep up the good work - much appreciated!

Hi,

is there any option that icon of enabed switch is the same color as non-protected switch.
slika

My code:

entities:
  - card:
      entity: switch.ha_fan
    restrictions:
      block: false
    row: true
    type: 'custom:restriction-card'
  - switch.schrack_fan
  - switch.schrack_x
  - switch.xiaomi_wall_switch_ln_levi_kabinet_parapet
  - switch.xiaomi_wall_switch_ln_desni_kabinet_parapet
  - binary_sensor.xiaomi_aqara_door_window_sensor_schrack_vrata
  - automation.padavine_samodejno_zapri_okno_kabinet
  - binary_sensor.kabinet_okno_stanje
  - switch.vektiva_smarwi_kabinet_okno
show_header_toggle: false
state_color: true
title: Stikala
type: entities

Thank you for answer…

One question…

every entity which is used under “custom” restriction-card is detected as unused entity.
slika

Is there any option to fix this?

I was getting loads of recursion errors in the browser console for the restriction card in HA v0.111.2.

I have reverted to v0.110.7 and they seem to no longer occur.

I’m currently trying to setup the restriction card, but for some reason, I’m still able to “unlock” the card? I get a pop-up saying “Are you sure you want to unlock”.

type: 'custom:restriction-card'
restrictions:
  confirm:
    block: true
card:
  entities:
    - entity: automation.frontend_toggle_dark_mode
      name: Dark Mode
    - entity: automation.light_start_diming_lights_and_change_color
      name: Sunset Light Script
    - entity: automation.system_auto_reboot_ha_five_times_a_week_at_4am
      name: Home Assistant - Daily Reboot
    - entity: automation.system_auto_reboot_pi_at_wednesday_and_sunday_at_4am
      name: Raspberry Pi 4 - Two Weekly Reboot
    - entity: automation.system_backup_every_wednessday_and_sunday_at_3am
      name: Backup - Wednesday & Sunday
  show_header_toggle: false
  title: Automations
  type: entities

EDIT: Nevermind… I was being stupid. Removed the confirm to fix it.

Version 1.2.5 Released with lots of new features:

New Options

Name Type Requirement Description
locked_icon string Optional Icon to show when locked. Default is mdi:lock-outline
unlocked_icon string Optional Icon to show when unlocked instead of fading the icon away

New Pin Options

Name Type Requirement Description
retry_delay number Optional Number of seconds that you want to delay next attempt to unlock. Default is 0
max_retries number Optional Number of consecutive invalid retries allowed before blocking for the max_retries_delay seconds. Default is unlimited
max_retries_delay number Optional Number of seconds to block attempts to unlock after the max_retries has been reached

New Theme Variables

name Default Description
restriction-lock-icon-size 24px Lock icon size
restriction-lock-opacity 0.5 Lock icon opacity

It’ll be interesting to see if anyone else can reproduce this issue.

Don’t know if it’s just me, but this upgrade made my working setup stopped working. Here is the lovelace config:

entities:
  - action: double_tap
    card:
      entity: script.hass_restart
    restrictions:
      confirm:
        text: Are you sure you want to restart HA?
    row: true
    type: 'custom:restriction-card'
  - action: double_tap
    card:
      entity: script.hasspi_reboot
    restrictions:
      confirm:
        text: Are you sure you want to reboot RPi?
    row: true
    type: 'custom:restriction-card'
  - action: double_tap
    card:
      entity: script.hasspi_shutdown
    restrictions:
      confirm:
        text: Are you sure you want to shutdown RPi?
    row: true
    type: 'custom:restriction-card'
show_header_toggle: false
state_color: true
title: System Utils
type: entities

No matter what I do, I cannot unlock the entity.

HA details:
Frontend version: 20200603.3 - latest

System Health

arch armv7l
chassis
dev false
docker true
docker_version 19.03.11
hassio true
host_os Raspbian GNU/Linux 10 (buster)
installation_type Home Assistant Supervised
os_name Linux
os_version 4.19.118-v7l+
python_version 3.7.7
supervisor 228
timezone Europe/Lisbon
version 0.111.4
virtualenv false

Lovelace

dashboards 3
mode storage
resources 9
views 7

Is there anything I’m missing here?

EDIT: I just tried tap and hold and they both work, it seems an issue only with double_tap. Can you please check?

Thanks in advance.

Please log an issue on github

Here it is, as requested.

Thanks in advance.

I was having quite a time trying to implement PIN protection, a 4-digit code starting with 0, let’s say 0123. I finally tried 1234 and that works, as does 1034, so I’m thinking that it’s the leading 0 causing an issue. Am I missing something or is this a bug?

      - card:
          entities:
            - input_boolean.door_message
          type: entities
          title: Messages
        type: custom:restriction-card
        restrictions:
          pin:
            code: 0123

wrap it in quotes

1 Like