Add use_entity_picture option to picture-entity card#51553
Add use_entity_picture option to picture-entity card#51553DTekNOdev wants to merge 5 commits intohome-assistant:devfrom
Conversation
33eb6df to
7024be1
Compare
|
Person entities already show their entity picture in this card, so that isn't really a good example usecase. media_player is the other example I could maybe think of, but their entity_picture is conditional, it isn't always present when it is not playing. |
Thanks, working on it, agreed about person entity, ill remove the example before publishing the pr. I have lots of custom integrations using entity picture, which is why I wanted this implemented, but I was trying to avoid using those as primary examples. |
7024be1 to
68f3cd0
Compare
Add documentation for the new use_entity_picture option that allows picture-entity cards to display the entity's entity_picture attribute for all entity types, not just person and image domains. This complements frontend PR home-assistant/frontend#51553
|
I'm wondering if maybe this would be a problem for image entities. If you enable use_entity_picture, then we bypass the computeImageUrl function, which uses the state I guess to flush cached image? I'm not sure if enabling this would have negative effect for camera entities as well. I wonder if it's a little confusing in those cases. |
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
I'm not sure if this fully answers your question, but here's how
* Stub image for entities outside camera/image/person domains Key behavior:
|
12c1d98 to
905bc08
Compare
No I don't think you really hit on the issue, let me try to rephrase. An image entity, with show_entity_picture off, uses the entity picture URL with a '&state=...' suffix appended to the url. An image entity, with show_entity_picture on, uses the same entity picture URL without the suffix. I think that means when the image entity updates, it won't automatically update to the new picture if show_entity_picture is on, because it will keep hitting the stale cached version. I'm just a little worried the behavior difference will confuse people because they won't really understand if they should enable this option or not for entities which already show the entity picture. |
After investigating further, Tested now with a template image like this and updating is working also whether or not |
e2b72b1 to
7cc05a3
Compare
|
Thanks for the review @MindFreeze — I've addressed both suggestions in the latest push:
One question while we're here: would it make sense to simplify this further by removing the toggle entirely and just automatically using Happy to go in either direction — just wanted to raise it before this gets merged. |
MindFreeze
left a comment
There was a problem hiding this comment.
I wouldn't remove the toggle because tile and badge cards already have the same toggle. image is also auto populated by the stub so an empty image is not that discoverable
855103d to
cc557f7
Compare
Allow picture-entity cards to display the entity's entity_picture attribute instead of requiring a manually configured image URL. This is particularly useful for entities that dynamically set their entity_picture (e.g., update entities showing component logos, custom integrations, etc.). The static image configuration remains as a fallback when the entity_picture attribute is not present or when use_entity_picture is not enabled. Changes: - Add use_entity_picture boolean option to PictureEntityCardConfig - Implement logic to check entity_picture attribute when enabled - Update validation to accept use_entity_picture as valid image source - Add editor toggle with helper text - Add translation strings for the new option
…re_local support Address review feedback: - Rename use_entity_picture to show_entity_picture to match tile card and badge naming - Check entity_picture_local first before entity_picture, following tile card pattern - Update all references in types, card implementation, editor, and translations
a65c8f3 to
c3c44a2
Compare
Proposed change
Picture-entity cards currently only use the
entity_pictureattribute automatically forpersonandimagedomain entities. This PR adds an optionaluse_entity_picturetoggle to extend this capability to all entity types.Motivation
Previously, users had to manually configure static image URLs for these entities, even when the entity already provided a picture. This enhancement allows any entity to use its
entity_pictureattribute, just like person entities do.Many entities beyond the person/image domains set the
entity_pictureattribute:Changes
Changes
The configured static image remains as a fallback when
entity_pictureis not present or when the toggle is disabled.Example
Screenshots
Custom integration providing entity picture (HACS norway_alerts integration)
Custom integration with manufacturers api provided url as entity_picture (HACS mspa integration)
show_state: true
show_name: true
type: picture-entity
entity: sensor.mspa_oslouvc_bobbyspa_water_temperature
use_entity_picture: true
name:
type: entity
Media player
Switching media sources with music assistant and updating picture entity image through entity_picture
Music assistant on the left, entity picture on the right
Type of change
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed:
To help with the load of incoming pull requests: