mirror of
https://github.com/home-assistant/frontend.git
synced 2026-12-04 10:40:30 +00:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42504f3908 | ||
|
|
ee8ae2a2ef | ||
|
|
5b73d7bb50 | ||
|
|
194356846b | ||
|
|
0f2148445b | ||
|
|
0a637a0d52 | ||
|
|
c09bfad8c2 | ||
|
|
d9f115b5c6 | ||
|
|
081506950c | ||
|
|
b1cc32d50e |
No files matched your search
@@ -62,7 +62,7 @@ Use entity-scoped helpers when the component watches an entity ID held on the ho
|
||||
|
||||
```ts
|
||||
@state() @consumeEntityState({ entityIdPath: ["_config", "entity"] })
|
||||
private _stateObj?: HassEntity;
|
||||
private _stateObj?: HassEntityState;
|
||||
|
||||
@state() @consumeEntityRegistryEntry({ entityIdPath: ["_config", "entity"] })
|
||||
private _entity?: EntityRegistryDisplayEntry;
|
||||
@@ -75,7 +75,7 @@ Use `consumeEntityStates` when the host property contains one or more entity IDs
|
||||
|
||||
```ts
|
||||
@state() @consumeEntityStates({ entityIdPath: ["_config", "entities"] })
|
||||
private _stateObjs?: Record<string, HassEntity>;
|
||||
private _stateObjs?: Record<string, HassEntityState>;
|
||||
```
|
||||
|
||||
For a single field from a grouped context, pair `@consume` with `@transform`:
|
||||
|
||||
@@ -20,8 +20,9 @@ runs:
|
||||
steps:
|
||||
- name: Build ${{ inputs.target }}
|
||||
shell: bash
|
||||
run: ./node_modules/.bin/gulp ${{ inputs.target }}
|
||||
run: ./node_modules/.bin/gulp "$TARGET"
|
||||
env:
|
||||
TARGET: ${{ inputs.target }}
|
||||
GITHUB_TOKEN: ${{ inputs.github-token }}
|
||||
IS_TEST: ${{ inputs.is-test }}
|
||||
RSPACK_CACHE: ${{ inputs.rspack-cache }}
|
||||
@@ -40,3 +40,22 @@ jobs:
|
||||
curl -sSfL "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" \
|
||||
| tar -xz actionlint
|
||||
./actionlint -color
|
||||
|
||||
zizmor:
|
||||
name: Check workflow security
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
# renovate: datasource=github-releases depName=zizmorcore/zizmor
|
||||
ZIZMOR_VERSION: 1.33.1
|
||||
steps:
|
||||
- name: Check out files from GitHub
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Run zizmor
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
curl -sSfL "https://github.com/zizmorcore/zizmor/releases/download/v${ZIZMOR_VERSION}/zizmor-x86_64-unknown-linux-gnu.tar.gz" \
|
||||
| tar -xz zizmor
|
||||
./zizmor --format=github .
|
||||
@@ -47,4 +47,6 @@ jobs:
|
||||
site-id: ${{ secrets.NETLIFY_GALLERY_SITE_ID }}
|
||||
|
||||
- name: Generate summary
|
||||
run: echo "${{ steps.deploy.outputs.netlify_url }}" >> "$GITHUB_STEP_SUMMARY"
|
||||
env:
|
||||
NETLIFY_URL: ${{ steps.deploy.outputs.netlify_url }}
|
||||
run: echo "$NETLIFY_URL" >> "$GITHUB_STEP_SUMMARY"
|
||||
@@ -2,6 +2,8 @@ name: "Pull Request Labeler"
|
||||
|
||||
on: pull_request_target # zizmor: ignore[dangerous-triggers] -- safe: checks out base repo scripts only and reads PR files through the API, never PR head code
|
||||
|
||||
permissions: {}
|
||||
|
||||
# Runs one at a time per pull request, so an older run can't undo a newer one
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
@@ -13,6 +15,7 @@ jobs:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Apply labels
|
||||
id: labeler
|
||||
|
||||
@@ -20,6 +20,7 @@ jobs:
|
||||
check:
|
||||
name: Check pull request follows contribution standards
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
pull-requests: write # To label and comment on pull requests
|
||||
steps:
|
||||
|
||||
@@ -28,18 +28,10 @@ AI can be a helpful tool for writing code and documentation. However, due to the
|
||||
|
||||
All contributions must be reviewed and understood by the contributor before submission. You should be able to explain every change in a pull request you submit. Pull requests that appear to be unreviewed AI output will be closed without review.
|
||||
|
||||
## Design contributions
|
||||
|
||||
AI can be a helpful tool to explore ideas and build mockups and prototypes. But AI tends to give the most common answer, not the one that fits Home Assistant and its users. So we require a human who brings the point of view and owns the design decisions.
|
||||
|
||||
You should be able to explain the problem your design solves and why you made your choices. If a mockup or prototype was mostly generated with AI, say so when you share it. Check your work against the [design guidelines](https://contributors.home-assistant.io/design/), as AI tools often make up components, colors, or spacing that don't exist in Home Assistant. Design proposals that look like unreviewed AI output may be closed or hidden.
|
||||
|
||||
## Our use of AI
|
||||
|
||||
Some of our projects use AI tools to assist with code reviews, issue triaging, reporting, and other project management tasks. These tools may leave comments on pull requests or issues. As with any automated tooling, these comments are not always correct.
|
||||
|
||||
We also use AI to help keep the design system, the Figma kit, and the code in sync. The design decisions behind them are made by people.
|
||||
|
||||
If an AI tool leaves a comment on your contribution, treat it as you would any other review comment. If you believe it is incorrect, say so; a brief explanation is sufficient. Maintainers always have the final say. If in doubt, ask a maintainer.
|
||||
|
||||
## Enforcement
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ContextProvider, provide } from "@lit/context";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
@@ -317,6 +317,6 @@ declare global {
|
||||
"ha-embed-provider": HaEmbedProvider;
|
||||
}
|
||||
interface HASSDomEvents {
|
||||
"states-changed": { states: HassEntities };
|
||||
"states-changed": { states: HassEntityStates };
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HistoryStates } from "../../../src/data/history";
|
||||
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
import { driftedValue, hashFraction } from "./drift";
|
||||
|
||||
const generateStateHistory = (
|
||||
state: HassEntity,
|
||||
state: HassEntityState,
|
||||
deltas,
|
||||
start_date: Date,
|
||||
end_date: Date
|
||||
@@ -50,7 +50,7 @@ const NUMBER_POINTS = 96;
|
||||
// An on/off entity, such as a light, switches a few times over the range, at
|
||||
// times picked from its entity ID, and ends in its state
|
||||
const generateOnOffHistory = (
|
||||
state: HassEntity,
|
||||
state: HassEntityState,
|
||||
start: Date,
|
||||
end: Date
|
||||
): HistoryStates[string] => {
|
||||
@@ -78,7 +78,7 @@ const generateOnOffHistory = (
|
||||
// A number drifts around its state over the range, the same on every load,
|
||||
// with as many decimals as its state, and ends in its state
|
||||
const generateNumberHistory = (
|
||||
state: HassEntity,
|
||||
state: HassEntityState,
|
||||
value: number,
|
||||
start: Date,
|
||||
end: Date
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
startOfWeek,
|
||||
startOfYear,
|
||||
} from "date-fns";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HaDurationData } from "../../../src/components/ha-duration-input";
|
||||
import type {
|
||||
Statistic,
|
||||
@@ -416,14 +416,14 @@ const derivedBatteryFlows: Record<string, { source: string; share: number }> = {
|
||||
},
|
||||
};
|
||||
|
||||
const hasSum = (stateObj: HassEntity | undefined): boolean =>
|
||||
const hasSum = (stateObj: HassEntityState | undefined): boolean =>
|
||||
stateObj?.attributes.state_class === "total" ||
|
||||
stateObj?.attributes.state_class === "total_increasing";
|
||||
|
||||
// Like Core, statistics are given in the unit asked for, such as power in kW
|
||||
// for the energy dashboard while the demo's power sensors are in W
|
||||
const unitFactor = (
|
||||
stateObj: HassEntity | undefined,
|
||||
stateObj: HassEntityState | undefined,
|
||||
units?: StatisticsUnitConfiguration
|
||||
): number => {
|
||||
const unit = stateObj?.attributes.unit_of_measurement;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {
|
||||
HassEntity,
|
||||
HassEntityAttributeBase,
|
||||
HassEntityState,
|
||||
HassEntityStateAttributeBase,
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
@@ -94,7 +94,7 @@ const BINARY_SENSOR_DEVICE_CLASSES = [
|
||||
"window",
|
||||
];
|
||||
|
||||
const ENTITIES: HassEntity[] = [
|
||||
const ENTITIES: HassEntityState[] = [
|
||||
// Alarm control panel
|
||||
createEntity("alarm_control_panel.disarmed", "disarmed"),
|
||||
createEntity("alarm_control_panel.armed_home", "armed_home"),
|
||||
@@ -305,8 +305,8 @@ function createEntity(
|
||||
entity_id: string,
|
||||
state: string,
|
||||
device_class?: string,
|
||||
attributes?: HassEntityAttributeBase | HassEntity["attributes"]
|
||||
): HassEntity {
|
||||
attributes?: HassEntityStateAttributeBase | HassEntityState["attributes"]
|
||||
): HassEntityState {
|
||||
return {
|
||||
entity_id,
|
||||
state,
|
||||
@@ -325,14 +325,14 @@ function createEntity(
|
||||
}
|
||||
|
||||
interface EntityRowData {
|
||||
stateObj: HassEntity;
|
||||
stateObj: HassEntityState;
|
||||
entity_id: string;
|
||||
state: string;
|
||||
device_class?: string;
|
||||
domain: string;
|
||||
}
|
||||
|
||||
function createRowData(stateObj: HassEntity): EntityRowData {
|
||||
function createRowData(stateObj: HassEntityState): EntityRowData {
|
||||
return {
|
||||
stateObj,
|
||||
entity_id: stateObj.entity_id,
|
||||
|
||||
+2
-2
@@ -109,7 +109,7 @@
|
||||
"lit": "3.3.3",
|
||||
"lit-html": "3.3.3",
|
||||
"maplibre-gl": "6.20.0",
|
||||
"marked": "18.3.0",
|
||||
"marked": "18.4.0",
|
||||
"marked-footnote": "1.4.0",
|
||||
"marked-gfm-heading-id": "4.1.4",
|
||||
"memoize-one": "7.0.0",
|
||||
@@ -212,7 +212,7 @@
|
||||
"rspack-manifest-plugin": "5.2.2",
|
||||
"serve": "14.2.8",
|
||||
"sinon": "22.1.0",
|
||||
"tar": "8.0.3",
|
||||
"tar": "8.0.4",
|
||||
"terser-webpack-plugin": "5.6.1",
|
||||
"ts-lit-plugin": "2.0.2",
|
||||
"typescript": "6.0.3",
|
||||
|
||||
Generated
+16
-16
@@ -407,14 +407,14 @@ importers:
|
||||
specifier: 6.20.0
|
||||
version: 6.20.0
|
||||
marked:
|
||||
specifier: 18.3.0
|
||||
version: 18.3.0
|
||||
specifier: 18.4.0
|
||||
version: 18.4.0
|
||||
marked-footnote:
|
||||
specifier: 1.4.0
|
||||
version: 1.4.0(marked@18.3.0)
|
||||
version: 1.4.0(marked@18.4.0)
|
||||
marked-gfm-heading-id:
|
||||
specifier: 4.1.4
|
||||
version: 4.1.4(marked@18.3.0)
|
||||
version: 4.1.4(marked@18.4.0)
|
||||
memoize-one:
|
||||
specifier: 7.0.0
|
||||
version: 7.0.0
|
||||
@@ -711,8 +711,8 @@ importers:
|
||||
specifier: 22.1.0
|
||||
version: 22.1.0
|
||||
tar:
|
||||
specifier: 8.0.3
|
||||
version: 8.0.3
|
||||
specifier: 8.0.4
|
||||
version: 8.0.4
|
||||
terser-webpack-plugin:
|
||||
specifier: 5.6.1
|
||||
version: 5.6.1([email protected])([email protected])([email protected])([email protected])([email protected])
|
||||
@@ -6575,8 +6575,8 @@ packages:
|
||||
engines: {node: '>= 20'}
|
||||
hasBin: true
|
||||
|
||||
marked@18.3.0:
|
||||
resolution: {integrity: sha512-ed8zmPXlBb3UfGXN5iHMQyMhFpdqLgoV5umUXx/Q1R+FW3q8VpqpyoKUwlENL9appo2UMvNLURDVaT3AMOryGA==}
|
||||
marked@18.4.0:
|
||||
resolution: {integrity: sha512-evbvoaiBPFO2lk2kSkIbrwjPMuX/HjKyefPdZbtwccsJWY91xlLF/SzB5hRsAOwStztmKC09i+IGsUcTYMt//A==}
|
||||
engines: {node: '>= 20'}
|
||||
hasBin: true
|
||||
|
||||
@@ -7801,8 +7801,8 @@ packages:
|
||||
resolution: {integrity: sha512-to/OxuCk5DeVONcjjODT7aeoRq5NIPPlfPc0tNML+wLlnf6u5BcJz97Uukv3pT3jzorkFhUevylkAiBr+ZmV2w==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
[email protected].3:
|
||||
resolution: {integrity: sha512-S+Gnl5H2+dD5DF7h4e6BOftgFcCqPv3rDRXCvhPLPeX7o2hnQ/aCax5bjdzRBb886xvBGR1vs+wHComyXbnRhQ==}
|
||||
[email protected].4:
|
||||
resolution: {integrity: sha512-efl2GHJOnqAV5jVrxbM8T3KrLyCAdcwtqF7tJOEJAe1S8rUJSkGrPu6nSZLJP6/KE7U2hDpMcktnKLx3iPwcZQ==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
[email protected]:
|
||||
@@ -15020,20 +15020,20 @@ snapshots:
|
||||
- react
|
||||
- use-sync-external-store
|
||||
|
||||
[email protected](marked@18.3.0):
|
||||
[email protected](marked@18.4.0):
|
||||
dependencies:
|
||||
marked: 18.3.0
|
||||
marked: 18.4.0
|
||||
|
||||
[email protected](marked@18.3.0):
|
||||
[email protected](marked@18.4.0):
|
||||
dependencies:
|
||||
github-slugger: 2.0.0
|
||||
marked: 18.3.0
|
||||
marked: 18.4.0
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
marked@18.3.0: {}
|
||||
marked@18.4.0: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
@@ -16458,7 +16458,7 @@ snapshots:
|
||||
minizlib: 3.1.0
|
||||
yallist: 5.0.0
|
||||
|
||||
[email protected].3: {}
|
||||
[email protected].4: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
|
||||
@@ -62,6 +62,15 @@
|
||||
"datasourceTemplate": "github-releases",
|
||||
"extractVersionTemplate": "^v(?<version>.+)$"
|
||||
},
|
||||
{
|
||||
"description": "Keep zizmor used in CI up to date",
|
||||
"customType": "regex",
|
||||
"managerFilePatterns": ["/^\\.github/workflows/actionlint\\.yaml$/"],
|
||||
"matchStrings": ["ZIZMOR_VERSION: (?<currentValue>\\S+)"],
|
||||
"depNameTemplate": "zizmorcore/zizmor",
|
||||
"datasourceTemplate": "github-releases",
|
||||
"extractVersionTemplate": "^v(?<version>.+)$"
|
||||
},
|
||||
{
|
||||
"description": "Keep gh-actions-lock in CI and Renovate's lockfile generator on the same version",
|
||||
"customType": "regex",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ReactiveControllerHost } from "@lit/reactive-element/reactive-controller";
|
||||
import type {
|
||||
Connection,
|
||||
HassEntities,
|
||||
HassEntityStates,
|
||||
UnsubscribeFunc,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { subscribeCondition } from "../../data/automation";
|
||||
@@ -393,7 +393,7 @@ export class ConditionEvaluator {
|
||||
*/
|
||||
export class ConditionEvaluatorController extends ContextController {
|
||||
@consumeContext({ context: statesContext, subscribe: true })
|
||||
private _states?: HassEntities | null;
|
||||
private _states?: HassEntityStates | null;
|
||||
|
||||
@consumeContext({ context: configContext, subscribe: true })
|
||||
private _hassConfig?: HomeAssistantConfig | null;
|
||||
|
||||
@@ -2,7 +2,7 @@ import type {
|
||||
ReactiveController,
|
||||
ReactiveControllerHost,
|
||||
} from "@lit/reactive-element/reactive-controller";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { timerTimeRemaining } from "../../data/timer";
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ export class TimerRemainingTimeController implements ReactiveController {
|
||||
|
||||
private _host: ReactiveControllerHost;
|
||||
|
||||
private _stateObj?: HassEntity;
|
||||
private _stateObj?: HassEntityState;
|
||||
|
||||
private _interval?: number;
|
||||
|
||||
@@ -26,7 +26,7 @@ export class TimerRemainingTimeController implements ReactiveController {
|
||||
host.addController(this);
|
||||
}
|
||||
|
||||
public setStateObj(stateObj: HassEntity | undefined): void {
|
||||
public setStateObj(stateObj: HassEntityState | undefined): void {
|
||||
this._stateObj = stateObj;
|
||||
this._startInterval();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import type { Context } from "@lit/context";
|
||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
} from "home-assistant-js-websocket";
|
||||
import type {
|
||||
HomeAssistant,
|
||||
HomeAssistantInternationalization,
|
||||
@@ -28,9 +31,9 @@ const resolveAtPath = (host: unknown, path: readonly string[]) => {
|
||||
return cur;
|
||||
};
|
||||
|
||||
/** Reuse `previous` when every entry still references the same `HassEntity`. */
|
||||
/** Reuse `previous` when every entry still references the same `HassEntityState`. */
|
||||
export const preserveUnchangedEntityStatesRecord = <
|
||||
T extends Record<string, HassEntity | undefined>,
|
||||
T extends Record<string, HassEntityState | undefined>,
|
||||
>(
|
||||
previous: T | undefined,
|
||||
next: T
|
||||
@@ -80,7 +83,7 @@ const composeDecorator = <T, V>(
|
||||
};
|
||||
|
||||
/**
|
||||
* Consumes `statesContext` and narrows it to the `HassEntity` for the entity
|
||||
* Consumes `statesContext` and narrows it to the `HassEntityState` for the entity
|
||||
* ID found at `entityIdPath` on the host (e.g. `["_config", "entity"]`).
|
||||
*
|
||||
* The first path segment is watched on the host — changes to it re-run the
|
||||
@@ -88,7 +91,7 @@ const composeDecorator = <T, V>(
|
||||
* nullish values.
|
||||
*/
|
||||
export const consumeEntityState = (config: ConsumeEntryConfig) =>
|
||||
composeDecorator<HassEntities, HassEntity>(
|
||||
composeDecorator<HassEntityStates, HassEntityState>(
|
||||
statesContext,
|
||||
config.entityIdPath[0],
|
||||
function (states) {
|
||||
@@ -106,10 +109,10 @@ export const consumeEntityState = (config: ConsumeEntryConfig) =>
|
||||
*/
|
||||
export const consumeEntityStates = (config: ConsumeEntryConfig) => {
|
||||
const watchKey = config.entityIdPath[0];
|
||||
const buildRecord = function (this: unknown, states: HassEntities) {
|
||||
const buildRecord = function (this: unknown, states: HassEntityStates) {
|
||||
const ids = ensureArray(resolveAtPath(this, config.entityIdPath));
|
||||
if (!ids || !states) return undefined;
|
||||
const result: Record<string, HassEntity> = {};
|
||||
const result: Record<string, HassEntityState> = {};
|
||||
for (const id of ids) {
|
||||
if (typeof id !== "string") continue;
|
||||
const state = states[id];
|
||||
@@ -121,22 +124,22 @@ export const consumeEntityStates = (config: ConsumeEntryConfig) => {
|
||||
return (proto: unknown, propertyKey: string) => {
|
||||
const key = String(propertyKey);
|
||||
const transformDec = transform<
|
||||
HassEntities,
|
||||
Record<string, HassEntity> | undefined
|
||||
HassEntityStates,
|
||||
Record<string, HassEntityState> | undefined
|
||||
>({
|
||||
transformer: function (this: unknown, states: HassEntities) {
|
||||
transformer: function (this: unknown, states: HassEntityStates) {
|
||||
const next = buildRecord.call(this, states);
|
||||
if (next === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const previous = (this as Record<string, unknown>)[
|
||||
`__transform_${key}`
|
||||
] as Record<string, HassEntity> | undefined;
|
||||
] as Record<string, HassEntityState> | undefined;
|
||||
return preserveUnchangedEntityStatesRecord(previous, next);
|
||||
},
|
||||
watch: watchKey ? [watchKey] : [],
|
||||
});
|
||||
const consumeDec = subscribeContext<HassEntities>(statesContext);
|
||||
const consumeDec = subscribeContext<HassEntityStates>(statesContext);
|
||||
transformDec(proto as never, propertyKey);
|
||||
consumeDec(proto as never, propertyKey);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { getShadowRootHost } from "./get-shadow-root-host";
|
||||
|
||||
/** The element and its ancestors, crossing shadow root boundaries. */
|
||||
export const composedAncestors = (element: Element | null): Element[] => {
|
||||
const ancestors: Element[] = [];
|
||||
let current = element;
|
||||
while (current) {
|
||||
ancestors.push(current);
|
||||
current = current.parentElement ?? getShadowRootHost(current);
|
||||
}
|
||||
return ancestors;
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { computeCssColor } from "../color/compute-color";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
import { stateColorCss } from "./state_color";
|
||||
@@ -23,11 +23,11 @@ export const computeAlertActiveStates = (entityId: string): string[] => {
|
||||
}
|
||||
};
|
||||
|
||||
export const isAlertActive = (stateObj: HassEntity): boolean =>
|
||||
export const isAlertActive = (stateObj: HassEntityState): boolean =>
|
||||
computeAlertActiveStates(stateObj.entity_id).includes(stateObj.state);
|
||||
|
||||
export const computeAlertColor = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
color: string
|
||||
): string | undefined => {
|
||||
if (color === "none") {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
|
||||
export const attributeClassNames = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
attributes: string[]
|
||||
): string => {
|
||||
if (!stateObj) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
mdiBatteryAlertVariantOutline,
|
||||
mdiBatteryUnknown,
|
||||
} from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
|
||||
const BATTERY_ICONS = {
|
||||
10: "mdi:battery-10",
|
||||
@@ -51,7 +51,7 @@ const BATTERY_CHARGING_ICONS = {
|
||||
100: "mdi:battery-charging",
|
||||
};
|
||||
|
||||
export const batteryIcon = (stateObj: HassEntity, state?: string) => {
|
||||
export const batteryIcon = (stateObj: HassEntityState, state?: string) => {
|
||||
const level = state ?? stateObj.state;
|
||||
return batteryLevelIcon(level);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {
|
||||
HassEntities,
|
||||
HassEntity,
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
HassServices,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { canToggleDomain } from "./can_toggle_domain";
|
||||
@@ -9,9 +9,9 @@ import { supportsFeature } from "./supports-feature";
|
||||
import { SPECIAL_TOGGLE_ACTIONS } from "./get_toggle_action";
|
||||
|
||||
export const canToggleState = (
|
||||
states: HassEntities,
|
||||
states: HassEntityStates,
|
||||
services: HassServices,
|
||||
stateObj: HassEntity
|
||||
stateObj: HassEntityState
|
||||
) => {
|
||||
const domain = computeStateDomain(stateObj);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassConfig, HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassConfig, HassEntityState } from "home-assistant-js-websocket";
|
||||
import {
|
||||
DOMAIN_ATTRIBUTES_FORMATERS,
|
||||
DOMAIN_ATTRIBUTES_UNITS,
|
||||
@@ -25,7 +25,7 @@ import { computeStateDomain } from "./compute_state_domain";
|
||||
|
||||
export const computeAttributeValueDisplay = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
locale: FrontendLocaleData,
|
||||
config: HassConfig,
|
||||
entities: HomeAssistant["entities"],
|
||||
@@ -47,7 +47,7 @@ export const computeAttributeValueDisplay = (
|
||||
|
||||
export const computeAttributeValueToParts = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
locale: FrontendLocaleData,
|
||||
config: HassConfig,
|
||||
entities: HomeAssistant["entities"],
|
||||
@@ -205,7 +205,7 @@ export const computeAttributeValueToParts = (
|
||||
// effects of a light group, so use the translation of a member.
|
||||
const computeMemberAttributeValueDisplay = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
entities: HomeAssistant["entities"],
|
||||
attribute: string,
|
||||
attributeValue: string
|
||||
@@ -224,7 +224,7 @@ const computeMemberAttributeValueDisplay = (
|
||||
|
||||
export const computeAttributeNameDisplay = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
entities: HomeAssistant["entities"],
|
||||
attribute: string
|
||||
): string => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type {
|
||||
EntityRegistryDisplayEntry,
|
||||
EntityRegistryEntry,
|
||||
@@ -56,7 +56,7 @@ const computeTextOnlyName = (
|
||||
* while the real formatter is still loading.
|
||||
*/
|
||||
export const computeEntityNameDisplayWithoutContext = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
name?: string | EntityNameItem | EntityNameItem[],
|
||||
options?: EntityNameOptions
|
||||
): string => {
|
||||
@@ -125,7 +125,7 @@ export const computeEntityEntryNameParts = (
|
||||
};
|
||||
|
||||
export const computeEntityNameParts = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
registries: HomeAssistantRegistries,
|
||||
options?: EntityNamePartsOptions
|
||||
): EntityNameParts => {
|
||||
@@ -139,7 +139,7 @@ export const computeEntityNameParts = (
|
||||
};
|
||||
|
||||
export const computeDefaultEntityNameItems = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
registries: HomeAssistantRegistries
|
||||
): EntityNameItem[] => {
|
||||
const parts = computeEntityNameParts(stateObj, registries);
|
||||
@@ -147,7 +147,7 @@ export const computeDefaultEntityNameItems = (
|
||||
};
|
||||
|
||||
export const computeEntityNameDisplay = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
name: string | EntityNameItem | EntityNameItem[] | undefined,
|
||||
registries: HomeAssistantRegistries,
|
||||
options?: EntityNameOptions
|
||||
@@ -194,7 +194,7 @@ export const computeEntityNameDisplay = (
|
||||
};
|
||||
|
||||
export const computeEntitySearchLabels = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
registries: HomeAssistantRegistries
|
||||
) => {
|
||||
const parts = computeEntityNameParts(stateObj, registries, {
|
||||
@@ -221,7 +221,7 @@ export interface EntityPickerDisplayOptions extends HomeAssistantRegistries {
|
||||
|
||||
export const computeEntityPickerDisplay = (
|
||||
options: EntityPickerDisplayOptions,
|
||||
stateObj: HassEntity
|
||||
stateObj: HassEntityState
|
||||
): EntityPickerDisplay => {
|
||||
const parts = computeEntityNameParts(stateObj, options);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { UNAVAILABLE, UNKNOWN } from "../../data/entity/entity";
|
||||
import type { HomeAssistantFormatters } from "../../types";
|
||||
import { unitFromParts } from "./value_parts";
|
||||
@@ -19,7 +19,7 @@ interface EntityUnitStubConfig {
|
||||
*/
|
||||
export const computeEntityUnitDisplay = (
|
||||
formatters: HomeAssistantFormatters,
|
||||
stateObj: HassEntity | undefined,
|
||||
stateObj: HassEntityState | undefined,
|
||||
config: EntityUnitStubConfig
|
||||
): string => {
|
||||
if (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { parseISO } from "date-fns";
|
||||
import type { HassConfig, HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassConfig, HassEntityState } from "home-assistant-js-websocket";
|
||||
import { UNAVAILABLE, UNKNOWN } from "../../data/entity/entity";
|
||||
import type { EntityRegistryDisplayEntry } from "../../data/entity/entity_registry";
|
||||
import type { FrontendLocaleData } from "../../data/translation";
|
||||
@@ -44,7 +44,7 @@ const NUMERICAL_DOMAINS = ["counter", "input_number", "number"];
|
||||
|
||||
export const computeStateDisplay = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
locale: FrontendLocaleData,
|
||||
config: HassConfig,
|
||||
entities: HomeAssistant["entities"],
|
||||
@@ -146,7 +146,7 @@ const computeStateToPartsFromEntityAttributes = (
|
||||
minimumFractionDigits: 2,
|
||||
// Override monetary options with number format
|
||||
...getNumberFormatOptions(
|
||||
{ state, attributes } as HassEntity,
|
||||
{ state, attributes } as HassEntityState,
|
||||
entity
|
||||
),
|
||||
});
|
||||
@@ -177,7 +177,7 @@ const computeStateToPartsFromEntityAttributes = (
|
||||
const value = formatNumber(
|
||||
state,
|
||||
locale,
|
||||
getNumberFormatOptions({ state, attributes } as HassEntity, entity)
|
||||
getNumberFormatOptions({ state, attributes } as HassEntityState, entity)
|
||||
);
|
||||
|
||||
const unit =
|
||||
@@ -298,7 +298,7 @@ const computeStateToPartsFromEntityAttributes = (
|
||||
|
||||
export const computeStateToParts = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
locale: FrontendLocaleData,
|
||||
config: HassConfig,
|
||||
entities: HomeAssistant["entities"],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
|
||||
export const computeStateDomain = (stateObj: HassEntity) =>
|
||||
export const computeStateDomain = (stateObj: HassEntityState) =>
|
||||
computeDomain(stateObj.entity_id);
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { computeObjectId } from "./compute_object_id";
|
||||
|
||||
export const computeStateNameFromEntityAttributes = (
|
||||
@@ -9,5 +9,5 @@ export const computeStateNameFromEntityAttributes = (
|
||||
? computeObjectId(entityId).replace(/_/g, " ")
|
||||
: (attributes.friendly_name ?? "").toString();
|
||||
|
||||
export const computeStateName = (stateObj: HassEntity): string =>
|
||||
export const computeStateName = (stateObj: HassEntityState): string =>
|
||||
computeStateNameFromEntityAttributes(stateObj.entity_id, stateObj.attributes);
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { AreaRegistryEntry } from "../../../data/area/area_registry";
|
||||
import type { DeviceRegistryEntry } from "../../../data/device/device_registry";
|
||||
import type {
|
||||
@@ -19,7 +19,7 @@ interface EntityContext {
|
||||
}
|
||||
|
||||
export const getEntityContext = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
entities: HomeAssistant["entities"],
|
||||
devices: HomeAssistant["devices"],
|
||||
areas: HomeAssistant["areas"],
|
||||
|
||||
@@ -9,9 +9,9 @@ import {
|
||||
mdiGate,
|
||||
mdiGateOpen,
|
||||
} from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
|
||||
export const computeOpenIcon = (stateObj: HassEntity): string => {
|
||||
export const computeOpenIcon = (stateObj: HassEntityState): string => {
|
||||
switch (stateObj.attributes.device_class) {
|
||||
case "door":
|
||||
return mdiDoorOpen;
|
||||
@@ -26,7 +26,7 @@ export const computeOpenIcon = (stateObj: HassEntity): string => {
|
||||
}
|
||||
};
|
||||
|
||||
export const computeCloseIcon = (stateObj: HassEntity): string => {
|
||||
export const computeCloseIcon = (stateObj: HassEntityState): string => {
|
||||
switch (stateObj.attributes.device_class) {
|
||||
case "door":
|
||||
return mdiDoorClosed;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
|
||||
export const deviceTrackerIcon = (stateObj: HassEntity, state?: string) => {
|
||||
export const deviceTrackerIcon = (
|
||||
stateObj: HassEntityState,
|
||||
state?: string
|
||||
) => {
|
||||
const compareState = state ?? stateObj.state;
|
||||
if (stateObj?.attributes.source_type === "router") {
|
||||
return compareState === "home" ? "mdi:lan-connect" : "mdi:lan-disconnect";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import memoizeOne from "memoize-one";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import { ensureArray } from "../array/ensure-array";
|
||||
@@ -68,7 +68,7 @@ export const generateEntityFilter = (
|
||||
: undefined;
|
||||
|
||||
return (entityId: string) => {
|
||||
const stateObj = states[entityId] as HassEntity | undefined;
|
||||
const stateObj = states[entityId] as HassEntityState | undefined;
|
||||
if (!stateObj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { GroupEntity } from "../../data/group";
|
||||
import { DEFAULT_VIEW_ENTITY_ID } from "../const";
|
||||
|
||||
// Return an ordered array of available views
|
||||
export const extractViews = (entities: HassEntities): GroupEntity[] => {
|
||||
export const extractViews = (entities: HassEntityStates): GroupEntity[] => {
|
||||
const views: GroupEntity[] = [];
|
||||
|
||||
Object.keys(entities).forEach((entityId) => {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
|
||||
export interface EntityLocation {
|
||||
@@ -9,8 +12,8 @@ export interface EntityLocation {
|
||||
|
||||
export const findFirstActiveZone = (
|
||||
inZones: readonly string[],
|
||||
states: HassEntities
|
||||
): HassEntity | undefined => {
|
||||
states: HassEntityStates
|
||||
): HassEntityState | undefined => {
|
||||
for (const zoneId of inZones) {
|
||||
const zone = states[zoneId];
|
||||
if (
|
||||
@@ -26,8 +29,8 @@ export const findFirstActiveZone = (
|
||||
};
|
||||
|
||||
export const getEntityLocation = (
|
||||
stateObj: HassEntity,
|
||||
states: HassEntities
|
||||
stateObj: HassEntityState,
|
||||
states: HassEntityStates
|
||||
): EntityLocation | undefined => {
|
||||
const {
|
||||
latitude,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { GroupEntity } from "../../data/group";
|
||||
|
||||
export const getGroupEntities = (
|
||||
entities: HassEntities,
|
||||
entities: HassEntityStates,
|
||||
group: GroupEntity
|
||||
) => {
|
||||
const result = {};
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { HVAC_MODES } from "../../data/climate";
|
||||
import { UNAVAILABLE, UNKNOWN } from "../../data/entity/entity";
|
||||
import { OPERATION_MODES } from "../../data/water_heater";
|
||||
@@ -249,7 +252,7 @@ const FIXED_DOMAIN_ATTRIBUTE_STATES = {
|
||||
};
|
||||
|
||||
export const getStatesDomain = (
|
||||
states: HassEntities,
|
||||
states: HassEntityStates,
|
||||
language: string,
|
||||
domain: string,
|
||||
attribute?: string | undefined
|
||||
@@ -408,9 +411,9 @@ export const getValueAttribute = (
|
||||
): string | undefined => DOMAIN_VALUE_ATTRIBUTES[domain]?.[optionsAttribute];
|
||||
|
||||
export const getStates = (
|
||||
states: HassEntities,
|
||||
states: HassEntityStates,
|
||||
language: string,
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
attribute: string | undefined = undefined
|
||||
): string[] => {
|
||||
const domain = computeStateDomain(stateObj);
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ClimateEntityFeature } from "../../data/feature/climate_entity_feature"
|
||||
import { CoverEntityFeature } from "../../data/feature/cover_entity_feature";
|
||||
import { MediaPlayerEntityFeature } from "../../data/feature/media-player_entity_feature";
|
||||
import { SirenEntityFeature } from "../../data/feature/siren_entity_feature";
|
||||
import { ValveEntityFeature } from "../../data/feature/valve_entity_feature";
|
||||
|
||||
// These are domains which have nonstandard 'toggle' behavior.
|
||||
// Otherwise, any domain with a turn_on and turn_off service may be toggled.
|
||||
@@ -58,6 +59,7 @@ export const SPECIAL_TOGGLE_ACTIONS: Record<string, SpecialToggleAction> = {
|
||||
valve: {
|
||||
on: "open_valve",
|
||||
off: "close_valve",
|
||||
feature: [ValveEntityFeature.OPEN, ValveEntityFeature.CLOSE],
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { GroupEntity } from "../../data/group";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
import { getGroupEntities } from "./get_group_entities";
|
||||
@@ -6,9 +6,9 @@ import { getGroupEntities } from "./get_group_entities";
|
||||
// Return an object containing all entities that the view will show
|
||||
// including embedded groups.
|
||||
export const getViewEntities = (
|
||||
entities: HassEntities,
|
||||
entities: HassEntityStates,
|
||||
view: GroupEntity
|
||||
): HassEntities => {
|
||||
): HassEntityStates => {
|
||||
const viewEntities = {};
|
||||
|
||||
view.attributes.entity_id.forEach((entityId) => {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { UNAVAILABLE, UNKNOWN } from "../../data/entity/entity";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
import { getToggleAction } from "./get_toggle_action";
|
||||
|
||||
export const computeGroupEntitiesState = (states: HassEntity[]): string => {
|
||||
export const computeGroupEntitiesState = (
|
||||
states: HassEntityState[]
|
||||
): string => {
|
||||
if (!states.length) {
|
||||
return UNAVAILABLE;
|
||||
}
|
||||
@@ -44,7 +46,7 @@ export const computeGroupEntitiesState = (states: HassEntity[]): string => {
|
||||
|
||||
export const toggleGroupEntities = (
|
||||
hass: Pick<HomeAssistant, "callService">,
|
||||
states: HassEntity[]
|
||||
states: HassEntityState[]
|
||||
) => {
|
||||
if (!states.length) {
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
|
||||
export const hasLocation = (stateObj: HassEntity) =>
|
||||
export const hasLocation = (stateObj: HassEntityState) =>
|
||||
"latitude" in stateObj.attributes && "longitude" in stateObj.attributes;
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { GroupEntity } from "../../data/group";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
|
||||
// Split a collection into a list of groups and a 'rest' list of ungrouped
|
||||
// entities.
|
||||
// Returns { groups: [], ungrouped: {} }
|
||||
export const splitByGroups = (entities: HassEntities) => {
|
||||
export const splitByGroups = (entities: HassEntityStates) => {
|
||||
const groups: GroupEntity[] = [];
|
||||
const ungrouped: HassEntities = {};
|
||||
const ungrouped: HassEntityStates = {};
|
||||
|
||||
Object.keys(entities).forEach((entityId) => {
|
||||
const entity = entities[entityId];
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { OFF, UNAVAILABLE, UNKNOWN } from "../../data/entity/entity";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
import { TIMESTAMP_STATE_DOMAINS } from "../const";
|
||||
|
||||
export function stateActive(stateObj: HassEntity, state?: string): boolean {
|
||||
export function stateActive(
|
||||
stateObj: HassEntityState,
|
||||
state?: string
|
||||
): boolean {
|
||||
const domain = computeDomain(stateObj.entity_id);
|
||||
const compareState = state !== undefined ? state : stateObj?.state;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {
|
||||
HassEntities,
|
||||
HassEntity,
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
HassServices,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { UNAVAILABLE } from "../../data/entity/entity";
|
||||
@@ -9,9 +9,9 @@ import { canToggleState } from "./can_toggle_state";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
|
||||
export const stateCardType = (
|
||||
states: HassEntities,
|
||||
states: HassEntityStates,
|
||||
services: HassServices,
|
||||
stateObj: HassEntity
|
||||
stateObj: HassEntityState
|
||||
) => {
|
||||
if (stateObj.state === UNAVAILABLE) {
|
||||
return "display";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Return a color representing a state. */
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { UNAVAILABLE } from "../../data/entity/entity";
|
||||
import type { GroupEntity } from "../../data/group";
|
||||
import { computeGroupDomain } from "../../data/group";
|
||||
@@ -44,7 +44,7 @@ const STATE_COLORED_DOMAIN = new Set([
|
||||
"weather",
|
||||
]);
|
||||
|
||||
export const stateColorCss = (stateObj: HassEntity, state?: string) => {
|
||||
export const stateColorCss = (stateObj: HassEntityState, state?: string) => {
|
||||
const compareState = state !== undefined ? state : stateObj?.state;
|
||||
if (compareState === UNAVAILABLE) {
|
||||
return `var(--state-unavailable-color)`;
|
||||
@@ -60,7 +60,7 @@ export const stateColorCss = (stateObj: HassEntity, state?: string) => {
|
||||
|
||||
export const domainStateColorProperties = (
|
||||
domain: string,
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
state?: string
|
||||
): string[] => {
|
||||
const compareState = state !== undefined ? state : stateObj.state;
|
||||
@@ -99,7 +99,7 @@ export const domainColorProperties = (
|
||||
};
|
||||
|
||||
export const stateColorProperties = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
state?: string
|
||||
): string[] | undefined => {
|
||||
const compareState = state !== undefined ? state : stateObj?.state;
|
||||
@@ -129,7 +129,7 @@ export const stateColorProperties = (
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const stateColorBrightness = (stateObj: HassEntity): string => {
|
||||
export const stateColorBrightness = (stateObj: HassEntityState): string => {
|
||||
if (
|
||||
stateObj.attributes.brightness &&
|
||||
computeDomain(stateObj.entity_id) !== "plant"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
import { updateIcon } from "./update_icon";
|
||||
import { deviceTrackerIcon } from "./device_tracker_icon";
|
||||
|
||||
export const stateIcon = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
state?: string
|
||||
): string | undefined => {
|
||||
const domain = computeStateDomain(stateObj);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
|
||||
export const supportsFeature = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
feature: number
|
||||
): boolean => supportsFeatureFromAttributes(stateObj.attributes, feature);
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { UpdateEntity } from "../../data/update";
|
||||
import { updateIsInstalling } from "../../data/update";
|
||||
|
||||
export const updateIcon = (stateObj: HassEntity, state?: string) => {
|
||||
export const updateIcon = (stateObj: HassEntityState, state?: string) => {
|
||||
const compareState = state ?? stateObj.state;
|
||||
// An install can be in progress even when the state is "off", e.g. when
|
||||
// downgrading firmware. Show the installing icon regardless of state.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { html } from "lit";
|
||||
import type { HassConfig } from "home-assistant-js-websocket";
|
||||
import { getConfigEntries } from "../../data/config_entries";
|
||||
import { domainToName } from "../../data/integration";
|
||||
import { getIntegrationDescriptions } from "../../data/integrations";
|
||||
@@ -6,7 +7,11 @@ import { showConfigFlowDialog } from "../../dialogs/config-flow/show-dialog-conf
|
||||
import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box";
|
||||
import { showMatterAddDeviceDialog } from "../../panels/config/integrations/integration-panels/matter/show-dialog-add-matter-device";
|
||||
import { showZWaveJSAddNodeDialog } from "../../panels/config/integrations/integration-panels/zwave_js/add-node/show-dialog-zwave_js-add-node";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import type { LocalizeFunc } from "../translations/localize";
|
||||
import type {
|
||||
HomeAssistantApi,
|
||||
HomeAssistantInternationalization,
|
||||
} from "../../types";
|
||||
import { documentationUrl } from "../../util/documentation-url";
|
||||
import { isComponentLoaded } from "../config/is_component_loaded";
|
||||
import { navigate } from "../navigate";
|
||||
@@ -15,17 +20,20 @@ export const PROTOCOL_INTEGRATIONS = ["zha", "zwave_js", "matter"] as const;
|
||||
|
||||
export const protocolIntegrationPicked = async (
|
||||
element: HTMLElement,
|
||||
hass: HomeAssistant,
|
||||
callWS: HomeAssistantApi["callWS"],
|
||||
localize: LocalizeFunc,
|
||||
loadBackendTranslation: HomeAssistantInternationalization["loadBackendTranslation"],
|
||||
hassConfig: HassConfig,
|
||||
domain: string,
|
||||
options?: { brand?: string; domain?: string; config_entry?: string }
|
||||
) => {
|
||||
if (options?.domain) {
|
||||
const localize = await hass.loadBackendTranslation("title", options.domain);
|
||||
options.domain = domainToName(localize, options.domain);
|
||||
const titleLocalize = await loadBackendTranslation("title", options.domain);
|
||||
options.domain = domainToName(titleLocalize, options.domain);
|
||||
}
|
||||
|
||||
if (options?.brand) {
|
||||
const integrationDescriptions = await getIntegrationDescriptions(hass);
|
||||
const integrationDescriptions = await getIntegrationDescriptions(callWS);
|
||||
options.brand =
|
||||
integrationDescriptions.core.integration[options.brand]?.name ||
|
||||
options.brand;
|
||||
@@ -35,37 +43,40 @@ export const protocolIntegrationPicked = async (
|
||||
const entries = options?.config_entry
|
||||
? undefined
|
||||
: (
|
||||
await getConfigEntries(hass, {
|
||||
domain,
|
||||
})
|
||||
await getConfigEntries(
|
||||
{ callWS },
|
||||
{
|
||||
domain,
|
||||
}
|
||||
)
|
||||
).filter((e) => !e.disabled_by);
|
||||
|
||||
if (
|
||||
!isComponentLoaded(hass.config, "zwave_js") ||
|
||||
!isComponentLoaded(hassConfig, "zwave_js") ||
|
||||
(!options?.config_entry && !entries?.length)
|
||||
) {
|
||||
// If the component isn't loaded, ask them to load the integration first
|
||||
showConfirmationDialog(element, {
|
||||
title: hass.localize(
|
||||
title: localize(
|
||||
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee_title",
|
||||
{ integration: "Z-Wave" }
|
||||
),
|
||||
text: hass.localize(
|
||||
text: localize(
|
||||
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee",
|
||||
{
|
||||
integration: "Z-Wave",
|
||||
brand: options?.brand || options?.domain || "Z-Wave",
|
||||
supported_hardware_link: html`<a
|
||||
href=${documentationUrl(hass, "/docs/z-wave/controllers")}
|
||||
href=${documentationUrl({ config: hassConfig }, "/docs/z-wave/controllers")}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>${hass.localize(
|
||||
>${localize(
|
||||
"ui.panel.config.integrations.config_flow.supported_hardware"
|
||||
)}</a
|
||||
>`,
|
||||
}
|
||||
),
|
||||
confirmText: hass.localize(
|
||||
confirmText: localize(
|
||||
"ui.panel.config.integrations.config_flow.proceed"
|
||||
),
|
||||
confirm: () => {
|
||||
@@ -84,40 +95,43 @@ export const protocolIntegrationPicked = async (
|
||||
const entries = options?.config_entry
|
||||
? undefined
|
||||
: (
|
||||
await getConfigEntries(hass, {
|
||||
domain,
|
||||
})
|
||||
await getConfigEntries(
|
||||
{ callWS },
|
||||
{
|
||||
domain,
|
||||
}
|
||||
)
|
||||
).filter((e) => !e.disabled_by);
|
||||
|
||||
if (
|
||||
!isComponentLoaded(hass.config, "zha") ||
|
||||
!isComponentLoaded(hassConfig, "zha") ||
|
||||
(!options?.config_entry && !entries?.length)
|
||||
) {
|
||||
// If the component isn't loaded, ask them to load the integration first
|
||||
showConfirmationDialog(element, {
|
||||
title: hass.localize(
|
||||
title: localize(
|
||||
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee_title",
|
||||
{ integration: "Zigbee" }
|
||||
),
|
||||
text: hass.localize(
|
||||
text: localize(
|
||||
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee",
|
||||
{
|
||||
integration: "Zigbee",
|
||||
brand: options?.brand || options?.domain || "Zigbee",
|
||||
supported_hardware_link: html`<a
|
||||
href=${documentationUrl(
|
||||
hass,
|
||||
{ config: hassConfig },
|
||||
"/integrations/zha/#known-working-zigbee-radio-modules"
|
||||
)}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>${hass.localize(
|
||||
>${localize(
|
||||
"ui.panel.config.integrations.config_flow.supported_hardware"
|
||||
)}</a
|
||||
>`,
|
||||
}
|
||||
),
|
||||
confirmText: hass.localize(
|
||||
confirmText: localize(
|
||||
"ui.panel.config.integrations.config_flow.proceed"
|
||||
),
|
||||
confirm: () => {
|
||||
@@ -134,36 +148,39 @@ export const protocolIntegrationPicked = async (
|
||||
const entries = options?.config_entry
|
||||
? undefined
|
||||
: (
|
||||
await getConfigEntries(hass, {
|
||||
domain,
|
||||
})
|
||||
await getConfigEntries(
|
||||
{ callWS },
|
||||
{
|
||||
domain,
|
||||
}
|
||||
)
|
||||
).filter((e) => !e.disabled_by);
|
||||
if (
|
||||
!isComponentLoaded(hass.config, domain) ||
|
||||
!isComponentLoaded(hassConfig, domain) ||
|
||||
(!options?.config_entry && !entries?.length)
|
||||
) {
|
||||
// If the component isn't loaded, ask them to load the integration first
|
||||
showConfirmationDialog(element, {
|
||||
title: hass.localize(
|
||||
title: localize(
|
||||
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee_title",
|
||||
{ integration: "Matter" }
|
||||
),
|
||||
text: hass.localize(
|
||||
text: localize(
|
||||
"ui.panel.config.integrations.config_flow.missing_matter",
|
||||
{
|
||||
integration: "Matter",
|
||||
brand: options?.brand || options?.domain || "Matter",
|
||||
supported_hardware_link: html`<a
|
||||
href=${documentationUrl(hass, "/integrations/matter")}
|
||||
href=${documentationUrl({ config: hassConfig }, "/integrations/matter")}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>${hass.localize(
|
||||
>${localize(
|
||||
"ui.panel.config.integrations.config_flow.supported_hardware"
|
||||
)}</a
|
||||
>`,
|
||||
}
|
||||
),
|
||||
confirmText: hass.localize(
|
||||
confirmText: localize(
|
||||
"ui.panel.config.integrations.config_flow.proceed"
|
||||
),
|
||||
confirm: () => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
closeAllDialogs,
|
||||
DIALOG_WAIT_TIMEOUT,
|
||||
updateClosedDialogSearch,
|
||||
} from "../dialogs/make-dialog-manager";
|
||||
import { fireEvent } from "./dom/fire_event";
|
||||
@@ -25,9 +26,6 @@ export interface NavigateOptions {
|
||||
keepDialogs?: boolean;
|
||||
}
|
||||
|
||||
// max time to wait for dialogs to close before navigating
|
||||
const DIALOG_WAIT_TIMEOUT = 500;
|
||||
|
||||
/**
|
||||
* State of the current history entry. Always read through this, the app writes
|
||||
* to the main window and a panel running in an iframe has its own history.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {
|
||||
HassEntity,
|
||||
HassEntityAttributeBase,
|
||||
HassEntityState,
|
||||
HassEntityStateAttributeBase,
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { EntityRegistryDisplayEntry } from "../../data/entity/entity_registry";
|
||||
import type { FrontendLocaleData } from "../../data/translation";
|
||||
@@ -12,11 +12,11 @@ import { blankBeforeUnit } from "../translations/blank_before_unit";
|
||||
* Returns true if the entity is considered numeric based on the attributes it has
|
||||
* @param stateObj The entity state object
|
||||
*/
|
||||
export const isNumericState = (stateObj: HassEntity): boolean =>
|
||||
export const isNumericState = (stateObj: HassEntityState): boolean =>
|
||||
isNumericFromAttributes(stateObj.attributes);
|
||||
|
||||
export const isNumericFromAttributes = (
|
||||
attributes: HassEntityAttributeBase
|
||||
attributes: HassEntityStateAttributeBase
|
||||
): boolean => !!attributes.unit_of_measurement || !!attributes.state_class;
|
||||
|
||||
export const numberFormatToLocale = (
|
||||
@@ -152,7 +152,7 @@ export const formatNumberToParts = (
|
||||
* @returns An `Intl.NumberFormatOptions` object with `maximumFractionDigits` set to 0, or `undefined`
|
||||
*/
|
||||
export const getNumberFormatOptions = (
|
||||
entityState?: HassEntity,
|
||||
entityState?: HassEntityState,
|
||||
entity?: EntityRegistryDisplayEntry
|
||||
): Intl.NumberFormatOptions | undefined => {
|
||||
const precision = entity?.display_precision;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassConfig, HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassConfig, HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { FrontendLocaleData } from "../../data/translation";
|
||||
import type { HomeAssistant, ValuePart } from "../../types";
|
||||
import {
|
||||
@@ -9,30 +9,30 @@ import {
|
||||
import type { LocalizeFunc } from "./localize";
|
||||
|
||||
export type FormatEntityStateFunc = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
state?: string
|
||||
) => string;
|
||||
export type FormatEntityStateToPartsFunc = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
state?: string
|
||||
) => ValuePart[];
|
||||
export type FormatEntityAttributeValueFunc = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
attribute: string,
|
||||
value?: any
|
||||
) => string;
|
||||
export type FormatEntityAttributeValueToPartsFunc = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
attribute: string,
|
||||
value?: any
|
||||
) => ValuePart[];
|
||||
export type FormatEntityAttributeNameFunc = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
attribute: string
|
||||
) => string;
|
||||
|
||||
export type FormatEntityNameFunc = (
|
||||
stateObj: HassEntity,
|
||||
stateObj: HassEntityState,
|
||||
name?: string | EntityNameItem | EntityNameItem[],
|
||||
options?: EntityNameOptions
|
||||
) => string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { LineSeriesOption } from "echarts/charts";
|
||||
import type { VisualMapComponentOption } from "echarts/components";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import { getGraphColorByIndex } from "../../common/color/colors";
|
||||
import { CLIMATE_HVAC_ACTION_TO_MODE } from "../../data/climate";
|
||||
import type { LineChartEntity, LineChartState } from "../../data/history";
|
||||
@@ -21,7 +21,7 @@ export const CLIMATE_MODE_CONFIGS = [
|
||||
|
||||
export interface StateHistoryChartLineDataParams {
|
||||
localize: LocalizeFunc;
|
||||
states: HassEntities;
|
||||
states: HassEntityStates;
|
||||
data: LineChartEntity[];
|
||||
endTime: Date;
|
||||
names?: Record<string, string>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassConfig, HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassConfig, HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues, TemplateResult } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -145,7 +145,7 @@ export class StateHistoryChartLine extends LitElement {
|
||||
private _entities!: HomeAssistant["entities"];
|
||||
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
private _states?: HassEntities;
|
||||
private _states?: HassEntityStates;
|
||||
|
||||
private _optionsEntityStates: Record<string, string | undefined> = {};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import type {
|
||||
CustomSeriesOption,
|
||||
CustomSeriesRenderItem,
|
||||
} from "echarts/types/dist/shared";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import { hex2rgb } from "../../common/color/convert-color";
|
||||
import { luminosity } from "../../common/color/rgb";
|
||||
import type { TimelineEntity } from "../../data/history";
|
||||
@@ -10,7 +10,7 @@ import { snapFrameSize } from "./down-sample";
|
||||
import { computeTimelineColor } from "./timeline-color";
|
||||
|
||||
export interface StateHistoryChartTimelineDataParams {
|
||||
states: HassEntities;
|
||||
states: HassEntityStates;
|
||||
data: TimelineEntity[];
|
||||
startTime: Date;
|
||||
endTime: Date;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -88,7 +88,7 @@ export class StateHistoryChartTimeline extends LitElement {
|
||||
private _hassConfig!: HomeAssistantConfig;
|
||||
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
private _states?: HassEntities;
|
||||
private _states?: HassEntityStates;
|
||||
|
||||
protected render() {
|
||||
return html`
|
||||
|
||||
@@ -3,7 +3,7 @@ import type {
|
||||
LineSeriesOption,
|
||||
ZRColor,
|
||||
} from "echarts/types/dist/shared";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import { getGraphColorByIndex } from "../../common/color/colors";
|
||||
import type { LocalizeFunc } from "../../common/translations/localize";
|
||||
import type {
|
||||
@@ -30,7 +30,7 @@ export interface StatisticsChartLegendItem {
|
||||
}
|
||||
|
||||
export interface StatisticsChartDataParams {
|
||||
states: HassEntities;
|
||||
states: HassEntityStates;
|
||||
formatEntityName: HomeAssistantFormatters["formatEntityName"];
|
||||
localize: LocalizeFunc;
|
||||
statisticsData: Statistics;
|
||||
|
||||
@@ -2,7 +2,7 @@ import type {
|
||||
BarSeriesOption,
|
||||
LineSeriesOption,
|
||||
} from "echarts/types/dist/shared";
|
||||
import type { HassConfig, HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassConfig, HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
@@ -186,7 +186,7 @@ export class StatisticsChart extends LitElement {
|
||||
private _themes!: Themes;
|
||||
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
private _states!: HassEntities;
|
||||
private _states!: HassEntityStates;
|
||||
|
||||
@consume({ context: entitiesContext, subscribe: true })
|
||||
private _entities!: HomeAssistant["entities"];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { getGraphColorByIndex } from "../../common/color/colors";
|
||||
import { hex2rgb, lab2hex, rgb2lab } from "../../common/color/convert-color";
|
||||
import { labBrighten } from "../../common/color/lab";
|
||||
@@ -23,7 +23,7 @@ const DOMAIN_STATE_SHADES: Record<string, Record<string, number>> = {
|
||||
function computeTimelineStateColor(
|
||||
state: string,
|
||||
computedStyles: CSSStyleDeclaration,
|
||||
stateObj?: HassEntity
|
||||
stateObj?: HassEntityState
|
||||
): string | undefined {
|
||||
if (!stateObj || state === UNAVAILABLE) {
|
||||
return computeCssValue("--history-unavailable-color", computedStyles);
|
||||
@@ -74,7 +74,7 @@ const stateColorMap = new Map<string, string>();
|
||||
function computeTimelineEnumColor(
|
||||
state: string,
|
||||
computedStyles: CSSStyleDeclaration,
|
||||
stateObj?: HassEntity
|
||||
stateObj?: HassEntityState
|
||||
): string | undefined {
|
||||
if (!stateObj) {
|
||||
return undefined;
|
||||
@@ -111,7 +111,7 @@ function computeTimeLineGenericColor(
|
||||
export function computeTimelineColor(
|
||||
state: string,
|
||||
computedStyles: CSSStyleDeclaration,
|
||||
stateObj?: HassEntity
|
||||
stateObj?: HassEntityState
|
||||
): string {
|
||||
return (
|
||||
computeTimelineStateColor(state, computedStyles, stateObj) ||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { RenderItemFunction } from "@lit-labs/virtualizer/virtualize";
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { property, state } from "lit/decorators";
|
||||
@@ -69,13 +69,13 @@ export abstract class HaDeviceAutomationPicker<
|
||||
|
||||
@state()
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
@transform<HassEntities, HassEntities>({
|
||||
@transform<HassEntityStates, HassEntityStates>({
|
||||
transformer: function (
|
||||
this: HaDeviceAutomationPicker<DeviceAutomation>,
|
||||
states
|
||||
) {
|
||||
const registryById = entityRegistryById(this._entityReg ?? []);
|
||||
const picked: HassEntities = {};
|
||||
const picked: HassEntityStates = {};
|
||||
[...(this._automations ?? []), this.value].forEach((automation) => {
|
||||
const id = automation?.entity_id;
|
||||
const entityId = id?.includes(".")
|
||||
@@ -89,7 +89,7 @@ export abstract class HaDeviceAutomationPicker<
|
||||
},
|
||||
watch: ["_automations", "value", "_entityReg"],
|
||||
})
|
||||
private _states: HassEntities = {};
|
||||
private _states: HassEntityStates = {};
|
||||
|
||||
@state()
|
||||
@consume({ context: formattersContext, subscribe: true })
|
||||
@@ -119,7 +119,7 @@ export abstract class HaDeviceAutomationPicker<
|
||||
|
||||
private _localizeDeviceAutomation: (
|
||||
localize: LocalizeFunc,
|
||||
states: HassEntities,
|
||||
states: HassEntityStates,
|
||||
formatEntityName: HomeAssistantFormatters["formatEntityName"],
|
||||
entityRegistry: EntityRegistryEntry[],
|
||||
automation: T
|
||||
@@ -214,7 +214,7 @@ export abstract class HaDeviceAutomationPicker<
|
||||
automations: T[] | undefined,
|
||||
localize: LocalizeFunc,
|
||||
language: string,
|
||||
states: HassEntities,
|
||||
states: HassEntityStates,
|
||||
formatEntityName: HomeAssistantFormatters["formatEntityName"],
|
||||
entityReg: EntityRegistryEntry[]
|
||||
) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { mdiSwapHorizontal } from "@mdi/js";
|
||||
import type { RenderItemFunction } from "@lit-labs/virtualizer/virtualize";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing, type PropertyValues } from "lit";
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
@@ -55,7 +55,9 @@ export type HaDevicePickerDeviceFilterFunc = (
|
||||
device: DeviceRegistryEntry
|
||||
) => boolean;
|
||||
|
||||
export type HaDevicePickerEntityFilterFunc = (entity: HassEntity) => boolean;
|
||||
export type HaDevicePickerEntityFilterFunc = (
|
||||
entity: HassEntityState
|
||||
) => boolean;
|
||||
|
||||
@customElement("ha-device-picker")
|
||||
export class HaDevicePicker extends LitElement {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { batteryLevelIcon } from "../../common/entity/battery_icon";
|
||||
@@ -6,9 +6,10 @@ import "../ha-icon";
|
||||
|
||||
@customElement("ha-battery-icon")
|
||||
export class HaBatteryIcon extends LitElement {
|
||||
@property({ attribute: false }) public batteryStateObj?: HassEntity;
|
||||
@property({ attribute: false }) public batteryStateObj?: HassEntityState;
|
||||
|
||||
@property({ attribute: false }) public batteryChargingStateObj?: HassEntity;
|
||||
@property({ attribute: false })
|
||||
public batteryChargingStateObj?: HassEntityState;
|
||||
|
||||
protected render() {
|
||||
if (!this.batteryStateObj) return nothing;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { LitElement, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
@@ -50,7 +50,7 @@ class HaEntityAttributePicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityStates({ entityIdPath: ["entityId"] })
|
||||
private _stateObjs?: Record<string, HassEntity>;
|
||||
private _stateObjs?: Record<string, HassEntityState>;
|
||||
|
||||
@state()
|
||||
@consume({ context: formattersContext, subscribe: true })
|
||||
@@ -64,7 +64,7 @@ class HaEntityAttributePicker extends LitElement {
|
||||
private _getItemsMemoized = memoizeOne(
|
||||
(
|
||||
entityId: string | string[] | undefined,
|
||||
stateObjs: Record<string, HassEntity> | undefined,
|
||||
stateObjs: Record<string, HassEntityState> | undefined,
|
||||
hideAttributes: string[] | undefined,
|
||||
formatEntityAttributeName: FormatEntityAttributeName
|
||||
): PickerComboBoxItem[] => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { RenderItemFunction } from "@lit-labs/virtualizer/virtualize";
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiDragHorizontalVariant, mdiPlus, mdiRestore } from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
@@ -101,7 +101,7 @@ export class HaEntityNamePicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityState({ entityIdPath: ["entityId"] })
|
||||
private _stateObj?: HassEntity;
|
||||
private _stateObj?: HassEntityState;
|
||||
|
||||
@state()
|
||||
@consume({ context: registriesContext, subscribe: true })
|
||||
@@ -423,7 +423,7 @@ export class HaEntityNamePicker extends LitElement {
|
||||
|
||||
private _defaultItems = memoizeOne(
|
||||
(
|
||||
stateObj: HassEntity | undefined,
|
||||
stateObj: HassEntityState | undefined,
|
||||
registries: ContextType<typeof registriesContext>
|
||||
): EntityNameItem[] => {
|
||||
if (!stateObj) {
|
||||
@@ -470,7 +470,7 @@ export class HaEntityNamePicker extends LitElement {
|
||||
|
||||
private _validTypes = memoizeOne(
|
||||
(
|
||||
stateObj: HassEntity | undefined,
|
||||
stateObj: HassEntityState | undefined,
|
||||
registries: ContextType<typeof registriesContext>
|
||||
) => {
|
||||
if (!stateObj) {
|
||||
@@ -497,7 +497,7 @@ export class HaEntityNamePicker extends LitElement {
|
||||
|
||||
private _getItems = memoizeOne(
|
||||
(
|
||||
stateObj: HassEntity | undefined,
|
||||
stateObj: HassEntityState | undefined,
|
||||
registries: ContextType<typeof registriesContext>,
|
||||
localize: LocalizeFunc,
|
||||
formatEntityName: HomeAssistantFormatters["formatEntityName"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiDragHorizontalVariant, mdiPlus } from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { repeat } from "lit/directives/repeat";
|
||||
@@ -118,7 +118,7 @@ export class HaStateContentPicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityState({ entityIdPath: ["entityId"] })
|
||||
private _stateObj?: HassEntity;
|
||||
private _stateObj?: HassEntityState;
|
||||
|
||||
@state()
|
||||
@consume({ context: registriesContext, subscribe: true })
|
||||
@@ -138,7 +138,7 @@ export class HaStateContentPicker extends LitElement {
|
||||
private _getItems = memoizeOne(
|
||||
(
|
||||
entityId: string | undefined,
|
||||
stateObj: HassEntity | undefined,
|
||||
stateObj: HassEntityState | undefined,
|
||||
allowName: boolean,
|
||||
allowContext: boolean,
|
||||
localize: LocalizeFunc,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { LitElement, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
@@ -45,7 +48,7 @@ const keepsStatesOrder = (
|
||||
};
|
||||
|
||||
export const computeEntityStateItems = (
|
||||
states: HassEntities | null | undefined,
|
||||
states: HassEntityStates | null | undefined,
|
||||
formatters: HomeAssistantFormatters,
|
||||
language: string,
|
||||
entityId: string | string[] | undefined,
|
||||
@@ -55,11 +58,11 @@ export const computeEntityStateItems = (
|
||||
): PickerComboBoxItem[] => {
|
||||
const entityIds = entityId ? ensureArray(entityId) : [];
|
||||
|
||||
const stateObjsByState = new Map<string, HassEntity>();
|
||||
const stateObjsByState = new Map<string, HassEntityState>();
|
||||
for (const entityIdItem of entityIds) {
|
||||
const stateObj =
|
||||
states?.[entityIdItem] ||
|
||||
({ entity_id: entityIdItem, attributes: {} } as HassEntity);
|
||||
({ entity_id: entityIdItem, attributes: {} } as HassEntityState);
|
||||
const entityStates = getStates(states ?? {}, language, stateObj, attribute);
|
||||
for (const s of entityStates) {
|
||||
if (!hideStates?.includes(s) && !stateObjsByState.has(s)) {
|
||||
@@ -105,7 +108,7 @@ export const computeEntityStateItems = (
|
||||
export const computeDefaultStateLabel = (
|
||||
i18n: ContextType<typeof internationalizationContext>,
|
||||
formatters: HomeAssistantFormatters,
|
||||
stateObjs: Record<string, HassEntity> | undefined,
|
||||
stateObjs: Record<string, HassEntityState> | undefined,
|
||||
entityId: string | string[] | undefined,
|
||||
attribute: string | undefined
|
||||
): string => {
|
||||
@@ -148,7 +151,7 @@ export class HaEntityStatePicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityStates({ entityIdPath: ["entityId"] })
|
||||
private _stateObjs?: Record<string, HassEntity>;
|
||||
private _stateObjs?: Record<string, HassEntityState>;
|
||||
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
private _states?: ContextType<typeof statesContext>;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -53,7 +56,7 @@ export class HaEntityStatesPicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityStates({ entityIdPath: ["entityId"] })
|
||||
private _stateObjs?: Record<string, HassEntity>;
|
||||
private _stateObjs?: Record<string, HassEntityState>;
|
||||
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
private _states?: ContextType<typeof statesContext>;
|
||||
@@ -68,7 +71,7 @@ export class HaEntityStatesPicker extends LitElement {
|
||||
|
||||
private _chipsSelector = memoizeOne(
|
||||
(
|
||||
states: HassEntities | null | undefined,
|
||||
states: HassEntityStates | null | undefined,
|
||||
formatters: HomeAssistantFormatters,
|
||||
language: string,
|
||||
entityId: string | string[] | undefined,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiFlash, mdiFlashOff } from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues, TemplateResult } from "lit";
|
||||
import { LitElement, css, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -16,7 +16,7 @@ import "../ha-switch";
|
||||
import { getToggleAction } from "../../common/entity/get_toggle_action";
|
||||
import type { LocalizeFunc } from "../../common/translations/localize";
|
||||
|
||||
const isOn = (stateObj?: HassEntity) =>
|
||||
const isOn = (stateObj?: HassEntityState) =>
|
||||
stateObj !== undefined &&
|
||||
!STATES_OFF.includes(stateObj.state) &&
|
||||
stateObj.state !== UNAVAILABLE &&
|
||||
@@ -43,7 +43,7 @@ export class HaEntityToggle extends LitElement {
|
||||
@consumeLocalize()
|
||||
private _localize!: LocalizeFunc;
|
||||
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
@property({ attribute: false }) public stateObj?: HassEntityState;
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiDelete } from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { consume } from "../../common/decorators/consume";
|
||||
@@ -32,7 +32,7 @@ export class HaFavoriteEntityListItem extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityState({ entityIdPath: ["entityId"] })
|
||||
private _stateObj?: HassEntity;
|
||||
private _stateObj?: HassEntityState;
|
||||
|
||||
@state()
|
||||
@consume({ context: registriesContext, subscribe: true })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiAlert } from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues, TemplateResult } from "lit";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -57,7 +57,7 @@ export class HaStateLabelBadge extends LitElement {
|
||||
@consumeEntityRegistryEntry({ entityIdPath: ["state", "entity_id"] })
|
||||
private _entry?: EntityRegistryDisplayEntry;
|
||||
|
||||
@property({ attribute: false }) public state?: HassEntity;
|
||||
@property({ attribute: false }) public state?: HassEntityState;
|
||||
|
||||
@property() public name?: string;
|
||||
|
||||
@@ -170,7 +170,7 @@ export class HaStateLabelBadge extends LitElement {
|
||||
|
||||
private _computeValue(
|
||||
domain: string,
|
||||
entityState: HassEntity,
|
||||
entityState: HassEntityState,
|
||||
entry?: EntityRegistryDisplayEntry
|
||||
) {
|
||||
switch (domain) {
|
||||
@@ -203,7 +203,7 @@ export class HaStateLabelBadge extends LitElement {
|
||||
|
||||
private _computeShowIcon(
|
||||
domain: string,
|
||||
entityState: HassEntity,
|
||||
entityState: HassEntityState,
|
||||
entry?: EntityRegistryDisplayEntry
|
||||
): boolean {
|
||||
if (entityState.state === UNAVAILABLE) {
|
||||
@@ -228,7 +228,7 @@ export class HaStateLabelBadge extends LitElement {
|
||||
|
||||
private _computeLabel(
|
||||
domain: string,
|
||||
entityState: HassEntity,
|
||||
entityState: HassEntityState,
|
||||
_timerTimeRemaining = 0
|
||||
) {
|
||||
// For unavailable states or certain domains, use a special translation that is truncated to fit within the badge label
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
mdiPencil,
|
||||
mdiShape,
|
||||
} from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, nothing, type PropertyValues } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
@@ -54,7 +54,7 @@ type StatisticItemType = "entity" | "external" | "no_state";
|
||||
|
||||
interface StatisticComboBoxItem extends PickerComboBoxItem {
|
||||
statistic_id?: string;
|
||||
stateObj?: HassEntity;
|
||||
stateObj?: HassEntityState;
|
||||
domainName?: string;
|
||||
type?: StatisticItemType;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiAlert } from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -30,7 +30,7 @@ import "../ha-state-icon";
|
||||
|
||||
@customElement("state-badge")
|
||||
export class StateBadge extends LitElement {
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
@property({ attribute: false }) public stateObj?: HassEntityState;
|
||||
|
||||
@property({ attribute: false }) public overrideIcon?: string;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
@@ -14,7 +14,7 @@ import "./state-badge";
|
||||
|
||||
@customElement("state-info")
|
||||
class StateInfo extends LitElement {
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
@property({ attribute: false }) public stateObj?: HassEntityState;
|
||||
|
||||
@property({ attribute: "in-dialog", type: Boolean }) public inDialog = false;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import Fuse from "fuse.js";
|
||||
@@ -29,7 +29,7 @@ import "./ha-state-icon";
|
||||
|
||||
export interface AreaControlPickerItem extends PickerComboBoxItem {
|
||||
type?: "domain" | "entity";
|
||||
stateObj?: HassEntity;
|
||||
stateObj?: HassEntityState;
|
||||
domain?: string;
|
||||
deviceClass?: string;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiPlus, mdiTextureBox } from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { LitElement, html, nothing } from "lit";
|
||||
import type { TemplateResult, PropertyValues } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
@@ -85,7 +85,7 @@ export class HaAreaPicker extends LitElement {
|
||||
public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||
|
||||
@property({ attribute: false })
|
||||
public entityFilter?: (entity: HassEntity) => boolean;
|
||||
public entityFilter?: (entity: HassEntityState) => boolean;
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { mdiDragHorizontalVariant } from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
@@ -48,7 +48,7 @@ export class HaAreasPicker extends LitElement {
|
||||
public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||
|
||||
@property({ attribute: false })
|
||||
public entityFilter?: (entity: HassEntity) => boolean;
|
||||
public entityFilter?: (entity: HassEntityState) => boolean;
|
||||
|
||||
@property({ attribute: "picked-area-label" })
|
||||
public pickedAreaLabel?: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { initialState } from "@lit/task";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { consume } from "../common/decorators/consume";
|
||||
@@ -16,7 +16,7 @@ import "./ha-svg-icon";
|
||||
|
||||
@customElement("ha-attribute-icon")
|
||||
export class HaAttributeIcon extends LitElement {
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
@property({ attribute: false }) public stateObj?: HassEntityState;
|
||||
|
||||
@property() public attribute?: string;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { initialState } from "@lit/task";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { consume } from "../common/decorators/consume";
|
||||
@@ -20,7 +20,7 @@ class HaAttributeValue extends LitElement {
|
||||
@consume({ context: formattersContext, subscribe: true })
|
||||
private _formatters?: ContextType<typeof formattersContext>;
|
||||
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
@property({ attribute: false }) public stateObj?: HassEntityState;
|
||||
|
||||
@property() public attribute!: string;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
mdiRedo,
|
||||
mdiUndo,
|
||||
} from "@mdi/js";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { css, html, ReactiveElement, render } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -1096,7 +1096,7 @@ export class HaCodeEditor extends ReactiveElement {
|
||||
|
||||
private _getStates = memoizeOne(
|
||||
(
|
||||
states: HassEntities,
|
||||
states: HassEntityStates,
|
||||
formatEntityName: HomeAssistantFormatters["formatEntityName"],
|
||||
registries: HomeAssistantRegistries
|
||||
): Completion[] => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { TemplateResult } from "lit";
|
||||
import { LitElement, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -26,7 +26,7 @@ export interface EntitiesDisplayValue {
|
||||
export class HaEntitiesDisplayEditor extends LitElement {
|
||||
@state()
|
||||
@consumeEntityStates({ entityIdPath: ["entitiesIds"] })
|
||||
private _entityStates?: Record<string, HassEntity>;
|
||||
private _entityStates?: Record<string, HassEntityState>;
|
||||
|
||||
@consume({ context: entitiesContext, subscribe: true })
|
||||
@state()
|
||||
@@ -85,7 +85,7 @@ export class HaEntitiesDisplayEditor extends LitElement {
|
||||
private _items = memoizeOne(
|
||||
(
|
||||
entitiesIds: string[],
|
||||
entityStates: Record<string, HassEntity> | undefined,
|
||||
entityStates: Record<string, HassEntityState> | undefined,
|
||||
entitiesReg: ContextType<typeof entitiesContext>,
|
||||
config: ContextType<typeof configContext>,
|
||||
connection: ContextType<typeof connectionContext>,
|
||||
@@ -93,7 +93,7 @@ export class HaEntitiesDisplayEditor extends LitElement {
|
||||
): DisplayItem[] => {
|
||||
const entities = entitiesIds
|
||||
.map((entityId) => entityStates?.[entityId])
|
||||
.filter((stateObj): stateObj is HassEntity => Boolean(stateObj));
|
||||
.filter((stateObj): stateObj is HassEntityState => Boolean(stateObj));
|
||||
|
||||
return entities.map((entity) => ({
|
||||
value: entity.entity_id,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { consumeEntityState } from "../common/decorators/consume-context-entry";
|
||||
@@ -10,7 +10,7 @@ import "./ha-state-icon";
|
||||
export class HaEntityIdIcon extends LitElement {
|
||||
@state()
|
||||
@consumeEntityState({ entityIdPath: ["entityId"] })
|
||||
private stateObj?: HassEntity;
|
||||
private stateObj?: HassEntityState;
|
||||
|
||||
@property({ attribute: false }) public entityId!: string;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { mdiFilterVariantRemove } from "@mdi/js";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
@@ -34,7 +34,7 @@ import type { HaListSelectableVirtualized } from "./list/ha-list-selectable-virt
|
||||
import type { HaListVirtualizedItem } from "./list/ha-list-virtualized";
|
||||
|
||||
interface EntityItem extends HaListVirtualizedItem {
|
||||
stateObj: HassEntity;
|
||||
stateObj: HassEntityState;
|
||||
name: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { RenderItemFunction } from "@lit-labs/virtualizer/virtualize";
|
||||
import { mdiPlus, mdiTextureBox } from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { LitElement, html } from "lit";
|
||||
import type { TemplateResult, PropertyValues } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
@@ -105,7 +105,7 @@ export class HaFloorPicker extends LitElement {
|
||||
public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||
|
||||
@property({ attribute: false })
|
||||
public entityFilter?: (entity: HassEntity) => boolean;
|
||||
public entityFilter?: (entity: HassEntityState) => boolean;
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
@@ -46,7 +46,7 @@ export class HaFloorsPicker extends LitElement {
|
||||
public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||
|
||||
@property({ attribute: false })
|
||||
public entityFilter?: (entity: HassEntity) => boolean;
|
||||
public entityFilter?: (entity: HassEntityState) => boolean;
|
||||
|
||||
@property({ attribute: "picked-floor-label" })
|
||||
public pickedFloorLabel?: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { RenderItemFunction } from "@lit-labs/virtualizer/virtualize";
|
||||
import { mdiPlus } from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { LitElement, html, nothing } from "lit";
|
||||
import type { TemplateResult, PropertyValues } from "lit";
|
||||
import {
|
||||
@@ -107,7 +107,7 @@ export class HaLabelPicker extends LitElement {
|
||||
public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||
|
||||
@property({ attribute: false })
|
||||
public entityFilter?: (entity: HassEntity) => boolean;
|
||||
public entityFilter?: (entity: HassEntityState) => boolean;
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiPlaylistPlus } from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { TemplateResult } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
@@ -75,7 +75,7 @@ export class HaLabelsPicker extends LitElement {
|
||||
public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||
|
||||
@property({ attribute: false })
|
||||
public entityFilter?: (entity: HassEntity) => boolean;
|
||||
public entityFilter?: (entity: HassEntityState) => boolean;
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { mdiDelete, mdiPlayBox, mdiPlus } from "@mdi/js";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -59,7 +59,7 @@ export class HaMediaItemPicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
@transform<HassEntities | null, boolean>({
|
||||
@transform<HassEntityStates | null, boolean>({
|
||||
transformer: function (this: HaMediaItemPicker, states) {
|
||||
const entityId = this._getActiveEntityId();
|
||||
if (!entityId) {
|
||||
|
||||
@@ -5,7 +5,10 @@ import {
|
||||
mdiTransitConnectionVariant,
|
||||
} from "@mdi/js";
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -74,9 +77,9 @@ export class HaRelatedItems extends LitElement {
|
||||
|
||||
@state()
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
@transform<HassEntities, HassEntities>({
|
||||
@transform<HassEntityStates, HassEntityStates>({
|
||||
transformer: function (this: HaRelatedItems, states) {
|
||||
const related: HassEntities = {};
|
||||
const related: HassEntityStates = {};
|
||||
ENTITY_SECTIONS.forEach((section) => {
|
||||
this._related?.[section]?.forEach((entityId) => {
|
||||
if (states?.[entityId]) {
|
||||
@@ -88,7 +91,7 @@ export class HaRelatedItems extends LitElement {
|
||||
},
|
||||
watch: ["_related"],
|
||||
})
|
||||
private _states: HassEntities = {};
|
||||
private _states: HassEntityStates = {};
|
||||
|
||||
@state()
|
||||
@consume({ context: devicesContext, subscribe: true })
|
||||
@@ -180,14 +183,14 @@ export class HaRelatedItems extends LitElement {
|
||||
private _relatedEntities = memoizeOne(
|
||||
(
|
||||
related: RelatedResult,
|
||||
states: HassEntities,
|
||||
states: HassEntityStates,
|
||||
formatEntityName: HomeAssistantFormatters["formatEntityName"],
|
||||
language: string
|
||||
) => {
|
||||
const toEntities = (entityIds: string[] = []) =>
|
||||
entityIds
|
||||
.map((entityId) => states[entityId])
|
||||
.filter((entity): entity is HassEntity => entity !== undefined)
|
||||
.filter((entity): entity is HassEntityState => entity !== undefined)
|
||||
.sort((a, b) =>
|
||||
caseInsensitiveStringCompare(
|
||||
formatEntityName(a),
|
||||
@@ -477,7 +480,7 @@ export class HaRelatedItems extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _renderEntityRow(entity: HassEntity) {
|
||||
private _renderEntityRow(entity: HassEntityState) {
|
||||
return html`
|
||||
<ha-list-item-button
|
||||
.headline=${this._formatEntityName(entity)}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -137,7 +137,7 @@ export class HaAreaSelector extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _filterEntities = (entity: HassEntity): boolean => {
|
||||
private _filterEntities = (entity: HassEntityState): boolean => {
|
||||
if (!this.selector.area?.entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -28,7 +28,7 @@ export class HaSelectorAttribute extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityStates({ entityIdPath: ["context", "filter_entity"] })
|
||||
private _filterEntityStates?: Record<string, HassEntity>;
|
||||
private _filterEntityStates?: Record<string, HassEntityState>;
|
||||
|
||||
protected render() {
|
||||
return html`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
@@ -35,7 +35,7 @@ export class HaColorTempSelector extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityStates({ entityIdPath: ["context", "filter_entity"] })
|
||||
private _filterEntityStates?: Record<string, HassEntity>;
|
||||
private _filterEntityStates?: Record<string, HassEntityState>;
|
||||
|
||||
protected render() {
|
||||
const { min, max } = this._bounds();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -153,7 +153,7 @@ export class HaDeviceSelector extends LitElement {
|
||||
);
|
||||
};
|
||||
|
||||
private _filterEntities = (entity: HassEntity): boolean =>
|
||||
private _filterEntities = (entity: HassEntityState): boolean =>
|
||||
ensureArray(this.selector.device!.entity).some((filter) =>
|
||||
filterSelectorEntities(
|
||||
filter,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -210,7 +210,7 @@ export class HaEntitySelector extends LitElement {
|
||||
entitySources: EntitySources | undefined,
|
||||
configEntries: ConfigEntry[] | undefined
|
||||
) =>
|
||||
(entity: HassEntity): boolean => {
|
||||
(entity: HassEntityState): boolean => {
|
||||
if (!selector.entity?.filter) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -136,7 +136,7 @@ export class HaFloorSelector extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _filterEntities = (entity: HassEntity): boolean => {
|
||||
private _filterEntities = (entity: HassEntityState): boolean => {
|
||||
if (!this.selector.floor?.entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ContextType } from "@lit/context";
|
||||
import { initialState } from "@lit/task";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { consume } from "../../common/decorators/consume";
|
||||
import { AsyncValueTask } from "../../common/controllers/async-value-task";
|
||||
import { consumeEntityState } from "../../common/decorators/consume-context-entry";
|
||||
@@ -37,7 +37,7 @@ export class HaIconSelector extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityState({ entityIdPath: ["context", "icon_entity"] })
|
||||
private _stateObj?: HassEntity;
|
||||
private _stateObj?: HassEntityState;
|
||||
|
||||
@state()
|
||||
@consume({ context: entitiesContext, subscribe: true })
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
mdiPencil,
|
||||
} from "@mdi/js";
|
||||
import deepClone from "deep-clone-simple";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing, type PropertyValues } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
@@ -71,7 +71,7 @@ export class HaObjectSelector extends LitElement {
|
||||
|
||||
@state()
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
private _states!: HassEntities;
|
||||
private _states!: HassEntityStates;
|
||||
|
||||
@state()
|
||||
@consume({ context: formattersContext, subscribe: true })
|
||||
@@ -265,7 +265,7 @@ export class HaObjectSelector extends LitElement {
|
||||
(
|
||||
i18n: HomeAssistantInternationalization,
|
||||
registries: HomeAssistantRegistries,
|
||||
states: HassEntities,
|
||||
states: HassEntityStates,
|
||||
formatEntityName: HomeAssistantFormatters["formatEntityName"]
|
||||
): FormatSelectorValueOptions => ({
|
||||
locale: i18n.locale,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -149,7 +149,7 @@ export class HaTargetSelector extends LitElement {
|
||||
if (!filters) {
|
||||
return ALL_ENTITIES;
|
||||
}
|
||||
return (entity: HassEntity): boolean =>
|
||||
return (entity: HassEntityState): boolean =>
|
||||
ensureArray(filters).some((filter) =>
|
||||
filterSelectorEntities(
|
||||
filter,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { initialState } from "@lit/task";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -23,7 +23,7 @@ import "./ha-svg-icon";
|
||||
|
||||
@customElement("ha-state-icon")
|
||||
export class HaStateIcon extends LitElement {
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
@property({ attribute: false }) public stateObj?: HassEntityState;
|
||||
|
||||
@state()
|
||||
@consume({ context: formattersContext, subscribe: true })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -60,9 +60,9 @@ export class HaSTTPicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
@transform<HassEntities, HassEntities>({
|
||||
@transform<HassEntityStates, HassEntityStates>({
|
||||
transformer: function (this: HaSTTPicker, states) {
|
||||
const engineStates: HassEntities = {};
|
||||
const engineStates: HassEntityStates = {};
|
||||
this._engines?.forEach(({ engine_id }) => {
|
||||
if (states?.[engine_id]) {
|
||||
engineStates[engine_id] = states[engine_id];
|
||||
@@ -72,7 +72,7 @@ export class HaSTTPicker extends LitElement {
|
||||
},
|
||||
watch: ["_engines"],
|
||||
})
|
||||
private _states: HassEntities = {};
|
||||
private _states: HassEntityStates = {};
|
||||
|
||||
@state()
|
||||
@consume({ context: formattersContext, subscribe: true })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -60,9 +60,9 @@ export class HaTTSPicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
@transform<HassEntities, HassEntities>({
|
||||
@transform<HassEntityStates, HassEntityStates>({
|
||||
transformer: function (this: HaTTSPicker, states) {
|
||||
const engineStates: HassEntities = {};
|
||||
const engineStates: HassEntityStates = {};
|
||||
this._engines?.forEach(({ engine_id }) => {
|
||||
if (states?.[engine_id]) {
|
||||
engineStates[engine_id] = states[engine_id];
|
||||
@@ -72,7 +72,7 @@ export class HaTTSPicker extends LitElement {
|
||||
},
|
||||
watch: ["_engines"],
|
||||
})
|
||||
private _states: HassEntities = {};
|
||||
private _states: HassEntityStates = {};
|
||||
|
||||
@state()
|
||||
@consume({ context: formattersContext, subscribe: true })
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ContextType } from "@lit/context";
|
||||
import type { CSSResultGroup, TemplateResult } from "lit";
|
||||
import { LitElement, css, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { consume } from "../common/decorators/consume";
|
||||
import { consumeLocalize } from "../common/decorators/consume-context-entry";
|
||||
import type { LocalizeFunc } from "../common/translations/localize";
|
||||
@@ -55,7 +55,7 @@ export class HaVacuumState extends LitElement {
|
||||
@consume({ context: apiContext, subscribe: true })
|
||||
private _api!: ContextType<typeof apiContext>;
|
||||
|
||||
@property({ attribute: false }) public stateObj!: HassEntity;
|
||||
@property({ attribute: false }) public stateObj!: HassEntityState;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
const interceptable = this._computeInterceptable(
|
||||
|
||||
Loaded 100 of 489 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user