fix: person attributes typing

This commit is contained in:
Quentame 2024-04-24 12:26:26 +00:00 committed by GitHub
parent 8d271ab8b0
commit 5bfedb7078
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 21 additions and 8 deletions

View File

@ -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",

View File

@ -14,7 +14,7 @@ const ENTITIES = [
}),
getEntity("person", "paulus", "home", {
friendly_name: "Paulus",
picture: "/images/paulus.jpg",
entity_picture: "/images/paulus.jpg",
}),
];

View File

@ -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",

View File

@ -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 {
@ -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) =>

View File

@ -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}

View File

@ -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}

View File

@ -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}