mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Re-add target option to zwave-js firmware upload (#15517)
This commit is contained in:
parent
19d721f193
commit
f786539f15
@ -757,10 +757,14 @@ export const fetchZwaveNodeFirmwareUpdateCapabilities = (
|
|||||||
export const uploadFirmwareAndBeginUpdate = async (
|
export const uploadFirmwareAndBeginUpdate = async (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_id: string,
|
device_id: string,
|
||||||
file: File
|
file: File,
|
||||||
|
target?: number
|
||||||
) => {
|
) => {
|
||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
fd.append("file", file);
|
fd.append("file", file);
|
||||||
|
if (target !== undefined) {
|
||||||
|
fd.append("target", target.toString());
|
||||||
|
}
|
||||||
const resp = await hass.fetchWithAuth(
|
const resp = await hass.fetchWithAuth(
|
||||||
`/api/zwave_js/firmware/upload/${device_id}`,
|
`/api/zwave_js/firmware/upload/${device_id}`,
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,15 @@ import {
|
|||||||
showAlertDialog,
|
showAlertDialog,
|
||||||
showConfirmationDialog,
|
showConfirmationDialog,
|
||||||
} from "../../../../../dialogs/generic/show-dialog-box";
|
} from "../../../../../dialogs/generic/show-dialog-box";
|
||||||
|
import { HaFormSchema } from "../../../../../components/ha-form/types";
|
||||||
|
|
||||||
|
const firmwareTargetSchema: HaFormSchema[] = [
|
||||||
|
{
|
||||||
|
name: "firmware_target",
|
||||||
|
type: "integer",
|
||||||
|
valueMin: 0,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
@customElement("dialog-zwave_js-update-firmware-node")
|
@customElement("dialog-zwave_js-update-firmware-node")
|
||||||
class DialogZWaveJSUpdateFirmwareNode extends LitElement {
|
class DialogZWaveJSUpdateFirmwareNode extends LitElement {
|
||||||
@ -59,6 +68,8 @@ class DialogZWaveJSUpdateFirmwareNode extends LitElement {
|
|||||||
|
|
||||||
@state() private _nodeStatus?: ZWaveJSNodeStatus;
|
@state() private _nodeStatus?: ZWaveJSNodeStatus;
|
||||||
|
|
||||||
|
@state() private _firmwareTarget?: number;
|
||||||
|
|
||||||
private _subscribedNodeStatus?: Promise<UnsubscribeFunc>;
|
private _subscribedNodeStatus?: Promise<UnsubscribeFunc>;
|
||||||
|
|
||||||
private _subscribedNodeFirmwareUpdate?: Promise<UnsubscribeFunc>;
|
private _subscribedNodeFirmwareUpdate?: Promise<UnsubscribeFunc>;
|
||||||
@ -80,6 +91,7 @@ class DialogZWaveJSUpdateFirmwareNode extends LitElement {
|
|||||||
this._updateFinishedMessage = undefined;
|
this._updateFinishedMessage = undefined;
|
||||||
this._firmwareFile = undefined;
|
this._firmwareFile = undefined;
|
||||||
this._nodeStatus = undefined;
|
this._nodeStatus = undefined;
|
||||||
|
this._firmwareTarget = undefined;
|
||||||
this._uploading = this._updateInProgress = false;
|
this._uploading = this._updateInProgress = false;
|
||||||
|
|
||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
@ -104,6 +116,19 @@ class DialogZWaveJSUpdateFirmwareNode extends LitElement {
|
|||||||
)}
|
)}
|
||||||
@file-picked=${this._uploadFile}
|
@file-picked=${this._uploadFile}
|
||||||
></ha-file-upload>
|
></ha-file-upload>
|
||||||
|
${this._nodeStatus.is_controller_node
|
||||||
|
? html``
|
||||||
|
: html`<p>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.zwave_js.update_firmware.firmware_target_intro"
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
<ha-form
|
||||||
|
.hass=${this.hass}
|
||||||
|
.data=${{ firmware_target: this._firmwareTarget }}
|
||||||
|
.schema=${firmwareTargetSchema}
|
||||||
|
@value-changed=${this._firmwareTargetChanged}
|
||||||
|
></ha-form>`}
|
||||||
<mwc-button
|
<mwc-button
|
||||||
slot="primaryAction"
|
slot="primaryAction"
|
||||||
@click=${this._beginFirmwareUpdate}
|
@click=${this._beginFirmwareUpdate}
|
||||||
@ -283,7 +308,8 @@ class DialogZWaveJSUpdateFirmwareNode extends LitElement {
|
|||||||
await uploadFirmwareAndBeginUpdate(
|
await uploadFirmwareAndBeginUpdate(
|
||||||
this.hass,
|
this.hass,
|
||||||
this.device!.id,
|
this.device!.id,
|
||||||
this._firmwareFile!
|
this._firmwareFile!,
|
||||||
|
this._firmwareTarget
|
||||||
);
|
);
|
||||||
this._updateInProgress = true;
|
this._updateInProgress = true;
|
||||||
this._uploading = false;
|
this._uploading = false;
|
||||||
@ -388,6 +414,10 @@ class DialogZWaveJSUpdateFirmwareNode extends LitElement {
|
|||||||
this._subscribedNodeFirmwareUpdate = undefined;
|
this._subscribedNodeFirmwareUpdate = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _firmwareTargetChanged(ev) {
|
||||||
|
this._firmwareTarget = ev.detail.value.firmware_target;
|
||||||
|
}
|
||||||
|
|
||||||
private async _uploadFile(ev) {
|
private async _uploadFile(ev) {
|
||||||
this._firmwareFile = ev.detail.files[0];
|
this._firmwareFile = ev.detail.files[0];
|
||||||
}
|
}
|
||||||
|
@ -3691,6 +3691,8 @@
|
|||||||
"warning_controller": "WARNING: Firmware updates can brick your controller if you do not use the right firmware files, or if you attempt to stop the firmware update before it completes. The Home Assistant and Z-Wave JS teams do not take any responsibility for any damages to your controller as a result of the firmware update and will not be able to help you if you brick your controller. Would you still like to continue?",
|
"warning_controller": "WARNING: Firmware updates can brick your controller if you do not use the right firmware files, or if you attempt to stop the firmware update before it completes. The Home Assistant and Z-Wave JS teams do not take any responsibility for any damages to your controller as a result of the firmware update and will not be able to help you if you brick your controller. Would you still like to continue?",
|
||||||
"introduction": "Select the firmware file you would like to use to update {device}.",
|
"introduction": "Select the firmware file you would like to use to update {device}.",
|
||||||
"introduction_controller": "Select the firmware file you would like to use to update {device}. Note that once you start a firmware update, you MUST wait for the update to complete.",
|
"introduction_controller": "Select the firmware file you would like to use to update {device}. Note that once you start a firmware update, you MUST wait for the update to complete.",
|
||||||
|
"firmware_target_intro": "Select the firmware target (0 for the Z-Wave chip, ≥1 for other chips if they exist) for this update.",
|
||||||
|
"firmware_target": "Firmware Target (chip)",
|
||||||
"upload_firmware": "Upload Firmware",
|
"upload_firmware": "Upload Firmware",
|
||||||
"upload_failed": "Upload Failed",
|
"upload_failed": "Upload Failed",
|
||||||
"begin_update": "Begin Firmware Update",
|
"begin_update": "Begin Firmware Update",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user