iantrich / restriction-card

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

Entity condition not working #10

Closed poberth closed 4 years ago

poberth commented 4 years ago

Checklist:

Release with the issue: 1.1.7

Last working release (if known):

Browser and Operating System: Chrome on Windows 10

Description of problem: I am trying to restrict the toggling of a lovelace entity based on the state of another entity. I want to be able to toggle the row entity "switch.device_relay" only if the entity "switch.device_automatic_mode" is off.

The problem is that the restriction card is not checking the state of the entity "switch.device_automatic_mode" so I still can change the state of the entity "switch.device_relay".

Here is the code I use:

entities:
  - entity: switch.device_automatic_mode
  - type: 'custom:restriction-card'
    card:
      entity: switch.device_relay
    row: true
    conditions:
      entity: switch.device_automatic_mode
      value: off
type: entities

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

Additional information:

iantrich commented 4 years ago

condition not conditions

poberth commented 4 years ago

Sorry for the typo, I tried it back with "condition" and I just have to double click on the relay entity to toggle it's state. How can I get the behavior I want ? Do you have a complete code example?

iantrich commented 4 years ago

This is straight from my config and does work

type: entities
show_header_toggle: false
title: Doors
entities:
  - card:
      entity: cover.left_garage_door
      secondary_info: ' [[ sensor.left_garage_last_updated.state ]] ago'
      type: 'custom:secondaryinfo-entity-row'
    condition:
      entity: cover.left_garage_door
      value: closed
    row: true
    type: 'custom:restriction-card'
iantrich commented 4 years ago

off and on should be wrapped in quotes. I believe those evaluate to true/false if not explicitly set to strings