mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16:36 +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 = (
|
||||
hass: HomeAssistant,
|
||||
entry_id: string
|
||||
): Promise<ZWaveJSNetwork> =>
|
||||
hass.callWS({
|
||||
device_or_entry_id: {
|
||||
device_id?: string;
|
||||
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",
|
||||
entry_id,
|
||||
device_id: device_or_entry_id.device_id,
|
||||
entry_id: device_or_entry_id.entry_id,
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchZwaveDataCollectionStatus = (
|
||||
hass: HomeAssistant,
|
||||
|
@ -52,7 +52,6 @@ export const getZwaveDeviceActions = async (
|
||||
label: hass.localize("ui.panel.config.zwave_js.device_info.heal_node"),
|
||||
action: () =>
|
||||
showZWaveJSHealNodeDialog(el, {
|
||||
entry_id: entryId,
|
||||
device: device,
|
||||
}),
|
||||
},
|
||||
|
@ -202,10 +202,9 @@ class DialogZWaveJSHealNetwork extends LitElement {
|
||||
if (!this.hass) {
|
||||
return;
|
||||
}
|
||||
const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(
|
||||
this.hass!,
|
||||
this.entry_id!
|
||||
);
|
||||
const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(this.hass!, {
|
||||
entry_id: this.entry_id!,
|
||||
});
|
||||
if (network.controller.is_heal_network_active) {
|
||||
this._status = "started";
|
||||
this._subscribed = subscribeHealZwaveNetworkProgress(
|
||||
|
@ -22,8 +22,6 @@ import { ZWaveJSHealNodeDialogParams } from "./show-dialog-zwave_js-heal-node";
|
||||
class DialogZWaveJSHealNode extends LitElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@state() private entry_id?: string;
|
||||
|
||||
@state() private device?: DeviceRegistryEntry;
|
||||
|
||||
@state() private _status?: string;
|
||||
@ -31,13 +29,11 @@ class DialogZWaveJSHealNode extends LitElement {
|
||||
@state() private _error?: string;
|
||||
|
||||
public showDialog(params: ZWaveJSHealNodeDialogParams): void {
|
||||
this.entry_id = params.entry_id;
|
||||
this.device = params.device;
|
||||
this._fetchData();
|
||||
}
|
||||
|
||||
public closeDialog(): void {
|
||||
this.entry_id = undefined;
|
||||
this._status = undefined;
|
||||
this.device = undefined;
|
||||
this._error = undefined;
|
||||
@ -46,7 +42,7 @@ class DialogZWaveJSHealNode extends LitElement {
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (!this.entry_id || !this.device) {
|
||||
if (!this.device) {
|
||||
return html``;
|
||||
}
|
||||
|
||||
@ -202,10 +198,9 @@ class DialogZWaveJSHealNode extends LitElement {
|
||||
if (!this.hass) {
|
||||
return;
|
||||
}
|
||||
const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(
|
||||
this.hass!,
|
||||
this.entry_id!
|
||||
);
|
||||
const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(this.hass!, {
|
||||
device_id: this.device!.id,
|
||||
});
|
||||
if (network.controller.is_heal_network_active) {
|
||||
this._status = "network-healing";
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
import { DeviceRegistryEntry } from "../../../../../data/device_registry";
|
||||
|
||||
export interface ZWaveJSHealNodeDialogParams {
|
||||
entry_id: string;
|
||||
device: DeviceRegistryEntry;
|
||||
}
|
||||
|
||||
|
@ -573,7 +573,7 @@ class ZWaveJSConfigDashboard extends SubscribeMixin(LitElement) {
|
||||
|
||||
const [network, dataCollectionStatus, provisioningEntries] =
|
||||
await Promise.all([
|
||||
fetchZwaveNetworkStatus(this.hass!, this.configEntryId),
|
||||
fetchZwaveNetworkStatus(this.hass!, { entry_id: this.configEntryId }),
|
||||
fetchZwaveDataCollectionStatus(this.hass!, this.configEntryId),
|
||||
fetchZwaveProvisioningEntries(this.hass!, this.configEntryId),
|
||||
]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user