Use device_id instead of config entry id and node id for zwave_js (#12658)

* Use device_id instead of config entry id and node id for zwave_js

* Add additional cleanup from #12642

* Revert removal of multiple config entries check

* Update src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-actions-zwave_js.ts

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Update src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-info-zwave_js.ts

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
Raman Gupta 2022-05-19 13:23:16 -04:00 committed by GitHub
parent 32a991989f
commit 5b7b0ea326
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 78 additions and 174 deletions

View File

@ -145,7 +145,7 @@ export interface ZWaveJSController {
supports_timers: boolean; supports_timers: boolean;
is_heal_network_active: boolean; is_heal_network_active: boolean;
inclusion_state: InclusionState; inclusion_state: InclusionState;
nodes: number[]; nodes: ZWaveJSNodeStatus[];
} }
export interface ZWaveJSNodeStatus { export interface ZWaveJSNodeStatus {
@ -200,8 +200,7 @@ export interface ZWaveJSNodeConfigParamMetadata {
export interface ZWaveJSSetConfigParamData { export interface ZWaveJSSetConfigParamData {
type: string; type: string;
entry_id: string; device_id: string;
node_id: number;
property: number; property: number;
property_key?: number; property_key?: number;
value: string | number; value: string | number;
@ -427,49 +426,41 @@ export const unprovisionZwaveSmartStartNode = (
export const fetchZwaveNodeStatus = ( export const fetchZwaveNodeStatus = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string, device_id: string
node_id: number
): Promise<ZWaveJSNodeStatus> => ): Promise<ZWaveJSNodeStatus> =>
hass.callWS({ hass.callWS({
type: "zwave_js/node_status", type: "zwave_js/node_status",
entry_id, device_id,
node_id,
}); });
export const fetchZwaveNodeMetadata = ( export const fetchZwaveNodeMetadata = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string, device_id: string
node_id: number
): Promise<ZwaveJSNodeMetadata> => ): Promise<ZwaveJSNodeMetadata> =>
hass.callWS({ hass.callWS({
type: "zwave_js/node_metadata", type: "zwave_js/node_metadata",
entry_id, device_id,
node_id,
}); });
export const fetchZwaveNodeConfigParameters = ( export const fetchZwaveNodeConfigParameters = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string, device_id: string
node_id: number
): Promise<ZWaveJSNodeConfigParams> => ): Promise<ZWaveJSNodeConfigParams> =>
hass.callWS({ hass.callWS({
type: "zwave_js/get_config_parameters", type: "zwave_js/get_config_parameters",
entry_id, device_id,
node_id,
}); });
export const setZwaveNodeConfigParameter = ( export const setZwaveNodeConfigParameter = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string, device_id: string,
node_id: number,
property: number, property: number,
value: number, value: number,
property_key?: number property_key?: number
): Promise<ZWaveJSSetConfigParamResult> => { ): Promise<ZWaveJSSetConfigParamResult> => {
const data: ZWaveJSSetConfigParamData = { const data: ZWaveJSSetConfigParamData = {
type: "zwave_js/set_config_parameter", type: "zwave_js/set_config_parameter",
entry_id, device_id,
node_id,
property, property,
value, value,
property_key, property_key,
@ -479,42 +470,36 @@ export const setZwaveNodeConfigParameter = (
export const reinterviewZwaveNode = ( export const reinterviewZwaveNode = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string, device_id: string,
node_id: number,
callbackFunction: (message: ZWaveJSRefreshNodeStatusMessage) => void callbackFunction: (message: ZWaveJSRefreshNodeStatusMessage) => void
): Promise<UnsubscribeFunc> => ): Promise<UnsubscribeFunc> =>
hass.connection.subscribeMessage( hass.connection.subscribeMessage(
(message: any) => callbackFunction(message), (message: any) => callbackFunction(message),
{ {
type: "zwave_js/refresh_node_info", type: "zwave_js/refresh_node_info",
entry_id, device_id,
node_id,
} }
); );
export const healZwaveNode = ( export const healZwaveNode = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string, device_id: string
node_id: number
): Promise<boolean> => ): Promise<boolean> =>
hass.callWS({ hass.callWS({
type: "zwave_js/heal_node", type: "zwave_js/heal_node",
entry_id, device_id,
node_id,
}); });
export const removeFailedZwaveNode = ( export const removeFailedZwaveNode = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string, device_id: string,
node_id: number,
callbackFunction: (message: any) => void callbackFunction: (message: any) => void
): Promise<UnsubscribeFunc> => ): Promise<UnsubscribeFunc> =>
hass.connection.subscribeMessage( hass.connection.subscribeMessage(
(message: any) => callbackFunction(message), (message: any) => callbackFunction(message),
{ {
type: "zwave_js/remove_failed_node", type: "zwave_js/remove_failed_node",
entry_id, device_id,
node_id,
} }
); );
@ -538,16 +523,14 @@ export const stopHealZwaveNetwork = (
export const subscribeZwaveNodeReady = ( export const subscribeZwaveNodeReady = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string, device_id: string,
node_id: number,
callbackFunction: (message) => void callbackFunction: (message) => void
): Promise<UnsubscribeFunc> => ): Promise<UnsubscribeFunc> =>
hass.connection.subscribeMessage( hass.connection.subscribeMessage(
(message: any) => callbackFunction(message), (message: any) => callbackFunction(message),
{ {
type: "zwave_js/node_ready", type: "zwave_js/node_ready",
entry_id, device_id,
node_id,
} }
); );

View File

@ -11,8 +11,6 @@ import { customElement, property, state } from "lit/decorators";
import { DeviceRegistryEntry } from "../../../../../../data/device_registry"; import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
import { import {
fetchZwaveNodeStatus, fetchZwaveNodeStatus,
getZwaveJsIdentifiersFromDevice,
ZWaveJSNodeIdentifiers,
ZWaveJSNodeStatus, ZWaveJSNodeStatus,
} from "../../../../../../data/zwave_js"; } from "../../../../../../data/zwave_js";
import { haStyle } from "../../../../../../resources/styles"; import { haStyle } from "../../../../../../resources/styles";
@ -20,6 +18,7 @@ import { HomeAssistant } from "../../../../../../types";
import { showZWaveJSReinterviewNodeDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-reinterview-node"; import { showZWaveJSReinterviewNodeDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-reinterview-node";
import { showZWaveJSHealNodeDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-heal-node"; import { showZWaveJSHealNodeDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-heal-node";
import { showZWaveJSRemoveFailedNodeDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-remove-failed-node"; import { showZWaveJSRemoveFailedNodeDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-remove-failed-node";
import { getConfigEntries } from "../../../../../../data/config_entries";
@customElement("ha-device-actions-zwave_js") @customElement("ha-device-actions-zwave_js")
export class HaDeviceActionsZWaveJS extends LitElement { export class HaDeviceActionsZWaveJS extends LitElement {
@ -29,34 +28,37 @@ export class HaDeviceActionsZWaveJS extends LitElement {
@state() private _entryId?: string; @state() private _entryId?: string;
@state() private _nodeId?: number;
@state() private _node?: ZWaveJSNodeStatus; @state() private _node?: ZWaveJSNodeStatus;
protected updated(changedProperties: PropertyValues) { public willUpdate(changedProperties: PropertyValues) {
super.willUpdate(changedProperties);
if (changedProperties.has("device")) { if (changedProperties.has("device")) {
const identifiers: ZWaveJSNodeIdentifiers | undefined =
getZwaveJsIdentifiersFromDevice(this.device);
if (!identifiers) {
return;
}
this._nodeId = identifiers.node_id;
this._entryId = this.device.config_entries[0];
this._fetchNodeDetails(); this._fetchNodeDetails();
} }
} }
protected async _fetchNodeDetails() { protected async _fetchNodeDetails() {
if (!this._nodeId || !this._entryId) { if (!this.device) {
return; return;
} }
this._node = await fetchZwaveNodeStatus( this._node = undefined;
this.hass,
this._entryId, const configEntries = await getConfigEntries(this.hass, {
this._nodeId domain: "zwave_js",
});
const configEntry = configEntries.find((entry) =>
this.device.config_entries.includes(entry.entry_id)
); );
if (!configEntry) {
return;
}
this._entryId = configEntry.entry_id;
this._node = await fetchZwaveNodeStatus(this.hass, this.device.id);
} }
protected render(): TemplateResult { protected render(): TemplateResult {
@ -96,33 +98,30 @@ export class HaDeviceActionsZWaveJS extends LitElement {
} }
private async _reinterviewClicked() { private async _reinterviewClicked() {
if (!this._nodeId || !this._entryId) { if (!this.device) {
return; return;
} }
showZWaveJSReinterviewNodeDialog(this, { showZWaveJSReinterviewNodeDialog(this, {
entry_id: this._entryId, device_id: this.device.id,
node_id: this._nodeId,
}); });
} }
private async _healNodeClicked() { private async _healNodeClicked() {
if (!this._nodeId || !this._entryId) { if (!this.device) {
return; return;
} }
showZWaveJSHealNodeDialog(this, { showZWaveJSHealNodeDialog(this, {
entry_id: this._entryId, entry_id: this._entryId!,
node_id: this._nodeId,
device: this.device, device: this.device,
}); });
} }
private async _removeFailedNode() { private async _removeFailedNode() {
if (!this._nodeId || !this._entryId) { if (!this.device) {
return; return;
} }
showZWaveJSRemoveFailedNodeDialog(this, { showZWaveJSRemoveFailedNodeDialog(this, {
entry_id: this._entryId, device_id: this.device.id,
node_id: this._nodeId,
}); });
} }

View File

@ -14,10 +14,8 @@ import {
} from "../../../../../../data/config_entries"; } from "../../../../../../data/config_entries";
import { import {
fetchZwaveNodeStatus, fetchZwaveNodeStatus,
getZwaveJsIdentifiersFromDevice,
nodeStatus, nodeStatus,
ZWaveJSNodeStatus, ZWaveJSNodeStatus,
ZWaveJSNodeIdentifiers,
SecurityClass, SecurityClass,
} from "../../../../../../data/zwave_js"; } from "../../../../../../data/zwave_js";
import { haStyle } from "../../../../../../resources/styles"; import { haStyle } from "../../../../../../resources/styles";
@ -29,57 +27,41 @@ export class HaDeviceInfoZWaveJS extends LitElement {
@property({ attribute: false }) public device!: DeviceRegistryEntry; @property({ attribute: false }) public device!: DeviceRegistryEntry;
@state() private _entryId?: string;
@state() private _configEntry?: ConfigEntry; @state() private _configEntry?: ConfigEntry;
@state() private _multipleConfigEntries = false; @state() private _multipleConfigEntries = false;
@state() private _nodeId?: number;
@state() private _node?: ZWaveJSNodeStatus; @state() private _node?: ZWaveJSNodeStatus;
protected updated(changedProperties: PropertyValues) { public willUpdate(changedProperties: PropertyValues) {
super.willUpdate(changedProperties);
if (changedProperties.has("device")) { if (changedProperties.has("device")) {
const identifiers: ZWaveJSNodeIdentifiers | undefined =
getZwaveJsIdentifiersFromDevice(this.device);
if (!identifiers) {
return;
}
this._nodeId = identifiers.node_id;
this._entryId = this.device.config_entries[0];
this._fetchNodeDetails(); this._fetchNodeDetails();
} }
} }
protected async _fetchNodeDetails() { protected async _fetchNodeDetails() {
if (!this._nodeId || !this._entryId) { if (!this.device) {
return; return;
} }
const configEntries = await getConfigEntries(this.hass, { const configEntries = await getConfigEntries(this.hass, {
domain: "zwave_js", domain: "zwave_js",
}); });
let zwaveJsConfEntries = 0;
for (const entry of configEntries) { this._multipleConfigEntries = configEntries.length > 1;
if (zwaveJsConfEntries) {
this._multipleConfigEntries = true; const configEntry = configEntries.find((entry) =>
} this.device.config_entries.includes(entry.entry_id)
if (entry.entry_id === this._entryId) { );
this._configEntry = entry;
} if (!configEntry) {
if (this._configEntry && this._multipleConfigEntries) { return;
break;
}
zwaveJsConfEntries++;
} }
this._node = await fetchZwaveNodeStatus( this._configEntry = configEntry;
this.hass,
this._entryId, this._node = await fetchZwaveNodeStatus(this.hass, this.device.id);
this._nodeId
);
} }
protected render(): TemplateResult { protected render(): TemplateResult {

View File

@ -922,13 +922,12 @@ export class HaConfigDevicePage extends LitElement {
} }
private _renderIntegrationInfo( private _renderIntegrationInfo(
device, device: DeviceRegistryEntry,
integrations: ConfigEntry[], integrations: ConfigEntry[],
deviceInfo: TemplateResult[], deviceInfo: TemplateResult[],
deviceActions: (string | TemplateResult)[] deviceActions: (string | TemplateResult)[]
): TemplateResult[] { ) {
const domains = integrations.map((int) => int.domain); const domains = integrations.map((int) => int.domain);
const templates: TemplateResult[] = [];
if (domains.includes("mqtt")) { if (domains.includes("mqtt")) {
import( import(
"./device-detail/integration-elements/mqtt/ha-device-actions-mqtt" "./device-detail/integration-elements/mqtt/ha-device-actions-mqtt"
@ -976,7 +975,6 @@ export class HaConfigDevicePage extends LitElement {
></ha-device-actions-zwave_js> ></ha-device-actions-zwave_js>
`); `);
} }
return templates;
} }
private async _showSettings() { private async _showSettings() {

View File

@ -24,8 +24,6 @@ class DialogZWaveJSHealNode extends LitElement {
@state() private entry_id?: string; @state() private entry_id?: string;
@state() private node_id?: number;
@state() private device?: DeviceRegistryEntry; @state() private device?: DeviceRegistryEntry;
@state() private _status?: string; @state() private _status?: string;
@ -35,14 +33,12 @@ class DialogZWaveJSHealNode extends LitElement {
public showDialog(params: ZWaveJSHealNodeDialogParams): void { public showDialog(params: ZWaveJSHealNodeDialogParams): void {
this.entry_id = params.entry_id; this.entry_id = params.entry_id;
this.device = params.device; this.device = params.device;
this.node_id = params.node_id;
this._fetchData(); this._fetchData();
} }
public closeDialog(): void { public closeDialog(): void {
this.entry_id = undefined; this.entry_id = undefined;
this._status = undefined; this._status = undefined;
this.node_id = undefined;
this.device = undefined; this.device = undefined;
this._error = undefined; this._error = undefined;
@ -221,11 +217,7 @@ class DialogZWaveJSHealNode extends LitElement {
} }
this._status = "started"; this._status = "started";
try { try {
this._status = (await healZwaveNode( this._status = (await healZwaveNode(this.hass, this.device!.id))
this.hass,
this.entry_id!,
this.node_id!
))
? "finished" ? "finished"
: "failed"; : "failed";
} catch (err: any) { } catch (err: any) {

View File

@ -15,9 +15,7 @@ import { ZWaveJSReinterviewNodeDialogParams } from "./show-dialog-zwave_js-reint
class DialogZWaveJSReinterviewNode extends LitElement { class DialogZWaveJSReinterviewNode extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@state() private entry_id?: string; @state() private device_id?: string;
@state() private node_id?: number;
@state() private _status?: string; @state() private _status?: string;
@ -29,12 +27,11 @@ class DialogZWaveJSReinterviewNode extends LitElement {
params: ZWaveJSReinterviewNodeDialogParams params: ZWaveJSReinterviewNodeDialogParams
): Promise<void> { ): Promise<void> {
this._stages = undefined; this._stages = undefined;
this.entry_id = params.entry_id; this.device_id = params.device_id;
this.node_id = params.node_id;
} }
protected render(): TemplateResult { protected render(): TemplateResult {
if (!this.entry_id) { if (!this.device_id) {
return html``; return html``;
} }
@ -159,8 +156,7 @@ class DialogZWaveJSReinterviewNode extends LitElement {
} }
this._subscribed = reinterviewZwaveNode( this._subscribed = reinterviewZwaveNode(
this.hass, this.hass,
this.entry_id!, this.device_id!,
this.node_id!,
this._handleMessage.bind(this) this._handleMessage.bind(this)
); );
} }
@ -194,8 +190,7 @@ class DialogZWaveJSReinterviewNode extends LitElement {
} }
public closeDialog(): void { public closeDialog(): void {
this.entry_id = undefined; this.device_id = undefined;
this.node_id = undefined;
this._status = undefined; this._status = undefined;
this._stages = undefined; this._stages = undefined;

View File

@ -18,9 +18,7 @@ import { ZWaveJSRemoveFailedNodeDialogParams } from "./show-dialog-zwave_js-remo
class DialogZWaveJSRemoveFailedNode extends LitElement { class DialogZWaveJSRemoveFailedNode extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@state() private entry_id?: string; @state() private device_id?: string;
@state() private node_id?: number;
@state() private _status = ""; @state() private _status = "";
@ -38,13 +36,12 @@ class DialogZWaveJSRemoveFailedNode extends LitElement {
public async showDialog( public async showDialog(
params: ZWaveJSRemoveFailedNodeDialogParams params: ZWaveJSRemoveFailedNodeDialogParams
): Promise<void> { ): Promise<void> {
this.entry_id = params.entry_id; this.device_id = params.device_id;
this.node_id = params.node_id;
} }
public closeDialog(): void { public closeDialog(): void {
this._unsubscribe(); this._unsubscribe();
this.entry_id = undefined; this.device_id = undefined;
this._status = ""; this._status = "";
fireEvent(this, "dialog-closed", { dialog: this.localName }); fireEvent(this, "dialog-closed", { dialog: this.localName });
@ -56,7 +53,7 @@ class DialogZWaveJSRemoveFailedNode extends LitElement {
} }
protected render(): TemplateResult { protected render(): TemplateResult {
if (!this.entry_id || !this.node_id) { if (!this.device_id) {
return html``; return html``;
} }
@ -166,8 +163,7 @@ class DialogZWaveJSRemoveFailedNode extends LitElement {
this._status = "started"; this._status = "started";
this._subscribed = removeFailedZwaveNode( this._subscribed = removeFailedZwaveNode(
this.hass, this.hass,
this.entry_id!, this.device_id!,
this.node_id!,
(message: any) => this._handleMessage(message) (message: any) => this._handleMessage(message)
).catch((error) => { ).catch((error) => {
this._status = "failed"; this._status = "failed";

View File

@ -3,7 +3,6 @@ import { DeviceRegistryEntry } from "../../../../../data/device_registry";
export interface ZWaveJSHealNodeDialogParams { export interface ZWaveJSHealNodeDialogParams {
entry_id: string; entry_id: string;
node_id: number;
device: DeviceRegistryEntry; device: DeviceRegistryEntry;
} }

View File

@ -1,8 +1,7 @@
import { fireEvent } from "../../../../../common/dom/fire_event"; import { fireEvent } from "../../../../../common/dom/fire_event";
export interface ZWaveJSReinterviewNodeDialogParams { export interface ZWaveJSReinterviewNodeDialogParams {
entry_id: string; device_id: string;
node_id: number;
} }
export const loadReinterviewNodeDialog = () => export const loadReinterviewNodeDialog = () =>

View File

@ -1,8 +1,7 @@
import { fireEvent } from "../../../../../common/dom/fire_event"; import { fireEvent } from "../../../../../common/dom/fire_event";
export interface ZWaveJSRemoveFailedNodeDialogParams { export interface ZWaveJSRemoveFailedNodeDialogParams {
entry_id: string; device_id: string;
node_id: number;
} }
export const loadRemoveFailedNodeDialog = () => export const loadRemoveFailedNodeDialog = () =>

View File

@ -17,7 +17,6 @@ import "../../../../../components/ha-svg-icon";
import { import {
fetchZwaveDataCollectionStatus, fetchZwaveDataCollectionStatus,
fetchZwaveNetworkStatus, fetchZwaveNetworkStatus,
fetchZwaveNodeStatus,
fetchZwaveProvisioningEntries, fetchZwaveProvisioningEntries,
InclusionState, InclusionState,
setZwaveDataCollectionPreference, setZwaveDataCollectionPreference,
@ -25,7 +24,6 @@ import {
stopZwaveInclusion, stopZwaveInclusion,
ZWaveJSClient, ZWaveJSClient,
ZWaveJSNetwork, ZWaveJSNetwork,
ZWaveJSNodeStatus,
ZwaveJSProvisioningEntry, ZwaveJSProvisioningEntry,
} from "../../../../../data/zwave_js"; } from "../../../../../data/zwave_js";
import { import {
@ -60,8 +58,6 @@ class ZWaveJSConfigDashboard extends LitElement {
@state() private _network?: ZWaveJSNetwork; @state() private _network?: ZWaveJSNetwork;
@state() private _nodes?: ZWaveJSNodeStatus[];
@state() private _provisioningEntries?: ZwaveJSProvisioningEntry[]; @state() private _provisioningEntries?: ZwaveJSProvisioningEntry[];
@state() private _status?: ZWaveJSClient["state"]; @state() private _status?: ZWaveJSClient["state"];
@ -84,9 +80,8 @@ class ZWaveJSConfigDashboard extends LitElement {
if (ERROR_STATES.includes(this._configEntry.state)) { if (ERROR_STATES.includes(this._configEntry.state)) {
return this._renderErrorScreen(); return this._renderErrorScreen();
} }
const notReadyDevices = const notReadyDevices =
this._nodes?.filter((node) => !node.ready).length ?? 0; this._network?.controller.nodes.filter((node) => !node.ready).length ?? 0;
return html` return html`
<hass-tabs-subpage <hass-tabs-subpage
@ -414,18 +409,6 @@ class ZWaveJSConfigDashboard extends LitElement {
this._dataCollectionOptIn = this._dataCollectionOptIn =
dataCollectionStatus.opted_in === true || dataCollectionStatus.opted_in === true ||
dataCollectionStatus.enabled === true; dataCollectionStatus.enabled === true;
this._fetchNodeStatus();
}
private async _fetchNodeStatus() {
if (!this._network) {
return;
}
const nodeStatePromisses = this._network.controller.nodes.map((nodeId) =>
fetchZwaveNodeStatus(this.hass, this.configEntryId!, nodeId)
);
this._nodes = await Promise.all(nodeStatePromisses);
} }
private async _addNodeClicked() { private async _addNodeClicked() {

View File

@ -61,19 +61,6 @@ const getDevice = memoizeOne(
entries?.find((device) => device.id === deviceId) entries?.find((device) => device.id === deviceId)
); );
const getNodeId = memoizeOne(
(device: DeviceRegistryEntry): number | undefined => {
const identifier = device.identifiers.find(
(ident) => ident[0] === "zwave_js"
);
if (!identifier) {
return undefined;
}
return parseInt(identifier[1].split("-")[1]);
}
);
@customElement("zwave_js-node-config") @customElement("zwave_js-node-config")
class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) { class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@ -382,12 +369,10 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
} }
private async _updateConfigParameter(target, value) { private async _updateConfigParameter(target, value) {
const nodeId = getNodeId(this._device!);
try { try {
const result = await setZwaveNodeConfigParameter( const result = await setZwaveNodeConfigParameter(
this.hass, this.hass,
this.configEntryId!, this._device!.id,
nodeId!,
target.property, target.property,
value, value,
target.propertyKey ? target.propertyKey : undefined target.propertyKey ? target.propertyKey : undefined
@ -429,15 +414,9 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
return; return;
} }
const nodeId = getNodeId(device);
if (!nodeId) {
this._error = "device_not_found";
return;
}
[this._nodeMetadata, this._config] = await Promise.all([ [this._nodeMetadata, this._config] = await Promise.all([
fetchZwaveNodeMetadata(this.hass, this.configEntryId, nodeId!), fetchZwaveNodeMetadata(this.hass, device.id),
fetchZwaveNodeConfigParameters(this.hass, this.configEntryId, nodeId!), fetchZwaveNodeConfigParameters(this.hass, device.id),
]); ]);
} }