iantrich / restriction-card

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

Unknown type encountered: entities #18

Closed SeLLeRoNe closed 4 years ago

SeLLeRoNe commented 4 years ago

Checklist:

Release with the issue: 1.1.9 Last working release (if known): 1.1.8 Browser and Operating System: Chgrome on Windows 10

Description of problem: Since last update my restricted cards (type: entities) are no longer working, but if I don't specify the "type" they do work.

Not really sure this was intended or not, haven't seen anything on the release note that would introduce a breaking change.

Here my card-config:

          - type: entities
            show_header_toggle: false
            entities:
              - type: "custom:restriction-card"
                restrictions:
                  block: true
                row: true
                card:
#                  type: entities
                  name: Fridge
                  entity: switch.fridge
                  state_color: true
                  tap_action:
                    action: none
              - type: "custom:restriction-card"
                restrictions:
                  block: true
                row: true
                card:
                  type: entities
                  name: Dishwasher
                  entity: switch.dishwasher
                  state_color: true
                  tap_action:
                    action: none
              - type: "custom:restriction-card"
                restrictions:
                  block: true
                row: true
                card:
                  type: entities
                  name: Toaster
                  entity: switch.toaster
                  state_color: true
                  tap_action:
                    action: none

Here how it looks: image

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

No console error apparently, sorry

Additional information:

iantrich commented 4 years ago

entities is not a valid row type. you can try custom:hui-entities-card

SeLLeRoNe commented 4 years ago

Oh okay,I through it was a bug since it was working with the previous version :)

Thanks

iantrich commented 4 years ago

it was more so an error on my part previously

SeLLeRoNe commented 4 years ago

Sorry to bother again, I did update HA this morning and now the entities needs to be in an array, which is fair enough, but the outcome is "ugly" somehow

          - type: entities
            show_header_toggle: false
            entities:
              - type: "custom:restriction-card"
                restrictions:
                  block: true
                row: true
                card:
                  type: custom:hui-entities-card
                  name: Fridge
                  entities:
                    - entity: switch.fridge
                      state_color: true
                      tap_action:
                        action: none
              - type: "custom:restriction-card"
                restrictions:
                  block: true
                row: true
                card:
                  type: custom:hui-entities-card
                  name: Dishwasher
                  entity: switch.dishwasher
                  state_color: true
                  tap_action:
                    action: none
              - type: "custom:restriction-card"
                restrictions:
                  block: true
                row: true
                card:
                  type: custom:hui-entities-card
                  name: Toaster
                  entity: switch.toaster
                  state_color: true
                  tap_action:
                    action: none

image

The first is the attempt to fix using the code as expected, the second and third are not yet fixed for that requirement, but as you can see the one fixed has the lock "miss-aligned" to the row.

Please let me know if you want me to open an issue just for this or if it's fine to re-open this one :)

Thanks again Andrea

iantrich commented 4 years ago

That's not how you define an entitites card, but also, I'm not sure why you're using the entities row to begin with when you're already in an entities card?

my suggestion

          - type: entities
            show_header_toggle: false
            state_color: true
            entities:
              - type: "custom:restriction-card"
                restrictions:
                  block: true
                row: true
                card:
                  name: Fridge
                  entity: switch.fridge
                  tap_action:
                    action: none
              - type: "custom:restriction-card"
                restrictions:
                  block: true
                row: true
                card:
                  type: custom:hui-entities-card
                  name: Dishwasher
                  entity: switch.dishwasher
                  tap_action:
                    action: none
              - type: "custom:restriction-card"
                restrictions:
                  block: true
                row: true
                card:
                  name: Toaster
                  entity: switch.toaster
                  tap_action:
                    action: none
iantrich commented 4 years ago

And the reason it is "ugly" is you added a card, but claimed it was a row in your config, so the alignment was off.

SeLLeRoNe commented 4 years ago

Ok, I must have been completely missunderstood something here.. I honestly tought I needed to specify the type on each "card:" inside the restriction-card.

Thank you very much for the time you spent on review my idiot mistake.

It is now working flawlessly!

SeLLeRoNe commented 4 years ago

Just a side note, the "state_color: true" actually needs to be in "card:" inside the resttriction card, otherwise the icon color based on the state seems to be ignored.