thomasloven / lovelace-state-switch

đŸ”čDynamically replace lovelace cards depending on occasion
MIT License
382 stars 27 forks source link

When '<entity> = group' not working #35

Closed franksimoes closed 4 years ago

franksimoes commented 4 years ago

When using "state-switch" with the "group" option, it does not identify user "admin" or user "user". Two users were created, an administrator and another ordinary user.

H.A = 0.107.7; FireFox version 77.0.1 (64-bits) - (Desktop); Chrome version 83.0.4103.97 64 bits - (Desktop);

- title: 'Conf Admin'
  icon: mdi:settings
  id: ADMSetupDeviceIoT
  visible: true
  cards:
    - type: custom:state-switch
      entity: group
      states:
        user:
          type: entities
          title: "Config IoT-ADM"
          show_header_toggle: false
          entities:
            - !include ../_iiotadx/xxx_adm_setup_list.yaml
        admin:
          type: markdown
          content: >
            ## Admin View
thomasloven commented 4 years ago

What does that mean? Does it show nothing? Does it show the user view for both users? Does it show the admin view for both users? Does it show the opposite view? Does it show something completely different?

franksimoes commented 4 years ago

Sorry I think I was very direct and succinct.

What does that mean? I have an ‘administrator’ user (george) and another ‘user’ (teste), and I’d like to show ‘xxx_adm_setup_list.yaml’ for the ‘user’ user. If it was one of the ‘admin’ group, only the message “Admin View”.

image

Does it show nothing? Exactly, in both cases it does not show on any type of user.

Does it show the user view for both users? It does not show in both cases.

Does it show the admin view for both users? It does not show ‘admin’ view for both users.

Does it show the opposite view? Dont show nothing.

Does it show something completely different? Dont show nothing.

thomasloven commented 4 years ago

Thank you. I specifically meant what does "Not working" mean.

I don't have any ideas what might cause this... does it show anything if you set a default value? Could you please try setting the entity to something else, to see if it's the group option that's causing the problems?

franksimoes commented 4 years ago

I thank you! I would like to have this feature. I will do two tests in different scenarios to facilitate the identification of the problem.

See you later!

franksimoes commented 4 years ago

1st - Test: Redo the test as you requested and implement the "default" option.

- title: 'ConfiguraçÔes Administrador'
  icon: mdi:settings
  id: ADMSetupDeviceIoT
  visible: true
  cards:
    - type: custom:state-switch
      entity: group
      default: default
      states:
        user:
          type: entities
          title: "Config TESTE"
          show_header_toggle: false
          entities:
            - type: divider
        admin:
          type: entities
          title: "Config GEORGE"
          show_header_toggle: false
          entities:
            - type: divider
        default: 
          type: entities
          title: "Test default"
          show_header_toggle: false
          entities:
            - type: divider

Result:

franksimoes commented 4 years ago

2nd - Test with 'entity: user' for comparison.

- title: 'ConfiguraçÔes Administrador'
  icon: mdi:settings
  id: ADMSetupDeviceIoT
  visible: true
  cards:
    - type: custom:state-switch
      entity: user
      default: default
      states:
        "teste":
          type: entities
          title: "Configuração IoT-ADM"
          show_header_toggle: false
          entities:
            - type: divider
        "george":
          type: entities
          title: "Config GEORGE"
          show_header_toggle: false
          entities:
            - type: divider
        default: 
          type: entities
          title: "Test default"
          show_header_toggle: false
          entities:
            - type: divider

Result:

thomasloven commented 4 years ago

Thank you! I believe I found the problem.

franksimoes commented 4 years ago

Thank you!

franksimoes commented 4 years ago

It didn't work properly!

I did a test with 'entity: group' and recognizes both types of users as 'admin'

https://github.com/thomasloven/lovelace-state-switch/issues/35#issuecomment-642061572

thomasloven commented 4 years ago
type: custom:state-switch
entity: group
default: default
states:
  admin:
    type: markdown
    content: "# ADMIN"
  user:
    type: markdown
    content: "# USER"
  default:
    type: markdown
    content: "# DEFAULT"

Can't reproduce

franksimoes commented 4 years ago

Exactly reproduce your code, and perform the tests with both users:

thomasloven commented 4 years ago

But with your code above you get admin for both users?

franksimoes commented 4 years ago

if you refer to this code:

- title: 'ConfiguraçÔes Administrador'
  icon: mdi:settings
  id: ADMSetupDeviceIoT
  visible: true
  cards:
    - type: custom:state-switch
      entity: user
      default: default
      states:
        "teste":
          type: entities
          title: "Configuração IoT-ADM"
          show_header_toggle: false
          entities:
            - type: divider
        "george":
          type: entities
          title: "Config GEORGE"
          show_header_toggle: false
          entities:
            - type: divider
        default: 
          type: entities
          title: "Test default"
          show_header_toggle: false
          entities:
            - type: divider

Result: