Lovelace Restriction Card - Client-side Security

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

That did the trick, thanks!

Is there any way to use this with an autogenerated list of entities from the lovelace-auto-entities card?

Iā€™ve got an autogenerated list of smart plugs:
kasa1

Using the following code:

type: 'custom:auto-entities'
card:
  type: entities
  title: Kasa Switches
  show_header_toggle: false
filter:
  include:
    - domain: switch
      entity_id: /.*kasa.*/
sort:
  method: name

I can wrap the ā€˜wholeā€™ card in a restriction-card and get one padlock up the top, but is there any way of integrating restriction-card on each resulting row (acknowledging that the restrictions/exemptions/conditions would be identical for all rows)?

Sorry if this is asking for too much but I canā€™t wrap my head around how I should combine these two cards I have placed in a horizontal stack into a restriction-card so they get the same height. (I only want to pin protect the second button)

type: horizontal-stack
cards:
  - type: glance
    entities:
      - entity: light.dimmable_light_2_2
        name: Hallway
        tap_action:
          action: toggle
    state_color: true
    show_icon: true
    show_state: false
    show_name: true
  - type: 'custom:restriction-card'
    restrictions:
      pin:
        code: 1976
    card:
      type: button
      name: null
      tap_action:
        action: call-service
        service: notify.mobile_app_oneplus_a6013
        service_data:
          message: Home Assistant
          title: Home Assistant is searching your phone!
          data:
            ttl: 0
            priority: high
            channel: alarm_stream
      icon: 'mdi:cellphone-wireless'
      icon_height: 25px

This is how it looks nowimage

That is likely core not waiting for custom cards to report the card height which is what it uses for layout stuff. There was also some stuff done earlier in the year to make cards height line up but it is likely applied to my wrapper card (Iā€™m sure it is actually) and that doesnā€™t trickle down to the button card. Log an issue on Github and Iā€™ll see what I can do after the holidays.