mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
20240906.0 (#21911)
This commit is contained in:
commit
ba770f8e50
@ -64,6 +64,7 @@ const DEVICES: DeviceRegistryEntry[] = [
|
|||||||
labels: [],
|
labels: [],
|
||||||
created_at: 0,
|
created_at: 0,
|
||||||
modified_at: 0,
|
modified_at: 0,
|
||||||
|
primary_config_entry: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
area_id: "backyard",
|
area_id: "backyard",
|
||||||
@ -86,6 +87,7 @@ const DEVICES: DeviceRegistryEntry[] = [
|
|||||||
labels: [],
|
labels: [],
|
||||||
created_at: 0,
|
created_at: 0,
|
||||||
modified_at: 0,
|
modified_at: 0,
|
||||||
|
primary_config_entry: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
area_id: null,
|
area_id: null,
|
||||||
@ -108,6 +110,7 @@ const DEVICES: DeviceRegistryEntry[] = [
|
|||||||
labels: [],
|
labels: [],
|
||||||
created_at: 0,
|
created_at: 0,
|
||||||
modified_at: 0,
|
modified_at: 0,
|
||||||
|
primary_config_entry: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ const DEVICES: DeviceRegistryEntry[] = [
|
|||||||
labels: [],
|
labels: [],
|
||||||
created_at: 0,
|
created_at: 0,
|
||||||
modified_at: 0,
|
modified_at: 0,
|
||||||
|
primary_config_entry: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
area_id: "backyard",
|
area_id: "backyard",
|
||||||
@ -86,6 +87,7 @@ const DEVICES: DeviceRegistryEntry[] = [
|
|||||||
labels: [],
|
labels: [],
|
||||||
created_at: 0,
|
created_at: 0,
|
||||||
modified_at: 0,
|
modified_at: 0,
|
||||||
|
primary_config_entry: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
area_id: null,
|
area_id: null,
|
||||||
@ -108,6 +110,7 @@ const DEVICES: DeviceRegistryEntry[] = [
|
|||||||
labels: [],
|
labels: [],
|
||||||
created_at: 0,
|
created_at: 0,
|
||||||
modified_at: 0,
|
modified_at: 0,
|
||||||
|
primary_config_entry: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -232,6 +232,7 @@ const createDeviceRegistryEntries = (
|
|||||||
labels: [],
|
labels: [],
|
||||||
created_at: 0,
|
created_at: 0,
|
||||||
modified_at: 0,
|
modified_at: 0,
|
||||||
|
primary_config_entry: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@
|
|||||||
"husky": "9.1.5",
|
"husky": "9.1.5",
|
||||||
"instant-mocha": "1.5.2",
|
"instant-mocha": "1.5.2",
|
||||||
"jszip": "3.10.1",
|
"jszip": "3.10.1",
|
||||||
"lint-staged": "15.2.9",
|
"lint-staged": "15.2.10",
|
||||||
"lit-analyzer": "2.0.3",
|
"lit-analyzer": "2.0.3",
|
||||||
"lodash.merge": "4.6.2",
|
"lodash.merge": "4.6.2",
|
||||||
"lodash.template": "4.5.0",
|
"lodash.template": "4.5.0",
|
||||||
|
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "home-assistant-frontend"
|
name = "home-assistant-frontend"
|
||||||
version = "20240904.0"
|
version = "20240906.0"
|
||||||
license = {text = "Apache-2.0"}
|
license = {text = "Apache-2.0"}
|
||||||
description = "The Home Assistant frontend"
|
description = "The Home Assistant frontend"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
@ -67,7 +67,9 @@ export class HaNumberSelector extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
${this.label ? html`${this.label}${this.required ? "*" : ""}` : nothing}
|
${this.label && !isBox
|
||||||
|
? html`${this.label}${this.required ? "*" : ""}`
|
||||||
|
: nothing}
|
||||||
<div class="input">
|
<div class="input">
|
||||||
${!isBox
|
${!isBox
|
||||||
? html`
|
? html`
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import type { HomeAssistant } from "../types";
|
import type { HomeAssistant } from "../types";
|
||||||
import type { IntegrationManifest, IntegrationType } from "./integration";
|
import type { IntegrationType } from "./integration";
|
||||||
|
|
||||||
export interface ConfigEntry {
|
export interface ConfigEntry {
|
||||||
entry_id: string;
|
entry_id: string;
|
||||||
@ -149,20 +149,19 @@ export const enableConfigEntry = (hass: HomeAssistant, configEntryId: string) =>
|
|||||||
|
|
||||||
export const sortConfigEntries = (
|
export const sortConfigEntries = (
|
||||||
configEntries: ConfigEntry[],
|
configEntries: ConfigEntry[],
|
||||||
manifestLookup: { [domain: string]: IntegrationManifest }
|
primaryConfigEntry: string | null
|
||||||
): ConfigEntry[] => {
|
): ConfigEntry[] => {
|
||||||
const sortedConfigEntries = [...configEntries];
|
if (!primaryConfigEntry) {
|
||||||
|
return configEntries;
|
||||||
const getScore = (entry: ConfigEntry) => {
|
}
|
||||||
const manifest = manifestLookup[entry.domain] as
|
const primaryEntry = configEntries.find(
|
||||||
| IntegrationManifest
|
(e) => e.entry_id === primaryConfigEntry
|
||||||
| undefined;
|
);
|
||||||
const isHelper = manifest?.integration_type === "helper";
|
if (!primaryEntry) {
|
||||||
return isHelper ? -1 : 1;
|
return configEntries;
|
||||||
};
|
}
|
||||||
|
const otherEntries = configEntries.filter(
|
||||||
const configEntriesCompare = (a: ConfigEntry, b: ConfigEntry) =>
|
(e) => e.entry_id !== primaryConfigEntry
|
||||||
getScore(b) - getScore(a);
|
);
|
||||||
|
return [primaryEntry, ...otherEntries];
|
||||||
return sortedConfigEntries.sort(configEntriesCompare);
|
|
||||||
};
|
};
|
||||||
|
@ -33,6 +33,7 @@ export interface DeviceRegistryEntry extends RegistryEntry {
|
|||||||
entry_type: "service" | null;
|
entry_type: "service" | null;
|
||||||
disabled_by: "user" | "integration" | "config_entry" | null;
|
disabled_by: "user" | "integration" | "config_entry" | null;
|
||||||
configuration_url: string | null;
|
configuration_url: string | null;
|
||||||
|
primary_config_entry: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeviceEntityDisplayLookup {
|
export interface DeviceEntityDisplayLookup {
|
||||||
|
@ -153,7 +153,7 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
.filter((entId) => entId in entryLookup)
|
.filter((entId) => entId in entryLookup)
|
||||||
.map((entry) => entryLookup[entry]);
|
.map((entry) => entryLookup[entry]);
|
||||||
|
|
||||||
return sortConfigEntries(deviceEntries, manifestLookup);
|
return sortConfigEntries(deviceEntries, device.primary_config_entry);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
|||||||
device.config_entries
|
device.config_entries
|
||||||
.filter((entId) => entId in entryLookup)
|
.filter((entId) => entId in entryLookup)
|
||||||
.map((entId) => entryLookup[entId]),
|
.map((entId) => entryLookup[entId]),
|
||||||
manifestLookup
|
device.primary_config_entry
|
||||||
);
|
);
|
||||||
|
|
||||||
const labels = labelReg && device?.labels;
|
const labels = labelReg && device?.labels;
|
||||||
|
@ -6,19 +6,18 @@ import {
|
|||||||
mdiCloseCircle,
|
mdiCloseCircle,
|
||||||
mdiProgressClock,
|
mdiProgressClock,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
|
||||||
import {
|
import {
|
||||||
css,
|
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
html,
|
|
||||||
LitElement,
|
LitElement,
|
||||||
nothing,
|
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
|
css,
|
||||||
|
html,
|
||||||
|
nothing,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import memoizeOne from "memoize-one";
|
import { groupBy } from "../../../../../common/util/group-by";
|
||||||
import "../../../../../components/ha-alert";
|
import "../../../../../components/ha-alert";
|
||||||
import "../../../../../components/ha-card";
|
import "../../../../../components/ha-card";
|
||||||
import "../../../../../components/ha-icon-next";
|
import "../../../../../components/ha-icon-next";
|
||||||
@ -27,25 +26,19 @@ import "../../../../../components/ha-settings-row";
|
|||||||
import "../../../../../components/ha-svg-icon";
|
import "../../../../../components/ha-svg-icon";
|
||||||
import "../../../../../components/ha-switch";
|
import "../../../../../components/ha-switch";
|
||||||
import "../../../../../components/ha-textfield";
|
import "../../../../../components/ha-textfield";
|
||||||
import { groupBy } from "../../../../../common/util/group-by";
|
import { computeDeviceName } from "../../../../../data/device_registry";
|
||||||
import {
|
|
||||||
computeDeviceName,
|
|
||||||
DeviceRegistryEntry,
|
|
||||||
subscribeDeviceRegistry,
|
|
||||||
} from "../../../../../data/device_registry";
|
|
||||||
import {
|
import {
|
||||||
|
ZWaveJSNodeConfigParam,
|
||||||
|
ZWaveJSNodeConfigParams,
|
||||||
|
ZWaveJSSetConfigParamResult,
|
||||||
|
ZwaveJSNodeMetadata,
|
||||||
fetchZwaveNodeConfigParameters,
|
fetchZwaveNodeConfigParameters,
|
||||||
fetchZwaveNodeMetadata,
|
fetchZwaveNodeMetadata,
|
||||||
setZwaveNodeConfigParameter,
|
setZwaveNodeConfigParameter,
|
||||||
ZWaveJSNodeConfigParam,
|
|
||||||
ZWaveJSNodeConfigParams,
|
|
||||||
ZwaveJSNodeMetadata,
|
|
||||||
ZWaveJSSetConfigParamResult,
|
|
||||||
} from "../../../../../data/zwave_js";
|
} from "../../../../../data/zwave_js";
|
||||||
import "../../../../../layouts/hass-error-screen";
|
import "../../../../../layouts/hass-error-screen";
|
||||||
import "../../../../../layouts/hass-loading-screen";
|
import "../../../../../layouts/hass-loading-screen";
|
||||||
import "../../../../../layouts/hass-tabs-subpage";
|
import "../../../../../layouts/hass-tabs-subpage";
|
||||||
import { SubscribeMixin } from "../../../../../mixins/subscribe-mixin";
|
|
||||||
import { haStyle } from "../../../../../resources/styles";
|
import { haStyle } from "../../../../../resources/styles";
|
||||||
import type { HomeAssistant, Route } from "../../../../../types";
|
import type { HomeAssistant, Route } from "../../../../../types";
|
||||||
import "../../../ha-config-section";
|
import "../../../ha-config-section";
|
||||||
@ -57,16 +50,8 @@ const icons = {
|
|||||||
error: mdiCloseCircle,
|
error: mdiCloseCircle,
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDevice = memoizeOne(
|
|
||||||
(
|
|
||||||
deviceId: string,
|
|
||||||
entries?: DeviceRegistryEntry[]
|
|
||||||
): DeviceRegistryEntry | undefined =>
|
|
||||||
entries?.find((device) => device.id === deviceId)
|
|
||||||
);
|
|
||||||
|
|
||||||
@customElement("zwave_js-node-config")
|
@customElement("zwave_js-node-config")
|
||||||
class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
class ZWaveJSNodeConfig extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property({ attribute: false }) public route!: Route;
|
@property({ attribute: false }) public route!: Route;
|
||||||
@ -79,8 +64,6 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
@property() public deviceId!: string;
|
@property() public deviceId!: string;
|
||||||
|
|
||||||
@state() private _deviceRegistryEntries?: DeviceRegistryEntry[];
|
|
||||||
|
|
||||||
@state() private _nodeMetadata?: ZwaveJSNodeMetadata;
|
@state() private _nodeMetadata?: ZwaveJSNodeMetadata;
|
||||||
|
|
||||||
@state() private _config?: ZWaveJSNodeConfigParams;
|
@state() private _config?: ZWaveJSNodeConfigParams;
|
||||||
@ -94,19 +77,8 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
|||||||
this.deviceId = this.route.path.substr(1);
|
this.deviceId = this.route.path.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public hassSubscribe(): UnsubscribeFunc[] {
|
|
||||||
return [
|
|
||||||
subscribeDeviceRegistry(this.hass.connection, (entries) => {
|
|
||||||
this._deviceRegistryEntries = entries;
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected updated(changedProps: PropertyValues): void {
|
protected updated(changedProps: PropertyValues): void {
|
||||||
if (
|
if (!this._config || changedProps.has("deviceId")) {
|
||||||
(!this._config || changedProps.has("deviceId")) &&
|
|
||||||
changedProps.has("_deviceRegistryEntries")
|
|
||||||
) {
|
|
||||||
this._fetchData();
|
this._fetchData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,7 +97,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
|||||||
return html`<hass-loading-screen></hass-loading-screen>`;
|
return html`<hass-loading-screen></hass-loading-screen>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const device = this._device!;
|
const device = this.hass.devices[this.deviceId];
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hass-tabs-subpage
|
<hass-tabs-subpage
|
||||||
@ -392,7 +364,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
|||||||
try {
|
try {
|
||||||
const result = await setZwaveNodeConfigParameter(
|
const result = await setZwaveNodeConfigParameter(
|
||||||
this.hass,
|
this.hass,
|
||||||
this._device!.id,
|
this.deviceId,
|
||||||
target.property,
|
target.property,
|
||||||
target.endpoint,
|
target.endpoint,
|
||||||
value,
|
value,
|
||||||
@ -420,16 +392,12 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
|||||||
this._results = { ...this._results, [key]: errorParam };
|
this._results = { ...this._results, [key]: errorParam };
|
||||||
}
|
}
|
||||||
|
|
||||||
private get _device(): DeviceRegistryEntry | undefined {
|
|
||||||
return getDevice(this.deviceId, this._deviceRegistryEntries);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async _fetchData() {
|
private async _fetchData() {
|
||||||
if (!this.configEntryId || !this._deviceRegistryEntries) {
|
if (!this.configEntryId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const device = this._device;
|
const device = this.hass.devices[this.deviceId];
|
||||||
if (!device) {
|
if (!device) {
|
||||||
this._error = "device_not_found";
|
this._error = "device_not_found";
|
||||||
return;
|
return;
|
||||||
|
14
yarn.lock
14
yarn.lock
@ -9070,7 +9070,7 @@ __metadata:
|
|||||||
jszip: "npm:3.10.1"
|
jszip: "npm:3.10.1"
|
||||||
leaflet: "npm:1.9.4"
|
leaflet: "npm:1.9.4"
|
||||||
leaflet-draw: "npm:1.0.4"
|
leaflet-draw: "npm:1.0.4"
|
||||||
lint-staged: "npm:15.2.9"
|
lint-staged: "npm:15.2.10"
|
||||||
lit: "npm:2.8.0"
|
lit: "npm:2.8.0"
|
||||||
lit-analyzer: "npm:2.0.3"
|
lit-analyzer: "npm:2.0.3"
|
||||||
lodash.merge: "npm:4.6.2"
|
lodash.merge: "npm:4.6.2"
|
||||||
@ -10497,9 +10497,9 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"lint-staged@npm:15.2.9":
|
"lint-staged@npm:15.2.10":
|
||||||
version: 15.2.9
|
version: 15.2.10
|
||||||
resolution: "lint-staged@npm:15.2.9"
|
resolution: "lint-staged@npm:15.2.10"
|
||||||
dependencies:
|
dependencies:
|
||||||
chalk: "npm:~5.3.0"
|
chalk: "npm:~5.3.0"
|
||||||
commander: "npm:~12.1.0"
|
commander: "npm:~12.1.0"
|
||||||
@ -10507,13 +10507,13 @@ __metadata:
|
|||||||
execa: "npm:~8.0.1"
|
execa: "npm:~8.0.1"
|
||||||
lilconfig: "npm:~3.1.2"
|
lilconfig: "npm:~3.1.2"
|
||||||
listr2: "npm:~8.2.4"
|
listr2: "npm:~8.2.4"
|
||||||
micromatch: "npm:~4.0.7"
|
micromatch: "npm:~4.0.8"
|
||||||
pidtree: "npm:~0.6.0"
|
pidtree: "npm:~0.6.0"
|
||||||
string-argv: "npm:~0.3.2"
|
string-argv: "npm:~0.3.2"
|
||||||
yaml: "npm:~2.5.0"
|
yaml: "npm:~2.5.0"
|
||||||
bin:
|
bin:
|
||||||
lint-staged: bin/lint-staged.js
|
lint-staged: bin/lint-staged.js
|
||||||
checksum: 10/2f7342ca3fc7e2a8a0cc3db79ca8d2ad0269b98b13220f3a6745a514aacf1f83487a23a550569081ea962f9a576af7df8d687a8330a9c3c2c27348d5a4d5440e
|
checksum: 10/ab6930cd633dbb5b6ec7c81fc06c65df41e9f80d93dd22e0d79c6e272cdfd8110a0fbdec60303d46a06b30bcd92261153630e2c937531b77ec5ae41e7e9d90d3
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@ -10937,7 +10937,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"micromatch@npm:^4.0.2, micromatch@npm:^4.0.4, micromatch@npm:~4.0.7":
|
"micromatch@npm:^4.0.2, micromatch@npm:^4.0.4, micromatch@npm:~4.0.8":
|
||||||
version: 4.0.8
|
version: 4.0.8
|
||||||
resolution: "micromatch@npm:4.0.8"
|
resolution: "micromatch@npm:4.0.8"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user