@@ -35,6 +35,7 @@ import { openInstallChooseDialog } from "../install-choose";
35
35
36
36
const OK_ICON = "🎉" ;
37
37
const WARNING_ICON = "👀" ;
38
+ const ESPHOME_WEB_URL = "https://web.esphome.io/?dashboard_wizard" ;
38
39
39
40
/*
40
41
Flow:
@@ -66,14 +67,15 @@ export class ESPHomeWizardDialog extends LitElement {
66
67
@state ( ) private _writeProgress ?: number ;
67
68
68
69
@state ( ) private _state :
70
+ | "ask_esphome_web"
69
71
| "basic_config"
70
72
| "connect_webserial"
71
73
| "pick_board"
72
74
| "connecting_webserial"
73
75
| "prepare_flash"
74
76
| "flashing"
75
77
| "wait_come_online"
76
- | "done" = "basic_config" ;
78
+ | "done" = supportsWebSerial ? "basic_config" : "ask_esphome_web ";
77
79
78
80
@state ( ) private _error ?: string ;
79
81
@@ -88,7 +90,9 @@ export class ESPHomeWizardDialog extends LitElement {
88
90
let content ;
89
91
let hideActions = false ;
90
92
91
- if ( this . _state === "basic_config" ) {
93
+ if ( this . _state === "ask_esphome_web" ) {
94
+ [ heading , content , hideActions ] = this . _renderAskESPHomeWeb ( ) ;
95
+ } else if ( this . _state === "basic_config" ) {
92
96
[ heading , content , hideActions ] = this . _renderBasicConfig ( ) ;
93
97
} else if ( this . _state === "pick_board" ) {
94
98
heading = "Select your ESP device" ;
@@ -161,41 +165,79 @@ export class ESPHomeWizardDialog extends LitElement {
161
165
<div class= "icon" > ${ icon } </ div>
162
166
${ label }
163
167
</ div>
164
- ${ showClose &&
165
- html `
168
+ ${ showClose
169
+ ? html `
170
+ <mwc- butto n
171
+ slot= "primaryAction"
172
+ dialogAction = "ok"
173
+ label= "Close"
174
+ > </ mwc- butto n>
175
+ `
176
+ : "" }
177
+ ` ;
178
+ }
179
+
180
+ private _renderAskESPHomeWeb ( ) : [
181
+ string | undefined ,
182
+ TemplateResult ,
183
+ boolean
184
+ ] {
185
+ const heading = "New device" ;
186
+ let hideActions = false ;
187
+ const content = html `
188
+ <div>
189
+ A device needs to be connected to a computer using a USB cable to be
190
+ added to ESPHome . Once added , ESPHome will interact with the device
191
+ wirelessly .
192
+ </ div>
193
+ <div>
194
+ ${ allowsWebSerial
195
+ ? "Your browser does not support WebSerial."
196
+ : "You are not browsing the dashboard over a secure connection (HTTPS)." }
197
+ This prevents ESPHome from being able to install this on devices
198
+ connected to this computer .
199
+ </ div>
200
+ <div>
201
+ You will still be able to install ESPHome by connecting the device to
202
+ the computer that runs the ESPHome dashboard .
203
+ </ div>
204
+ <div>
205
+ Alternatively , you can use ESPHome Web to prepare a device for being
206
+ used with ESPHome using this computer .
207
+ </ div>
208
+
209
+ <a
210
+ slot= "secondaryAction"
211
+ href = ${ ESPHOME_WEB_URL }
212
+ target= "_blank"
213
+ rel = "noopener"
214
+ >
166
215
<mwc- butto n
167
- slot = "primaryAction"
168
- dialogAction = "ok "
169
- label= "Close "
216
+ no - attention
217
+ dialogAction= "close "
218
+ label = "Open ESPHome Web "
170
219
> </ mwc- butto n>
171
- ` }
220
+ </ a>
221
+
222
+ <mwc- butto n
223
+ slot= "primaryAction"
224
+ label = "Continue"
225
+ @click = ${ ( ) => {
226
+ this . _state = "basic_config" ;
227
+ } }
228
+ > </ mwc- butto n>
172
229
` ;
230
+
231
+ return [ heading , content , hideActions ] ;
173
232
}
174
233
175
234
private _renderBasicConfig ( ) : [ string | undefined , TemplateResult , boolean ] {
176
235
if ( this . _hasWifiSecrets === undefined ) {
177
236
return [ undefined , this . _renderProgress ( "Initializing" ) , true ] ;
178
237
}
179
- const heading = "New device" ;
238
+ const heading = supportsWebSerial ? "New device" : "Create configuration ";
180
239
let hideActions = false ;
181
240
const content = html `
182
- ${ supportsWebSerial
183
- ? ""
184
- : html `
185
- <div class= "notice" >
186
- Limited functionality because
187
- ${ allowsWebSerial
188
- ? html `
189
- your browser does not support WebSerial .
190
- <a
191
- href= "https://esphome.io/guides/getting_started_hassio.html#webserial"
192
- target = "_blank"
193
- > Learn more </ a
194
- >
195
- `
196
- : "you're not browsing the dashboard over a secure connection (HTTPS)." }
197
- </ div>
198
- ` }
199
241
${ this . _error ? html `<div class= "error" > ${ this . _error } </ div> ` : "" }
200
242
201
243
<mwc- textfield
@@ -696,11 +738,6 @@ export class ESPHomeWizardDialog extends LitElement {
696
738
line-height: 80px;
697
739
color: black;
698
740
}
699
- .notice {
700
- padding: 8px 24px;
701
- background-color: #fff59d;
702
- margin: 0 -24px;
703
- }
704
741
.error {
705
742
color: #db4437;
706
743
margin-bottom: 16px;
@@ -719,7 +756,7 @@ export class ESPHomeWizardDialog extends LitElement {
719
756
cursor: pointer;
720
757
}
721
758
722
- mwc-button[slot="secondaryAction" ] {
759
+ mwc-button[no-attention ] {
723
760
--mdc-theme-primary: #444;
724
761
--mdc-theme-on-primary: white;
725
762
}
0 commit comments