-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
picture cards: add person image support #20593
Merged
piitaya
merged 11 commits into
home-assistant:dev
from
hacf-fr:picture-card/add_person_support
Jul 23, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
463d0b6
picture cards: add person image support
Quentame 415c36c
fix: person attributes typing
Quentame ce2bbf4
review: apply comment from @coderabbitai
Quentame 87c8eb7
fix lint:types
Quentame b9998e7
review: put person domain in image_entity config
Quentame b38d0f8
add picture card compatibility & exemple in gallery
Quentame 44c6b52
fix lint
Quentame c0d1213
Allow only image or person domains on image_entity editor config
Quentame 75c1632
fix domain type
Quentame 349b116
gracefully use the default config.image if the person don't have an i…
Quentame 0eb8b77
gracefully use the default config.image if the person don't have an i…
Quentame File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
title: Picture Card | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { html, LitElement, PropertyValues, TemplateResult } from "lit"; | ||
import { customElement, query } from "lit/decorators"; | ||
import { getEntity } from "../../../../src/fake_data/entity"; | ||
import { provideHass } from "../../../../src/fake_data/provide_hass"; | ||
import "../../components/demo-cards"; | ||
import { mockIcons } from "../../../../demo/src/stubs/icons"; | ||
|
||
const ENTITIES = [ | ||
getEntity("person", "paulus", "home", { | ||
friendly_name: "Paulus", | ||
entity_picture: "/images/paulus.jpg", | ||
}), | ||
]; | ||
|
||
const CONFIGS = [ | ||
{ | ||
heading: "Image URL", | ||
config: ` | ||
- type: picture | ||
image: /images/living_room.png | ||
`, | ||
}, | ||
{ | ||
heading: "Person entity", | ||
config: ` | ||
- type: picture | ||
image_entity: person.paulus | ||
`, | ||
}, | ||
{ | ||
heading: "Error: Image required", | ||
config: ` | ||
- type: picture | ||
entity: person.paulus | ||
`, | ||
}, | ||
]; | ||
|
||
@customElement("demo-lovelace-picture-card") | ||
class DemoPicture extends LitElement { | ||
@query("#demos") private _demoRoot!: HTMLElement; | ||
|
||
protected render(): TemplateResult { | ||
return html`<demo-cards id="demos" .configs=${CONFIGS}></demo-cards>`; | ||
} | ||
|
||
protected firstUpdated(changedProperties: PropertyValues) { | ||
super.firstUpdated(changedProperties); | ||
const hass = provideHass(this._demoRoot); | ||
hass.updateTranslations(null, "en"); | ||
hass.updateTranslations("lovelace", "en"); | ||
hass.addEntities(ENTITIES); | ||
mockIcons(hass); | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
"demo-lovelace-picture-card": DemoPicture; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the
attributes
field fromfetchPersons
is properly handled in all calling contexts.Would you like me to help implement or verify this handling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Quentame, it appears that the
attributes
field from thePersonEntity
is not directly referenced or manipulated in theha-config-person.ts
file or other related components in thesrc/panels/config/person/
directory. This suggests that the handling of theattributes
field might be abstracted elsewhere or not required in the current context of thefetchPersons
usage.If there are specific functionalities or components where you expect the
attributes
field to be used, please let me know, and I can further investigate those areas. Otherwise, the current implementation inha-config-person.ts
seems to focus primarily on sorting and managing person data without directly interacting with the detailed attributes ofPersonEntity
.Analysis chain
Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 2122
Script:
Length of output: 62