Handle breaking changes as result of zwave_js lib upgrade (#18009)

* Handle breaking changes as result of zwave_js lib upgrade

* fix capitalization
This commit is contained in:
Raman Gupta 2023-09-28 14:00:21 -04:00 committed by GitHub
parent 30c6e4e35e
commit 5a5265723c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 150 additions and 134 deletions

View File

@ -192,7 +192,7 @@ export interface ZWaveJSController {
supported_function_types: number[]; supported_function_types: number[];
suc_node_id: number; suc_node_id: number;
supports_timers: boolean; supports_timers: boolean;
is_heal_network_active: boolean; is_rebuilding_routes: boolean;
inclusion_state: InclusionState; inclusion_state: InclusionState;
nodes: ZWaveJSNodeStatus[]; nodes: ZWaveJSNodeStatus[];
} }
@ -278,9 +278,9 @@ export interface ZWaveJSRefreshNodeStatusMessage {
stage?: string; stage?: string;
} }
export interface ZWaveJSHealNetworkStatusMessage { export interface ZWaveJSRebuildRoutesStatusMessage {
event: string; event: string;
heal_node_status: { [key: number]: string }; rebuild_routes_status: { [key: number]: string };
} }
export interface ZWaveJSControllerStatisticsUpdatedMessage { export interface ZWaveJSControllerStatisticsUpdatedMessage {
@ -651,12 +651,12 @@ export const reinterviewZwaveNode = (
} }
); );
export const healZwaveNode = ( export const rebuildZwaveNodeRoutes = (
hass: HomeAssistant, hass: HomeAssistant,
device_id: string device_id: string
): Promise<boolean> => ): Promise<boolean> =>
hass.callWS({ hass.callWS({
type: "zwave_js/heal_node", type: "zwave_js/rebuild_node_routes",
device_id, device_id,
}); });
@ -673,33 +673,33 @@ export const removeFailedZwaveNode = (
} }
); );
export const healZwaveNetwork = ( export const rebuildZwaveNetworkRoutes = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string entry_id: string
): Promise<UnsubscribeFunc> => ): Promise<UnsubscribeFunc> =>
hass.callWS({ hass.callWS({
type: "zwave_js/begin_healing_network", type: "zwave_js/begin_rebuilding_routes",
entry_id, entry_id,
}); });
export const stopHealZwaveNetwork = ( export const stopRebuildingZwaveNetworkRoutes = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string entry_id: string
): Promise<UnsubscribeFunc> => ): Promise<UnsubscribeFunc> =>
hass.callWS({ hass.callWS({
type: "zwave_js/stop_healing_network", type: "zwave_js/stop_rebuilding_routes",
entry_id, entry_id,
}); });
export const subscribeHealZwaveNetworkProgress = ( export const subscribeRebuildZwaveNetworkRoutesProgress = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string, entry_id: string,
callbackFunction: (message: ZWaveJSHealNetworkStatusMessage) => void callbackFunction: (message: ZWaveJSRebuildRoutesStatusMessage) => void
): Promise<UnsubscribeFunc> => ): Promise<UnsubscribeFunc> =>
hass.connection.subscribeMessage( hass.connection.subscribeMessage(
(message: any) => callbackFunction(message), (message: any) => callbackFunction(message),
{ {
type: "zwave_js/subscribe_heal_network_progress", type: "zwave_js/subscribe_rebuild_routes_progress",
entry_id, entry_id,
} }
); );

View File

@ -15,7 +15,7 @@ import {
} from "../../../../../../data/zwave_js"; } from "../../../../../../data/zwave_js";
import { showConfirmationDialog } from "../../../../../../dialogs/generic/show-dialog-box"; import { showConfirmationDialog } from "../../../../../../dialogs/generic/show-dialog-box";
import type { HomeAssistant } from "../../../../../../types"; import type { HomeAssistant } from "../../../../../../types";
import { showZWaveJSHealNodeDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-heal-node"; import { showZWaveJSRebuildNodeRoutesDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-rebuild-node-routes";
import { showZWaveJSNodeStatisticsDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-node-statistics"; import { showZWaveJSNodeStatisticsDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-node-statistics";
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 { 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";
@ -69,10 +69,12 @@ export const getZwaveDeviceActions = async (
}), }),
}, },
{ {
label: hass.localize("ui.panel.config.zwave_js.device_info.heal_node"), label: hass.localize(
"ui.panel.config.zwave_js.device_info.rebuild_routes"
),
icon: mdiHospitalBox, icon: mdiHospitalBox,
action: () => action: () =>
showZWaveJSHealNodeDialog(el, { showZWaveJSRebuildNodeRoutesDialog(el, {
device, device,
}), }),
}, },

View File

@ -8,18 +8,18 @@ import { fireEvent } from "../../../../../common/dom/fire_event";
import { createCloseHeading } from "../../../../../components/ha-dialog"; import { createCloseHeading } from "../../../../../components/ha-dialog";
import { import {
fetchZwaveNetworkStatus, fetchZwaveNetworkStatus,
healZwaveNetwork, rebuildZwaveNetworkRoutes,
stopHealZwaveNetwork, stopRebuildingZwaveNetworkRoutes,
subscribeHealZwaveNetworkProgress, subscribeRebuildZwaveNetworkRoutesProgress,
ZWaveJSHealNetworkStatusMessage, ZWaveJSRebuildRoutesStatusMessage,
ZWaveJSNetwork, ZWaveJSNetwork,
} from "../../../../../data/zwave_js"; } from "../../../../../data/zwave_js";
import { haStyleDialog } from "../../../../../resources/styles"; import { haStyleDialog } from "../../../../../resources/styles";
import { HomeAssistant } from "../../../../../types"; import { HomeAssistant } from "../../../../../types";
import { ZWaveJSHealNetworkDialogParams } from "./show-dialog-zwave_js-heal-network"; import { ZWaveJSRebuildNetworkRoutesDialogParams } from "./show-dialog-zwave_js-rebuild-network-routes";
@customElement("dialog-zwave_js-heal-network") @customElement("dialog-zwave_js-rebuild-network-routes")
class DialogZWaveJSHealNetwork extends LitElement { class DialogZWaveJSRebuildNetworkRoutes extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@state() private entry_id?: string; @state() private entry_id?: string;
@ -34,7 +34,7 @@ class DialogZWaveJSHealNetwork extends LitElement {
private _subscribed?: Promise<UnsubscribeFunc>; private _subscribed?: Promise<UnsubscribeFunc>;
public showDialog(params: ZWaveJSHealNetworkDialogParams): void { public showDialog(params: ZWaveJSRebuildNetworkRoutesDialogParams): void {
this._progress_total = 0; this._progress_total = 0;
this.entry_id = params.entry_id; this.entry_id = params.entry_id;
this._fetchData(); this._fetchData();
@ -61,7 +61,9 @@ class DialogZWaveJSHealNetwork extends LitElement {
@closed=${this.closeDialog} @closed=${this.closeDialog}
.heading=${createCloseHeading( .heading=${createCloseHeading(
this.hass, this.hass,
this.hass.localize("ui.panel.config.zwave_js.heal_network.title") this.hass.localize(
"ui.panel.config.zwave_js.rebuild_network_routes.title"
)
)} )}
> >
${!this._status ${!this._status
@ -74,7 +76,7 @@ class DialogZWaveJSHealNetwork extends LitElement {
<div class="status"> <div class="status">
<p> <p>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_network.introduction" "ui.panel.config.zwave_js.rebuild_network_routes.introduction"
)} )}
</p> </p>
</div> </div>
@ -82,13 +84,16 @@ class DialogZWaveJSHealNetwork extends LitElement {
<p> <p>
<em> <em>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_network.traffic_warning" "ui.panel.config.zwave_js.rebuild_network_routes.traffic_warning"
)} )}
</em> </em>
</p> </p>
<mwc-button slot="primaryAction" @click=${this._startHeal}> <mwc-button
slot="primaryAction"
@click=${this._startRebuildingRoutes}
>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_network.start_heal" "ui.panel.config.zwave_js.rebuild_network_routes.start_rebuilding_routes"
)} )}
</mwc-button> </mwc-button>
` `
@ -99,13 +104,13 @@ class DialogZWaveJSHealNetwork extends LitElement {
<p> <p>
<b> <b>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_network.in_progress" "ui.panel.config.zwave_js.rebuild_network_routes.in_progress"
)} )}
</b> </b>
</p> </p>
<p> <p>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_network.run_in_background" "ui.panel.config.zwave_js.rebuild_network_routes.run_in_background"
)} )}
</p> </p>
</div> </div>
@ -114,9 +119,12 @@ class DialogZWaveJSHealNetwork extends LitElement {
<mwc-linear-progress indeterminate> </mwc-linear-progress> <mwc-linear-progress indeterminate> </mwc-linear-progress>
` `
: ""} : ""}
<mwc-button slot="secondaryAction" @click=${this._stopHeal}> <mwc-button
slot="secondaryAction"
@click=${this._stopRebuildingRoutes}
>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_network.stop_heal" "ui.panel.config.zwave_js.rebuild_network_routes.stop_rebuilding_routes"
)} )}
</mwc-button> </mwc-button>
<mwc-button slot="primaryAction" @click=${this.closeDialog}> <mwc-button slot="primaryAction" @click=${this.closeDialog}>
@ -134,7 +142,7 @@ class DialogZWaveJSHealNetwork extends LitElement {
<div class="status"> <div class="status">
<p> <p>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_network.healing_failed" "ui.panel.config.zwave_js.rebuild_network_routes.rebuilding_routes_failed"
)} )}
</p> </p>
</div> </div>
@ -154,7 +162,7 @@ class DialogZWaveJSHealNetwork extends LitElement {
<div class="status"> <div class="status">
<p> <p>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_network.healing_complete" "ui.panel.config.zwave_js.rebuild_network_routes.rebuilding_routes_complete"
)} )}
</p> </p>
</div> </div>
@ -174,7 +182,7 @@ class DialogZWaveJSHealNetwork extends LitElement {
<div class="status"> <div class="status">
<p> <p>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_network.healing_cancelled" "ui.panel.config.zwave_js.rebuild_network_routes.rebuilding_routes_cancelled"
)} )}
</p> </p>
</div> </div>
@ -205,9 +213,9 @@ class DialogZWaveJSHealNetwork extends LitElement {
const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(this.hass!, { const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(this.hass!, {
entry_id: this.entry_id!, entry_id: this.entry_id!,
}); });
if (network.controller.is_heal_network_active) { if (network.controller.is_rebuilding_routes) {
this._status = "started"; this._status = "started";
this._subscribed = subscribeHealZwaveNetworkProgress( this._subscribed = subscribeRebuildZwaveNetworkRoutesProgress(
this.hass, this.hass,
this.entry_id!, this.entry_id!,
this._handleMessage.bind(this) this._handleMessage.bind(this)
@ -215,33 +223,33 @@ class DialogZWaveJSHealNetwork extends LitElement {
} }
} }
private _startHeal(): void { private _startRebuildingRoutes(): void {
if (!this.hass) { if (!this.hass) {
return; return;
} }
healZwaveNetwork(this.hass, this.entry_id!); rebuildZwaveNetworkRoutes(this.hass, this.entry_id!);
this._status = "started"; this._status = "started";
this._subscribed = subscribeHealZwaveNetworkProgress( this._subscribed = subscribeRebuildZwaveNetworkRoutesProgress(
this.hass, this.hass,
this.entry_id!, this.entry_id!,
this._handleMessage.bind(this) this._handleMessage.bind(this)
); );
} }
private _stopHeal(): void { private _stopRebuildingRoutes(): void {
if (!this.hass) { if (!this.hass) {
return; return;
} }
stopHealZwaveNetwork(this.hass, this.entry_id!); stopRebuildingZwaveNetworkRoutes(this.hass, this.entry_id!);
this._unsubscribe(); this._unsubscribe();
this._status = "cancelled"; this._status = "cancelled";
} }
private _handleMessage(message: ZWaveJSHealNetworkStatusMessage): void { private _handleMessage(message: ZWaveJSRebuildRoutesStatusMessage): void {
if (message.event === "heal network progress") { if (message.event === "rebuild routes progress") {
let finished = 0; let finished = 0;
let in_progress = 0; let in_progress = 0;
for (const status of Object.values(message.heal_node_status)) { for (const status of Object.values(message.rebuild_routes_status)) {
if (status === "pending") { if (status === "pending") {
in_progress++; in_progress++;
} }
@ -249,11 +257,11 @@ class DialogZWaveJSHealNetwork extends LitElement {
finished++; finished++;
} }
} }
this._progress_total = Object.keys(message.heal_node_status).length; this._progress_total = Object.keys(message.rebuild_routes_status).length;
this._progress_finished = finished / this._progress_total; this._progress_finished = finished / this._progress_total;
this._progress_in_progress = in_progress / this._progress_total; this._progress_in_progress = in_progress / this._progress_total;
} }
if (message.event === "heal network done") { if (message.event === "rebuild routes done") {
this._unsubscribe(); this._unsubscribe();
this._status = "finished"; this._status = "finished";
} }
@ -306,6 +314,6 @@ class DialogZWaveJSHealNetwork extends LitElement {
declare global { declare global {
interface HTMLElementTagNameMap { interface HTMLElementTagNameMap {
"dialog-zwave_js-heal-network": DialogZWaveJSHealNetwork; "dialog-zwave_js-rebuild-network-routes": DialogZWaveJSRebuildNetworkRoutes;
} }
} }

View File

@ -11,15 +11,15 @@ import {
} from "../../../../../data/device_registry"; } from "../../../../../data/device_registry";
import { import {
fetchZwaveNetworkStatus, fetchZwaveNetworkStatus,
healZwaveNode, rebuildZwaveNodeRoutes,
ZWaveJSNetwork, ZWaveJSNetwork,
} from "../../../../../data/zwave_js"; } from "../../../../../data/zwave_js";
import { haStyleDialog } from "../../../../../resources/styles"; import { haStyleDialog } from "../../../../../resources/styles";
import { HomeAssistant } from "../../../../../types"; import { HomeAssistant } from "../../../../../types";
import { ZWaveJSHealNodeDialogParams } from "./show-dialog-zwave_js-heal-node"; import { ZWaveJSRebuildNodeRoutesDialogParams } from "./show-dialog-zwave_js-rebuild-node-routes";
@customElement("dialog-zwave_js-heal-node") @customElement("dialog-zwave_js-rebuild-node-routes")
class DialogZWaveJSHealNode extends LitElement { class DialogZWaveJSRebuildNodeRoutes extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@state() private device?: DeviceRegistryEntry; @state() private device?: DeviceRegistryEntry;
@ -28,7 +28,7 @@ class DialogZWaveJSHealNode extends LitElement {
@state() private _error?: string; @state() private _error?: string;
public showDialog(params: ZWaveJSHealNodeDialogParams): void { public showDialog(params: ZWaveJSRebuildNodeRoutesDialogParams): void {
this.device = params.device; this.device = params.device;
this._fetchData(); this._fetchData();
} }
@ -52,7 +52,9 @@ class DialogZWaveJSHealNode extends LitElement {
@closed=${this.closeDialog} @closed=${this.closeDialog}
.heading=${createCloseHeading( .heading=${createCloseHeading(
this.hass, this.hass,
this.hass.localize("ui.panel.config.zwave_js.heal_node.title") this.hass.localize(
"ui.panel.config.zwave_js.rebuild_node_routes.title"
)
)} )}
> >
${!this._status ${!this._status
@ -65,7 +67,7 @@ class DialogZWaveJSHealNode extends LitElement {
<div class="status"> <div class="status">
<p> <p>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_node.introduction", "ui.panel.config.zwave_js.rebuild_node_routes.introduction",
{ {
device: html`<em device: html`<em
>${computeDeviceName(this.device, this.hass!)}</em >${computeDeviceName(this.device, this.hass!)}</em
@ -78,13 +80,16 @@ class DialogZWaveJSHealNode extends LitElement {
<p> <p>
<em> <em>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_node.traffic_warning" "ui.panel.config.zwave_js.rebuild_node_routes.traffic_warning"
)} )}
</em> </em>
</p> </p>
<mwc-button slot="primaryAction" @click=${this._startHeal}> <mwc-button
slot="primaryAction"
@click=${this._startRebuildingRoutes}
>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_node.start_heal" "ui.panel.config.zwave_js.rebuild_node_routes.start_rebuilding_routes"
)} )}
</mwc-button> </mwc-button>
` `
@ -96,7 +101,7 @@ class DialogZWaveJSHealNode extends LitElement {
<div class="status"> <div class="status">
<p> <p>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_node.in_progress", "ui.panel.config.zwave_js.rebuild_node_routes.in_progress",
{ {
device: html`<em device: html`<em
>${computeDeviceName(this.device, this.hass!)}</em >${computeDeviceName(this.device, this.hass!)}</em
@ -121,7 +126,7 @@ class DialogZWaveJSHealNode extends LitElement {
<div class="status"> <div class="status">
<p> <p>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_node.healing_failed", "ui.panel.config.zwave_js.rebuild_node_routes.rebuilding_routes_failed",
{ {
device: html`<em device: html`<em
>${computeDeviceName(this.device, this.hass!)}</em >${computeDeviceName(this.device, this.hass!)}</em
@ -134,7 +139,7 @@ class DialogZWaveJSHealNode extends LitElement {
? html` <em>${this._error}</em> ` ? html` <em>${this._error}</em> `
: ` : `
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_node.healing_failed_check_logs" "ui.panel.config.zwave_js.rebuild_node_routes.rebuilding_routes_failed_check_logs"
)} )}
`} `}
</p> </p>
@ -155,7 +160,7 @@ class DialogZWaveJSHealNode extends LitElement {
<div class="status"> <div class="status">
<p> <p>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_node.healing_complete", "ui.panel.config.zwave_js.rebuild_node_routes.rebuilding_routes_complete",
{ {
device: html`<em device: html`<em
>${computeDeviceName(this.device, this.hass!)}</em >${computeDeviceName(this.device, this.hass!)}</em
@ -170,7 +175,7 @@ class DialogZWaveJSHealNode extends LitElement {
</mwc-button> </mwc-button>
` `
: ``} : ``}
${this._status === "network-healing" ${this._status === "rebuilding-routes"
? html` ? html`
<div class="flex-container"> <div class="flex-container">
<ha-svg-icon <ha-svg-icon
@ -180,7 +185,7 @@ class DialogZWaveJSHealNode extends LitElement {
<div class="status"> <div class="status">
<p> <p>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.heal_node.network_heal_in_progress" "ui.panel.config.zwave_js.rebuild_node_routes.routes_rebuild_in_progress"
)} )}
</p> </p>
</div> </div>
@ -201,18 +206,18 @@ class DialogZWaveJSHealNode extends LitElement {
const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(this.hass!, { const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(this.hass!, {
device_id: this.device!.id, device_id: this.device!.id,
}); });
if (network.controller.is_heal_network_active) { if (network.controller.is_rebuilding_routes) {
this._status = "network-healing"; this._status = "rebuilding-routes";
} }
} }
private async _startHeal(): Promise<void> { private async _startRebuildingRoutes(): Promise<void> {
if (!this.hass) { if (!this.hass) {
return; return;
} }
this._status = "started"; this._status = "started";
try { try {
this._status = (await healZwaveNode(this.hass, this.device!.id)) this._status = (await rebuildZwaveNodeRoutes(this.hass, this.device!.id))
? "finished" ? "finished"
: "failed"; : "failed";
} catch (err: any) { } catch (err: any) {
@ -258,6 +263,6 @@ class DialogZWaveJSHealNode extends LitElement {
declare global { declare global {
interface HTMLElementTagNameMap { interface HTMLElementTagNameMap {
"dialog-zwave_js-heal-node": DialogZWaveJSHealNode; "dialog-zwave_js-rebuild-node-routes": DialogZWaveJSRebuildNodeRoutes;
} }
} }

View File

@ -1,19 +0,0 @@
import { fireEvent } from "../../../../../common/dom/fire_event";
export interface ZWaveJSHealNetworkDialogParams {
entry_id: string;
}
export const loadHealNetworkDialog = () =>
import("./dialog-zwave_js-heal-network");
export const showZWaveJSHealNetworkDialog = (
element: HTMLElement,
healNetworkDialogParams: ZWaveJSHealNetworkDialogParams
): void => {
fireEvent(element, "show-dialog", {
dialogTag: "dialog-zwave_js-heal-network",
dialogImport: loadHealNetworkDialog,
dialogParams: healNetworkDialogParams,
});
};

View File

@ -1,19 +0,0 @@
import { fireEvent } from "../../../../../common/dom/fire_event";
import { DeviceRegistryEntry } from "../../../../../data/device_registry";
export interface ZWaveJSHealNodeDialogParams {
device: DeviceRegistryEntry;
}
export const loadHealNodeDialog = () => import("./dialog-zwave_js-heal-node");
export const showZWaveJSHealNodeDialog = (
element: HTMLElement,
healNodeDialogParams: ZWaveJSHealNodeDialogParams
): void => {
fireEvent(element, "show-dialog", {
dialogTag: "dialog-zwave_js-heal-node",
dialogImport: loadHealNodeDialog,
dialogParams: healNodeDialogParams,
});
};

View File

@ -0,0 +1,19 @@
import { fireEvent } from "../../../../../common/dom/fire_event";
export interface ZWaveJSRebuildNetworkRoutesDialogParams {
entry_id: string;
}
export const loadRebuildNetworkRoutesDialog = () =>
import("./dialog-zwave_js-rebuild-network-routes");
export const showZWaveJSRebuildNetworkRoutesDialog = (
element: HTMLElement,
rebuildNetworkRoutesDialogParams: ZWaveJSRebuildNetworkRoutesDialogParams
): void => {
fireEvent(element, "show-dialog", {
dialogTag: "dialog-zwave_js-rebuild-network-routes",
dialogImport: loadRebuildNetworkRoutesDialog,
dialogParams: rebuildNetworkRoutesDialogParams,
});
};

View File

@ -0,0 +1,20 @@
import { fireEvent } from "../../../../../common/dom/fire_event";
import { DeviceRegistryEntry } from "../../../../../data/device_registry";
export interface ZWaveJSRebuildNodeRoutesDialogParams {
device: DeviceRegistryEntry;
}
export const loadRebuildNodeRoutesDialog = () =>
import("./dialog-zwave_js-rebuild-node-routes");
export const showZWaveJSRebuildNodeRoutesDialog = (
element: HTMLElement,
rebuildNodeRoutesDialogParams: ZWaveJSRebuildNodeRoutesDialogParams
): void => {
fireEvent(element, "show-dialog", {
dialogTag: "dialog-zwave_js-rebuild-node-routes",
dialogImport: loadRebuildNodeRoutesDialog,
dialogParams: rebuildNodeRoutesDialogParams,
});
};

View File

@ -52,7 +52,7 @@ 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";
import { showZWaveJSAddNodeDialog } from "./show-dialog-zwave_js-add-node"; import { showZWaveJSAddNodeDialog } from "./show-dialog-zwave_js-add-node";
import { showZWaveJSHealNetworkDialog } from "./show-dialog-zwave_js-heal-network"; import { showZWaveJSRebuildNetworkRoutesDialog } from "./show-dialog-zwave_js-rebuild-network-routes";
import { showZWaveJSRemoveNodeDialog } from "./show-dialog-zwave_js-remove-node"; import { showZWaveJSRemoveNodeDialog } from "./show-dialog-zwave_js-remove-node";
import { configTabs } from "./zwave_js-config-router"; import { configTabs } from "./zwave_js-config-router";
@ -430,11 +430,11 @@ class ZWaveJSConfigDashboard extends SubscribeMixin(LitElement) {
)} )}
</mwc-button> </mwc-button>
<mwc-button <mwc-button
@click=${this._healNetworkClicked} @click=${this._rebuildNetworkRoutesClicked}
.disabled=${this._status === "disconnected"} .disabled=${this._status === "disconnected"}
> >
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.common.heal_network" "ui.panel.config.zwave_js.common.rebuild_network_routes"
)} )}
</mwc-button> </mwc-button>
<mwc-button @click=${this._openOptionFlow}> <mwc-button @click=${this._openOptionFlow}>
@ -612,8 +612,8 @@ class ZWaveJSConfigDashboard extends SubscribeMixin(LitElement) {
}); });
} }
private async _healNetworkClicked() { private async _rebuildNetworkRoutesClicked() {
showZWaveJSHealNetworkDialog(this, { showZWaveJSRebuildNetworkRoutesDialog(this, {
entry_id: this.configEntryId!, entry_id: this.configEntryId!,
}); });
} }

View File

@ -3934,7 +3934,7 @@
"add_node": "Add device", "add_node": "Add device",
"remove_node": "Remove device", "remove_node": "Remove device",
"reconfigure_server": "Re-configure server", "reconfigure_server": "Re-configure server",
"heal_network": "Heal Network", "rebuild_network_routes": "Rebuild network routes",
"in_progress_inclusion_exclusion": "Z-Wave JS is searching for devices", "in_progress_inclusion_exclusion": "Z-Wave JS is searching for devices",
"cancel_inclusion_exclusion": "Stop searching" "cancel_inclusion_exclusion": "Stop searching"
}, },
@ -3994,7 +3994,7 @@
"node_ready": "Ready", "node_ready": "Ready",
"device_config": "Configure", "device_config": "Configure",
"reinterview_device": "Re-interview", "reinterview_device": "Re-interview",
"heal_node": "Heal", "rebuild_routes": "Rebuild routes",
"remove_failed": "Remove failed", "remove_failed": "Remove failed",
"update_firmware": "Update", "update_firmware": "Update",
"highest_security": "Highest security", "highest_security": "Highest security",
@ -4176,28 +4176,28 @@
"interview_failed": "The device interview failed. Additional information may be available in the logs.", "interview_failed": "The device interview failed. Additional information may be available in the logs.",
"interview_complete": "Device interview complete." "interview_complete": "Device interview complete."
}, },
"heal_network": { "rebuild_network_routes": {
"title": "Heal your Z-Wave network", "title": "Rebuild routes for your Z-Wave network",
"introduction": "Start a network heal on your Z-Wave network. A network heal will cause all devices to re-calculate their routes back to the controller and is recommended if you have recently moved devices or your controller.", "introduction": "Start rebuilding routes on your Z-Wave network. Rebuilding routes will cause all devices to re-calculate their routes back to the controller and is recommended if you have recently moved devices or your controller.",
"traffic_warning": "The healing process generates a large amount of traffic on the Z-Wave network. This may cause devices to respond slowly (or not at all) while the heal is in progress.", "traffic_warning": "The rebuilding process generates a large amount of traffic on the Z-Wave network. This may cause devices to respond slowly (or not at all) while the rebuild is in progress.",
"start_heal": "Start healing", "start_rebuilding_routes": "Start rebuilding routes",
"in_progress": "Network healing is in progress. This will take some time.", "in_progress": "Rebuild of network routes is in progress. This will take some time.",
"run_in_background": "You can close this dialog and the network healing will continue in the background.", "run_in_background": "You can close this dialog and the rebuild of network routes will continue in the background.",
"stop_heal": "Stop Healing", "stop_rebuilding_routes": "Stop rebuilding routes",
"healing_complete": "Network healing is complete.", "rebuilding_routes_complete": "Routes have been rebuilt.",
"healing_failed": "Healing failed. Additional information may be available in the logs.", "rebuilding_routes_failed": "Route rebuilding failed. Additional information may be available in the logs.",
"healing_cancelled": "Network healing has been cancelled." "rebuilding_routes_cancelled": "Rebuilding network routes has been cancelled."
}, },
"heal_node": { "rebuild_node_routes": {
"title": "Heal a Z-Wave device", "title": "Rebuild routes for a Z-Wave device",
"introduction": "Tell {device} to update its routes back to the controller. This can help with communication issues if you have recently moved the device or your controller.", "introduction": "Tell {device} to update its routes back to the controller. This can help with communication issues if you have recently moved the device or your controller.",
"traffic_warning": "The healing process generates a large amount of traffic on the Z-Wave network. This may cause devices to respond slowly (or not at all) while the heal is in progress.", "traffic_warning": "The route rebuilding process generates a large amount of traffic on the Z-Wave network. This may cause devices to respond slowly (or not at all) while the rebuilding is in progress.",
"start_heal": "Heal Device", "start_rebuilding_routes": "Rebuild Routes for Device",
"healing_failed": "{device} could not be healed.", "rebuilding_routes_failed": "{device} routes could not be rebuild.",
"healing_failed_check_logs": "Additional information may be available in the logs.", "rebuilding_routes_failed_check_logs": "Additional information may be available in the logs.",
"healing_complete": "{device} has been healed.", "rebuilding_routes_complete": "{device} routes have been rebuilt.",
"in_progress": "{device} healing is in progress.", "in_progress": "{device} routes rebuild is in progress.",
"network_heal_in_progress": "A Z-Wave network heal is already in progress. Please wait for it to finish before healing an individual device." "routes_rebuild_in_progress": "A Z-Wave routes rebuild is already in progress. Please wait for it to finish before rebuilding routes for an individual device."
}, },
"update_firmware": { "update_firmware": {
"title": "Update device firmware", "title": "Update device firmware",