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

Entity bug in V4.0b15 #734

Closed
andyblac opened this issue Jul 27, 2023 · 24 comments
Closed

Entity bug in V4.0b15 #734

andyblac opened this issue Jul 27, 2023 · 24 comments
Labels

Comments

@andyblac
Copy link

andyblac commented Jul 27, 2023

Checklist

  • [ x] I updated the card to the latest version available
  • [x ] I cleared the cache of my browser

Version of the card
Version: 4.0b15

Describe the bug

  tap_action:
    action: "more-info"
    entity: "[[[ return variables.ulm_card_person_entity; ]]]"
  name: "[[[ return states[variables.ulm_card_person_entity].attributes.friendly_name ]]]"
  entity: "[[[ return variables.ulm_card_person_entity; ]]]"
  icon: "[[[ return variables.ulm_card_person_icon; ]]]"
  show_entity_picture: "[[[ return variables.ulm_card_person_use_entity_picture ]]]"
  entity_picture:
    "[[[ return variables.ulm_card_person_use_entity_picture ? states[variables.ulm_card_person_entity].attributes.entity_picture\
    \ : null ]]]"

in V3.5 the above code works fine, but in v4.0b12, when you set an entity in the tap_action and then tap on it in the dashboard you see the following error.
Screenshot 2023-07-27 at 09 52 33

in the example above the action entity and the main entity, both use the same entity variable.

Expected behavior
it should show the person enity

@andyblac andyblac added the bug Something isn't working label Jul 27, 2023
@andyblac andyblac changed the title Entity bug in V4.0b12 Entity bug in V4.0b15 Jul 27, 2023
@RomRider
Copy link
Collaborator

RomRider commented Jul 27, 2023

Can you share the relevant main card + custom_field config please?
The code has not changed on the custom_fields part on those new versions

@RomRider
Copy link
Collaborator

RomRider commented Jul 27, 2023

This works well:

          - type: custom:button-card
            variables:
              entity: light.test_light
            styles:
              grid:
                - grid-template-areas: "'test' 'icon'"
            custom_fields:
              test:
                card:
                  icon: mdi:fan
                  type: custom:button-card
                  entity: '[[[ return variables.entity; ]]]'
                  tap_action:
                    action: more-info
                    entity: '[[[ return variables.entity; ]]]'

So there's something else going on with your code

BTW, using templates for entity or show_entity_picture outside of a custom field doesn't work and has never been possible

@andyblac
Copy link
Author

andyblac commented Jul 27, 2023

          - type: "custom:button-card"
            template:
              - custom_card_andyblac_person
            entity: person.christine_leek
            variables:
              ulm_card_person_entity: person.christine_leek
              ulm_card_person_use_entity_picture: false
              ulm_card_person_icon: mdi:face-woman
              ulm_card_person_battery: sensor.christines_iphone_icloudv3_battery
              ulm_address: sensor.christines_iphone_icloudv3_zone_name
              ulm_card_person_eta: sensor.christines_iphone_icloudv3_zone_distance

thats the dashbaord code, I have also attached the entier YAML for the template.
custom_card_andyblac_person.yaml.zip

BTW this is just tweaked code from the Lovelace Minimalist project, lost of templates are now broken in 4.0 beta.

@RomRider
Copy link
Collaborator

RomRider commented Jul 27, 2023

Yeah, so what you are doing has never been possible, as stated in my last comment, you can't template entity or show_entity_picture in the main button-card. This never worked so it's unrelated to the latest beta.

@andyblac
Copy link
Author

this is strange because it works in 3.5 and Minimalist project use it all over.

@andyblac
Copy link
Author

show entity picture still works
Screenshot 2023-07-27 at 10 34 13

@RomRider
Copy link
Collaborator

RomRider commented Jul 27, 2023

Yes, but if you look here https://ui-lovelace-minimalist.github.io/UI/usage/cards/card_person/#usage, you'll see they redefine the entity in the main config + on the variables.

And again, show_entity_picture doesn't support templates (it works magically because the picture exists, else I fall back to the icon)

@andyblac
Copy link
Author

andyblac commented Jul 27, 2023

just like i do in my above code. I used their code as a base.

@RomRider
Copy link
Collaborator

RomRider commented Jul 27, 2023

What is this, then entity: "[[[ return variables.ulm_card_person_entity; ]]]" in your first post ?

This is not needed entity_picture: "[[[ return variables.ulm_card_person_use_entity_picture ? states[variables.ulm_card_person_entity].attributes.entity_picture\ \ : null ]]]" as I do it in the code directly (and anyway, it's not templatable)

@andyblac
Copy link
Author

andyblac commented Jul 27, 2023

@RomRider
Copy link
Collaborator

I was speaking about this:

  tap_action:
    action: "more-info"
    entity: "[[[ return variables.ulm_card_person_entity; ]]]"
  name: "[[[ return states[variables.ulm_card_person_entity].attributes.friendly_name ]]]"
  entity: "[[[ return variables.ulm_card_person_entity; ]]]" # <<<<<<<<< THIS HERE
  icon: "[[[ return variables.ulm_card_person_icon; ]]]"
  show_entity_picture: "[[[ return variables.ulm_card_person_use_entity_picture ]]]"
  entity_picture:
    "[[[ return variables.ulm_card_person_use_entity_picture ? states[variables.ulm_card_person_entity].attributes.entity_picture\
    \ : null ]]]"

@andyblac
Copy link
Author

andyblac commented Jul 27, 2023

yes exactly the same in there code, line 31

@andyblac
Copy link
Author

Screenshot 2023-07-27 at 10 41 09

@andyblac
Copy link
Author

if i comment out the entity from the tap_action everything works as expected, but this then means we can nolonger have a different entity for tap actions ?

@RomRider
Copy link
Collaborator

Ok, you need to share the full context... and how you instantiate the template else it's impossible to know what we're taking about. Just showing me what you shared initially and not how you use it will make me think you are trying to template the entity config entry...

@andyblac
Copy link
Author

i'm not sure, this the code i use with minimalist project. should I report the bug there instead ? I gave you my full code for dashboard and the template import.

@RomRider
Copy link
Collaborator

Alright, I found the bug now that I understand the context :)

@andyblac
Copy link
Author

sorry I could not be more help, still learning all this stuff.

github-actions bot pushed a commit that referenced this issue Jul 27, 2023
## [4.0.0-dev.16](v4.0.0-dev.15...v4.0.0-dev.16) (2023-07-27)

### Bug Fixes

* *_action more-info entity as a template was not evaluated ([02441b2](02441b2)), closes [#734](#734)
@github-actions
Copy link

🎉 This issue has been resolved in version 4.0.0-dev.16 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@andyblac
Copy link
Author

thanks alot fix works, how can I send you a donation ?

@RomRider
Copy link
Collaborator

You can't :D

@andyblac
Copy link
Author

hahah, ok, i'll keep trying to help find bugs.

github-actions bot pushed a commit that referenced this issue Jul 29, 2023
## [4.0.0](v3.5.0...v4.0.0) (2023-07-29)

### ⚠ BREAKING CHANGES

* **helpers:** If you were using any of the beta before `4.0.0-dev14`. Please replace all the calls to helper functions with `helpers.xxx` for eg. `helpers.relativeTime(entity.state)` or `helpers.localize(entity)`
* **hacs:** Minimum required HA Version is now 2023.7
* **actions:** Requires HA 2023.4 minimum. Support for the new action format (`target` is also be supported), `service_data` should be renamed to `data` (but it still works with the old format)
* **icons:** This might break your card-mod setup
* this might break some of your color settings

### Features

* **action:** `repeat_limit` for `hold_action` ([73c216f](73c216f)), closes [#564](#564) [#555](#555)
* **actions:** Support for the new action (assist) and all the future ones ([d9c17a4](d9c17a4)), closes [#711](#711) [#685](#685)
* **custom_fields:** Add `do_not_eval` to stop evaluating js templates in an embedded card ([1638cf8](1638cf8))
* **helpers:** all template functions are now available through the `helpers` object ([f22ed69](f22ed69))
* **icons:** replace ha-icon with ha-state-icon to follow new HA's icons per domain automatically ([ab6a3f5](ab6a3f5))
* **templates:** new `relativeTime` function to display a relative time in a template and update it automatically ([965a3d7](965a3d7)), closes [#701](#701)
* **templates:** New date and time format helpers ([9b4fb05](9b4fb05))
* **variables:** A variable can depend on another variable based on their name's alphabetical order ([8cddccb](8cddccb)), closes [#656](#656)
* Force the `numeric_precision` for states which are numbers ([24d75c2](24d75c2))
* new helper functions for date/time in templates ([2b75993](2b75993)), closes [#701](#701)
* Support for localization in templates ([5de2dc9](5de2dc9))

### Bug Fixes

* *_action more-info entity as a template was not evaluated ([02441b2](02441b2)), closes [#734](#734)
* `group_expand` now works even if the entity is not a `group.xxx` ([f192ded](f192ded)), closes [#645](#645)
* Color are now aligned with HA > 2022.12 ([685d55e](685d55e)), closes [#635](#635)
* custom fields would sometime throw unsafeHTML errors ([c67e1d5](c67e1d5)), closes [#725](#725)
* ha-icon (if in custom_fields) size was weird ([a448c8e](a448c8e))
* ha-state-icon CSS selector was wrong ([a1bb39a](a1bb39a))
* icon would be cut with card height defined ([19f8393](19f8393)), closes [#731](#731)
* localization fix ([02dfab3](02dfab3)), closes [#685](#685) [#693](#693)
* lock icon was displaying over more-info dialog ([bf075b0](bf075b0)), closes [#694](#694)
* lock would go out of the button ([0b3e4d3](0b3e4d3))
* non string fiels would error with an unsafeHTML error ([d65c347](d65c347)), closes [#725](#725)
* numerical states would not follow HA's format ([72d7c41](72d7c41)), closes [#662](#662)
* optimize contrast color compute ([35109c3](35109c3))
* relativeTime didn't support to set the first letter uppercase ([f8b9b09](f8b9b09)), closes [#735](#735)
* Some cards with child cards wouldn't be clickable ([9f21c58](9f21c58))
* text/icon contrast when using label-card ([01e199b](01e199b))
* variable which were objects were only evaluated once ([e40bda9](e40bda9))
* **templates:** `variables` was `undefined` if none where provided. ([fad332b](fad332b)), closes [#718](#718)
* tooltip would show over everything ([1bc8f99](1bc8f99))
* **color:** main config `color` was broken ([b93c996](b93c996))
* **hacs:** minimum HA version 2023.7 ([db3b394](db3b394))
* **templates:** don't use the `numeric_precision` from the card config for `localize` in js templates by default ([2cc384f](2cc384f))
@github-actions
Copy link

🎉 This issue has been resolved in version 4.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants