mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 14:56:37 +00:00
Fix zwavejs provisioned view (#10809)
This commit is contained in:
parent
1916c179b4
commit
f3104d3c93
@ -208,11 +208,11 @@ export const enum NodeStatus {
|
|||||||
export interface ZwaveJSProvisioningEntry {
|
export interface ZwaveJSProvisioningEntry {
|
||||||
/** The device specific key (DSK) in the form aaaaa-bbbbb-ccccc-ddddd-eeeee-fffff-11111-22222 */
|
/** The device specific key (DSK) in the form aaaaa-bbbbb-ccccc-ddddd-eeeee-fffff-11111-22222 */
|
||||||
dsk: string;
|
dsk: string;
|
||||||
securityClasses: SecurityClass[];
|
security_classes: SecurityClass[];
|
||||||
/**
|
additional_properties: {
|
||||||
* Additional properties to be stored in this provisioning entry, e.g. the device ID from a scanned QR code
|
nodeId?: number;
|
||||||
*/
|
|
||||||
[prop: string]: any;
|
[prop: string]: any;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RequestedGrant {
|
export interface RequestedGrant {
|
||||||
@ -278,7 +278,7 @@ export const setZwaveDataCollectionPreference = (
|
|||||||
export const fetchZwaveProvisioningEntries = (
|
export const fetchZwaveProvisioningEntries = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entry_id: string
|
entry_id: string
|
||||||
): Promise<any> =>
|
): Promise<ZwaveJSProvisioningEntry[]> =>
|
||||||
hass.callWS({
|
hass.callWS({
|
||||||
type: "zwave_js/get_provisioning_entries",
|
type: "zwave_js/get_provisioning_entries",
|
||||||
entry_id,
|
entry_id,
|
||||||
|
@ -45,6 +45,8 @@ export interface ZWaveJSAddNodeDevice {
|
|||||||
class DialogZWaveJSAddNode extends LitElement {
|
class DialogZWaveJSAddNode extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
|
@state() private _params?: ZWaveJSAddNodeDialogParams;
|
||||||
|
|
||||||
@state() private _entryId?: string;
|
@state() private _entryId?: string;
|
||||||
|
|
||||||
@state() private _status?:
|
@state() private _status?:
|
||||||
@ -91,6 +93,7 @@ class DialogZWaveJSAddNode extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async showDialog(params: ZWaveJSAddNodeDialogParams): Promise<void> {
|
public async showDialog(params: ZWaveJSAddNodeDialogParams): Promise<void> {
|
||||||
|
this._params = params;
|
||||||
this._entryId = params.entry_id;
|
this._entryId = params.entry_id;
|
||||||
this._status = "loading";
|
this._status = "loading";
|
||||||
this._checkSmartStartSupport();
|
this._checkSmartStartSupport();
|
||||||
@ -562,6 +565,9 @@ class DialogZWaveJSAddNode extends LitElement {
|
|||||||
provisioningInfo
|
provisioningInfo
|
||||||
);
|
);
|
||||||
this._status = "provisioned";
|
this._status = "provisioned";
|
||||||
|
if (this._params?.addedCallback) {
|
||||||
|
this._params.addedCallback();
|
||||||
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
this._error = err.message;
|
this._error = err.message;
|
||||||
this._status = "failed";
|
this._status = "failed";
|
||||||
@ -693,6 +699,9 @@ class DialogZWaveJSAddNode extends LitElement {
|
|||||||
if (message.event === "interview completed") {
|
if (message.event === "interview completed") {
|
||||||
this._unsubscribe();
|
this._unsubscribe();
|
||||||
this._status = "finished";
|
this._status = "finished";
|
||||||
|
if (this._params?.addedCallback) {
|
||||||
|
this._params.addedCallback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.event === "interview stage completed") {
|
if (message.event === "interview stage completed") {
|
||||||
|
@ -2,6 +2,7 @@ import { fireEvent } from "../../../../../common/dom/fire_event";
|
|||||||
|
|
||||||
export interface ZWaveJSAddNodeDialogParams {
|
export interface ZWaveJSAddNodeDialogParams {
|
||||||
entry_id: string;
|
entry_id: string;
|
||||||
|
addedCallback?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadAddNodeDialog = () => import("./dialog-zwave_js-add-node");
|
export const loadAddNodeDialog = () => import("./dialog-zwave_js-add-node");
|
||||||
|
@ -411,6 +411,7 @@ class ZWaveJSConfigDashboard extends LitElement {
|
|||||||
private async _addNodeClicked() {
|
private async _addNodeClicked() {
|
||||||
showZWaveJSAddNodeDialog(this, {
|
showZWaveJSAddNodeDialog(this, {
|
||||||
entry_id: this.configEntryId!,
|
entry_id: this.configEntryId!,
|
||||||
|
addedCallback: () => this._fetchData(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { mdiDelete } from "@mdi/js";
|
import { mdiCheckCircle, mdiCloseCircleOutline, mdiDelete } from "@mdi/js";
|
||||||
import { html, LitElement } from "lit";
|
import { html, LitElement } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
@ -42,17 +42,42 @@ class ZWaveJSProvisioned extends LitElement {
|
|||||||
|
|
||||||
private _columns = memoizeOne(
|
private _columns = memoizeOne(
|
||||||
(narrow: boolean): DataTableColumnContainer => ({
|
(narrow: boolean): DataTableColumnContainer => ({
|
||||||
|
included: {
|
||||||
|
title: this.hass.localize(
|
||||||
|
"ui.panel.config.zwave_js.provisioned.included"
|
||||||
|
),
|
||||||
|
type: "icon",
|
||||||
|
width: "100px",
|
||||||
|
template: (_info, provisioningEntry: any) =>
|
||||||
|
provisioningEntry.additional_properties.nodeId
|
||||||
|
? html`
|
||||||
|
<ha-svg-icon
|
||||||
|
.label=${this.hass.localize(
|
||||||
|
"ui.panel.config.zwave_js.provisioned.included"
|
||||||
|
)}
|
||||||
|
.path=${mdiCheckCircle}
|
||||||
|
></ha-svg-icon>
|
||||||
|
`
|
||||||
|
: html`
|
||||||
|
<ha-svg-icon
|
||||||
|
.label=${this.hass.localize(
|
||||||
|
"ui.panel.config.zwave_js.provisioned.not_included"
|
||||||
|
)}
|
||||||
|
.path=${mdiCloseCircleOutline}
|
||||||
|
></ha-svg-icon>
|
||||||
|
`,
|
||||||
|
},
|
||||||
dsk: {
|
dsk: {
|
||||||
title: this.hass.localize("ui.panel.config.zwave_js.provisioned.dsk"),
|
title: this.hass.localize("ui.panel.config.zwave_js.provisioned.dsk"),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
grows: true,
|
grows: true,
|
||||||
},
|
},
|
||||||
securityClasses: {
|
security_classes: {
|
||||||
title: this.hass.localize(
|
title: this.hass.localize(
|
||||||
"ui.panel.config.zwave_js.provisioned.security_classes"
|
"ui.panel.config.zwave_js.provisioned.security_classes"
|
||||||
),
|
),
|
||||||
width: "15%",
|
width: "30%",
|
||||||
hidden: narrow,
|
hidden: narrow,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
@ -60,7 +85,7 @@ class ZWaveJSProvisioned extends LitElement {
|
|||||||
securityClasses
|
securityClasses
|
||||||
.map((secClass) =>
|
.map((secClass) =>
|
||||||
this.hass.localize(
|
this.hass.localize(
|
||||||
`ui.panel.config.zwave_js.security_classes.${SecurityClass[secClass]}`
|
`ui.panel.config.zwave_js.security_classes.${SecurityClass[secClass]}.title`
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.join(", "),
|
.join(", "),
|
||||||
@ -70,6 +95,7 @@ class ZWaveJSProvisioned extends LitElement {
|
|||||||
"ui.panel.config.zwave_js.provisioned.unprovison"
|
"ui.panel.config.zwave_js.provisioned.unprovison"
|
||||||
),
|
),
|
||||||
type: "icon-button",
|
type: "icon-button",
|
||||||
|
width: "100px",
|
||||||
template: (_info, provisioningEntry: any) => html`
|
template: (_info, provisioningEntry: any) => html`
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@ -97,6 +123,8 @@ class ZWaveJSProvisioned extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _unprovision = async (ev) => {
|
private _unprovision = async (ev) => {
|
||||||
|
const dsk = ev.currentTarget.provisioningEntry.dsk;
|
||||||
|
|
||||||
const confirm = await showConfirmationDialog(this, {
|
const confirm = await showConfirmationDialog(this, {
|
||||||
title: this.hass.localize(
|
title: this.hass.localize(
|
||||||
"ui.panel.config.zwave_js.provisioned.confirm_unprovision_title"
|
"ui.panel.config.zwave_js.provisioned.confirm_unprovision_title"
|
||||||
@ -113,11 +141,8 @@ class ZWaveJSProvisioned extends LitElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await unprovisionZwaveSmartStartNode(
|
await unprovisionZwaveSmartStartNode(this.hass, this.configEntryId, dsk);
|
||||||
this.hass,
|
this._fetchData();
|
||||||
this.configEntryId,
|
|
||||||
ev.currentTarget.provisioningEntry.dsk
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2897,6 +2897,8 @@
|
|||||||
"dsk": "DSK",
|
"dsk": "DSK",
|
||||||
"security_classes": "Security classes",
|
"security_classes": "Security classes",
|
||||||
"unprovison": "Unprovison",
|
"unprovison": "Unprovison",
|
||||||
|
"included": "Included",
|
||||||
|
"not_included": "Not Included",
|
||||||
"confirm_unprovision_title": "Are you sure you want to unprovision the device?",
|
"confirm_unprovision_title": "Are you sure you want to unprovision the device?",
|
||||||
"confirm_unprovision_text": "If you unprovision the device it will not be added to Home Assistant when it is powered on. If it is already added to Home Assistant, removing the provisioned device will not remove it from Home Assistant."
|
"confirm_unprovision_text": "If you unprovision the device it will not be added to Home Assistant when it is powered on. If it is already added to Home Assistant, removing the provisioned device will not remove it from Home Assistant."
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user