mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +00:00
Update zwave_js/network_status WS API (#12735)
This commit is contained in:
parent
19d014307a
commit
7358faf88e
@ -301,12 +301,23 @@ export const migrateZwave = (
|
|||||||
|
|
||||||
export const fetchZwaveNetworkStatus = (
|
export const fetchZwaveNetworkStatus = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entry_id: string
|
device_or_entry_id: {
|
||||||
): Promise<ZWaveJSNetwork> =>
|
device_id?: string;
|
||||||
hass.callWS({
|
entry_id?: string;
|
||||||
|
}
|
||||||
|
): Promise<ZWaveJSNetwork> => {
|
||||||
|
if (device_or_entry_id.device_id && device_or_entry_id.entry_id) {
|
||||||
|
throw new Error("Only one of device or entry ID should be supplied.");
|
||||||
|
}
|
||||||
|
if (!device_or_entry_id.device_id && !device_or_entry_id.entry_id) {
|
||||||
|
throw new Error("Either device or entry ID should be supplied.");
|
||||||
|
}
|
||||||
|
return hass.callWS({
|
||||||
type: "zwave_js/network_status",
|
type: "zwave_js/network_status",
|
||||||
entry_id,
|
device_id: device_or_entry_id.device_id,
|
||||||
|
entry_id: device_or_entry_id.entry_id,
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const fetchZwaveDataCollectionStatus = (
|
export const fetchZwaveDataCollectionStatus = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
@ -52,7 +52,6 @@ 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.heal_node"),
|
||||||
action: () =>
|
action: () =>
|
||||||
showZWaveJSHealNodeDialog(el, {
|
showZWaveJSHealNodeDialog(el, {
|
||||||
entry_id: entryId,
|
|
||||||
device: device,
|
device: device,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -202,10 +202,9 @@ class DialogZWaveJSHealNetwork extends LitElement {
|
|||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(
|
const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(this.hass!, {
|
||||||
this.hass!,
|
entry_id: this.entry_id!,
|
||||||
this.entry_id!
|
});
|
||||||
);
|
|
||||||
if (network.controller.is_heal_network_active) {
|
if (network.controller.is_heal_network_active) {
|
||||||
this._status = "started";
|
this._status = "started";
|
||||||
this._subscribed = subscribeHealZwaveNetworkProgress(
|
this._subscribed = subscribeHealZwaveNetworkProgress(
|
||||||
|
@ -22,8 +22,6 @@ import { ZWaveJSHealNodeDialogParams } from "./show-dialog-zwave_js-heal-node";
|
|||||||
class DialogZWaveJSHealNode extends LitElement {
|
class DialogZWaveJSHealNode extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@state() private entry_id?: string;
|
|
||||||
|
|
||||||
@state() private device?: DeviceRegistryEntry;
|
@state() private device?: DeviceRegistryEntry;
|
||||||
|
|
||||||
@state() private _status?: string;
|
@state() private _status?: string;
|
||||||
@ -31,13 +29,11 @@ class DialogZWaveJSHealNode extends LitElement {
|
|||||||
@state() private _error?: string;
|
@state() private _error?: string;
|
||||||
|
|
||||||
public showDialog(params: ZWaveJSHealNodeDialogParams): void {
|
public showDialog(params: ZWaveJSHealNodeDialogParams): void {
|
||||||
this.entry_id = params.entry_id;
|
|
||||||
this.device = params.device;
|
this.device = params.device;
|
||||||
this._fetchData();
|
this._fetchData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeDialog(): void {
|
public closeDialog(): void {
|
||||||
this.entry_id = undefined;
|
|
||||||
this._status = undefined;
|
this._status = undefined;
|
||||||
this.device = undefined;
|
this.device = undefined;
|
||||||
this._error = undefined;
|
this._error = undefined;
|
||||||
@ -46,7 +42,7 @@ class DialogZWaveJSHealNode extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
if (!this.entry_id || !this.device) {
|
if (!this.device) {
|
||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,10 +198,9 @@ class DialogZWaveJSHealNode extends LitElement {
|
|||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(
|
const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(this.hass!, {
|
||||||
this.hass!,
|
device_id: this.device!.id,
|
||||||
this.entry_id!
|
});
|
||||||
);
|
|
||||||
if (network.controller.is_heal_network_active) {
|
if (network.controller.is_heal_network_active) {
|
||||||
this._status = "network-healing";
|
this._status = "network-healing";
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ import { fireEvent } from "../../../../../common/dom/fire_event";
|
|||||||
import { DeviceRegistryEntry } from "../../../../../data/device_registry";
|
import { DeviceRegistryEntry } from "../../../../../data/device_registry";
|
||||||
|
|
||||||
export interface ZWaveJSHealNodeDialogParams {
|
export interface ZWaveJSHealNodeDialogParams {
|
||||||
entry_id: string;
|
|
||||||
device: DeviceRegistryEntry;
|
device: DeviceRegistryEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ class ZWaveJSConfigDashboard extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
const [network, dataCollectionStatus, provisioningEntries] =
|
const [network, dataCollectionStatus, provisioningEntries] =
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
fetchZwaveNetworkStatus(this.hass!, this.configEntryId),
|
fetchZwaveNetworkStatus(this.hass!, { entry_id: this.configEntryId }),
|
||||||
fetchZwaveDataCollectionStatus(this.hass!, this.configEntryId),
|
fetchZwaveDataCollectionStatus(this.hass!, this.configEntryId),
|
||||||
fetchZwaveProvisioningEntries(this.hass!, this.configEntryId),
|
fetchZwaveProvisioningEntries(this.hass!, this.configEntryId),
|
||||||
]);
|
]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user