diff --git a/README.md b/README.md index c96fd1f..113bb97 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Manifest definition: { "name": "ESPHome", "version": "2021.10.3", + "home_assistant_domain": "esphome", "builds": [ { "chipFamily": "ESP32", diff --git a/index.html b/index.html index 9d595e5..c291b72 100644 --- a/index.html +++ b/index.html @@ -266,6 +266,7 @@ { "name": "ESPHome", "version": "2021.11.0", + "home_assistant_domain": "esphome", "builds": [ { "chipFamily": "ESP32", @@ -291,6 +292,11 @@ where it should be installed. Part paths are resolved relative to the path of the manifest, but can also be URLs to other hosts.

+

+ If your firmware is supported by Home Assistant, you can add the + optional key home_assistant_domain. If present, ESP Web + Tools will link the user to add this device to Home Assistant. +

Wi-Fi provisioning

ESP Web Tools has support for the diff --git a/src/const.ts b/src/const.ts index 7744e14..b9eb4d1 100644 --- a/src/const.ts +++ b/src/const.ts @@ -15,6 +15,7 @@ export interface Build { export interface Manifest { name: string; version: string; + home_assistant_domain?: string; builds: Build[]; } diff --git a/src/install-dialog.ts b/src/install-dialog.ts index 73a667e..04250e8 100644 --- a/src/install-dialog.ts +++ b/src/install-dialog.ts @@ -61,11 +61,6 @@ class EwtInstallDialog extends LitElement { @state() private _busy = false; - private _progressFeedback?: { - resolve: (_: unknown) => void; - reject: () => void; - }; - protected render() { if (!this.port) { return html``; @@ -180,7 +175,21 @@ class EwtInstallDialog extends LitElement { class="has-button" target="_blank" > - + + + + `} + ${!this._manifest.home_assistant_domain || + this._client!.state !== ImprovSerialCurrentState.PROVISIONED + ? "" + : html` +

+ +
`} @@ -245,29 +254,53 @@ class EwtInstallDialog extends LitElement { this._client!.state === ImprovSerialCurrentState.PROVISIONED ) { heading = undefined; + const showSetupLinks = + !this._wasProvisioned && + (this._client!.nextUrl !== undefined || + "home_assistant_domain" in this._manifest); + hideActions = showSetupLinks; content = html` ${messageTemplate(OK_ICON, "Device connected to the network!")} - ${!this._wasProvisioned && this._client!.nextUrl !== undefined + ${showSetupLinks ? html` - { - this._state = "DASHBOARD"; - }} - > - - - { - this._state = "DASHBOARD"; - this._installState = undefined; - }} - > +
+
+ { + this._state = "DASHBOARD"; + }} + > + + +
+ ${!this._manifest.home_assistant_domain + ? "" + : html` +
+ + + +
+ `} +
+ { + this._state = "DASHBOARD"; + this._installState = undefined; + }} + > +
+
` : html`