Skip to content

Commit

Permalink
fix: person attributes typing
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentame committed May 31, 2024
1 parent 990b2f6 commit 73193a2
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gallery/src/pages/lovelace/picture-elements-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ENTITIES = [
}),
getEntity("person", "paulus", "home", {
friendly_name: "Paulus",
picture: "/images/paulus.jpg",
entity_picture: "/images/paulus.jpg",
}),
getEntity("sensor", "battery", 35, {
device_class: "battery",
Expand Down
2 changes: 1 addition & 1 deletion gallery/src/pages/lovelace/picture-entity-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ENTITIES = [
}),
getEntity("person", "paulus", "home", {
friendly_name: "Paulus",
picture: "/images/paulus.jpg",
entity_picture: "/images/paulus.jpg",
}),
];

Expand Down
2 changes: 1 addition & 1 deletion gallery/src/pages/lovelace/picture-glance-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ENTITIES = [
}),
getEntity("person", "paulus", "home", {
friendly_name: "Paulus",
picture: "/images/paulus.jpg",
entity_picture: "/images/paulus.jpg",
}),
getEntity("sensor", "battery", 35, {
device_class: "battery",
Expand Down
17 changes: 15 additions & 2 deletions src/data/person.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { HassEntityBase } from "home-assistant-js-websocket";
import {
HassEntityAttributeBase,
HassEntityBase,
} from "home-assistant-js-websocket";
import { HomeAssistant } from "../types";

export interface BasePerson {
Expand All @@ -19,8 +22,18 @@ export interface PersonMutableParams {
picture: string | null;
}

interface PersonEntityAttributes extends HassEntityAttributeBase {
id: string;
user_id?: string;
device_trackers?: string[];
editable?: boolean;
gps_accuracy?: number;
latitude?: number;
longitude?: number;
}

export interface PersonEntity extends HassEntityBase {
attributes: Person;
attributes: PersonEntityAttributes;
}

export const fetchPersons = (hass: HomeAssistant) =>
Expand Down
2 changes: 1 addition & 1 deletion src/panels/lovelace/cards/hui-picture-elements-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class HuiPictureElementsCard extends LitElement implements LovelaceCard {
.image=${domain === "image"
? computeImageUrl(stateObj as ImageEntity)
: domain === "person"
? (stateObj as PersonEntity).attributes.picture
? (stateObj as PersonEntity).attributes.entity_picture
: this._config.image}
.stateImage=${this._config.state_image}
.stateFilter=${this._config.state_filter}
Expand Down
2 changes: 1 addition & 1 deletion src/panels/lovelace/cards/hui-picture-entity-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class HuiPictureEntityCard extends LitElement implements LovelaceCard {
.image=${domain === "image"
? computeImageUrl(stateObj as ImageEntity)
: domain === "person"
? (stateObj as PersonEntity).attributes.picture
? (stateObj as PersonEntity).attributes.entity_picture
: this._config.image}
.stateImage=${this._config.state_image}
.stateFilter=${this._config.state_filter}
Expand Down
2 changes: 1 addition & 1 deletion src/panels/lovelace/cards/hui-picture-glance-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
.image=${domain === "image"
? computeImageUrl(stateObj as ImageEntity)
: domain === "person"
? (stateObj as PersonEntity).attributes.picture
? (stateObj as PersonEntity).attributes.entity_picture
: this._config.image}
.stateImage=${this._config.state_image}
.stateFilter=${this._config.state_filter}
Expand Down

0 comments on commit 73193a2

Please sign in to comment.