iantrich / restriction-card

🔒 Apply restrictions to Lovelace cards
MIT License
254 stars 22 forks source link

Not working in Home Assistant 2024.3.3 #110

Closed wgstarks closed 3 months ago

wgstarks commented 3 months ago

Checklist:

Release with the issue:

1.2.9

Last working release (if known):

Browser and Operating System:

MacOS Safari, Firefox, Chrome, HA app

Description of problem:

Javascript errors shown in the web inspector (if applicable):

Additional information:

I'm not seeing anything in the logs.

Sample YAML configuration- type: custom:restriction-card row: true card: entity: switch.greenhouse_lights_switch restrictions: confirm: text: Are you sure you want to turn the lights on/off?

ildar170975 commented 3 months ago

Fix the posted code, it is unformatted. And do not post it as a picture.

wgstarks commented 3 months ago

Fix the posted code, it is unformatted. And do not post it as a picture.

Not sure how to post the yaml and preserve formatting? If I attempt to edit it it appears with the proper formatting.

wgstarks commented 3 months ago

Ok got it.

type: custom:restriction-card
row: true
card:
  entity: switch.greenhouse_lights_switch
restrictions:
  confirm:
    text: Are you sure you want to turn the lights on/off?
ildar170975 commented 3 months ago

The "row" card is supposed to be used in Entities card. Is it what you do?

wgstarks commented 3 months ago

Yes. Here is the entire card-

type: entities
entities:
  - entity: sensor.greenhouse_temperature_humidity_greenhouse_temperature
  - entity: sensor.greenhouse_temperature_humidity_greenhouse_humidity
  - type: custom:restriction-card
    row: true
    card:
      entity: switch.greenhouse_lights_switch
    restrictions:
      confirm:
        text: Are you sure you want to turn the lights on/off?
  - type: custom:restriction-card
    row: true
    card:
      entity: switch.greenhouse_heater_greenhouse_heater
    restrictions:
      confirm:
        text: Are you sure you want to turn the heater on/off?
  - entity: binary_sensor.front_door_1_front_door_1
  - entity: binary_sensor.front_door_2_front_door_2
  - entity: switch.greenhouse_lights_switch
    name: Greenhouse Lights
    secondary_info: entity-id
    icon: mdi:lightbulb
  - entity: switch.greenhouse_heater_greenhouse_heater
    secondary_info: entity-id
ildar170975 commented 3 months ago

And what do you mean by "not working"? It was not described in your post.

Besides, those "checkboxes" which you missed were with some meaning.

wgstarks commented 3 months ago

It has stopped changing the state of the switch. If I click the switch I get the confirmation popup, select ok and then the state of the switch remains unchanged. This card was working properly until the most recent update to home assistant.

ildar170975 commented 3 months ago

The restriction-card DOES NOT change states of entities. The card merely intercepts a mouse events when in a "locked" state. In your particular case: after pressing OK in a confirmation dialog you may do whatever you want - either tap on a row or toggle a switch.

wgstarks commented 3 months ago

Thanks. In my original testing a single click was all that was needed but it appears that was improper operation and whatever the problem was is now corrected.

Again, thanks for the support.

ildar170975 commented 3 months ago

Good that you sorted it out. Here is a discussion of this card: https://community.home-assistant.io/t/lovelace-restriction-card-client-side-security/142889 Please ask all card-related questions there.