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