iantrich / restriction-card

🔒 Apply restrictions to Lovelace cards
MIT License
270 stars 23 forks source link

Dynamic restrictions #97

Closed pmkruyen closed 1 year ago

pmkruyen commented 1 year ago

👋

I want to lock/unlock a slider depending on the value of a boolean input (switch).

‘Unfortunately, the code below does not work. Is it because the switch is not in a restriction card or is my code incorrect?

Thanks for your help.

- title: Test
    path: Test
    badges: []
    cards:
      - type: entities
        entities:
          - input_boolean.ceiling_fan_state
      - type: entities
        entities:
          - card:
              entity: input_number.ceiling_fan_slider
              name: Slider
              secondary_info: last-changed
            restrictions:
              block: true
              condition:
                value: 'on'
                entity: input_boolean.ceiling_fan_state
                operator: '=='
            type: custom:restriction-card
            row: true
pmkruyen commented 1 year ago

I checked, but putting the switch in a restriction card has no effect.

ildar170975 commented 1 year ago

Because this is wrong:

          restrictions:
            block: true
            condition:
              value: 'on'
              entity: input_boolean.ceiling_fan_state
              operator: '=='

https://github.com/iantrich/restriction-card#block-options

Should be:

      restrictions:
        block:
          condition:
            value: 'on'
            entity: xxxxxxxxxxxxxxxxxxxxxx
            operator: '=='
pmkruyen commented 1 year ago

Thanks!