Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Person card custom zones do not work #41

Closed
gazpachoking opened this issue Nov 15, 2021 · 3 comments · Fixed by #87
Closed

Person card custom zones do not work #41

gazpachoking opened this issue Nov 15, 2021 · 3 comments · Fixed by #87

Comments

@gazpachoking
Copy link

When using the person card with custom zones defined, the card will crash with the following error if the person is in one of the custom zones:

ButtonCardJSTemplateError: TypeError: states[variables.ulm_card_person_zone1] is undefined in 'if (states[variables.ulm_card_person_entity].state != 'home'){ if (states[variables.ulm_card_p...'

Taking a peek at the code, it looks like this is because the custom zones defined (ulm_card_person_zone1, and ulm_card_person_zone2) need to be the friendly name of the zones to match the persons state, but then the zone entity is tried to look up with just the friendly name. Suggested fix would be to have the ulm_card_person_zone1 variables be defined as the actual zone, i.e. zone.work, then tweak the icon lookup function to something like this: (beware, I'm not a js developer, so it might need some further tweaks)

        if (states[variables.ulm_card_person_entity].state != 'home'){
          if (states[variables.ulm_card_person_entity].state == states[variables.ulm_card_person_zone1].attributes.friendly_name){
            var icon = states[variables.ulm_card_person_zone1].attributes.icon != null ? states[variables.ulm_card_person_zone1].attributes.icon : 'mdi:help-circle'
            return '<ha-icon icon="' + icon + '" style="width: 10px; height: 10px; color: var(--primary-background-color);"></ha-icon>';
          } else if (states[variables.ulm_card_person_entity].state == states[variables.ulm_card_person_zone2].attributes.friendly_name){
            var icon = states[variables.ulm_card_person_zone2].attributes.icon != null ? states[variables.ulm_card_person_zone2].attributes.icon : 'mdi:help-circle'
            return '<ha-icon icon="' + icon + '" style="width: 10px; height: 10px; color: var(--primary-background-color);"></ha-icon>';
          } else {
            return '<ha-icon icon="mdi:home-minus" style="width: 10px; height: 10px; color: var(--primary-background-color);"></ha-icon>';
          }
        } else {
          return '<ha-icon icon="mdi:home-variant" style="width: 10px; height: 10px; color: var(--primary-background-color);"></ha-icon>';
        }
@gazpachoking
Copy link
Author

I tested this change and it seems to work.

@CM000n
Copy link
Collaborator

CM000n commented Dec 15, 2021

Thanks for your investigation! That should be fixed with: #87

@CM000n
Copy link
Collaborator

CM000n commented Dec 19, 2021

Closed in v1.0.0-beta.8 🏳️‍🌈

@CM000n CM000n closed this as completed Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants