File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -221,10 +221,22 @@ def _validate(config):
221
221
raise cv .Invalid ("Fast connect can only be used with one network!" )
222
222
223
223
if CONF_USE_ADDRESS not in config :
224
+ use_address = CORE .name + config [CONF_DOMAIN ]
224
225
if CONF_MANUAL_IP in config :
225
226
use_address = str (config [CONF_MANUAL_IP ][CONF_STATIC_IP ])
226
- else :
227
- use_address = CORE .name + config [CONF_DOMAIN ]
227
+ elif CONF_NETWORKS in config :
228
+ ips = set (
229
+ str (net [CONF_MANUAL_IP ][CONF_STATIC_IP ])
230
+ for net in config [CONF_NETWORKS ]
231
+ if CONF_MANUAL_IP in net
232
+ )
233
+ if len (ips ) > 1 :
234
+ raise cv .Invalid (
235
+ "Must specify use_address when using multiple static IP addresses."
236
+ )
237
+ if len (ips ) == 1 :
238
+ use_address = next (iter (ips ))
239
+
228
240
config [CONF_USE_ADDRESS ] = use_address
229
241
230
242
return config
@@ -334,7 +346,8 @@ async def to_code(config):
334
346
cg .add (var .set_use_address (config [CONF_USE_ADDRESS ]))
335
347
336
348
for network in config .get (CONF_NETWORKS , []):
337
- cg .add (var .add_sta (wifi_network (network , config .get (CONF_MANUAL_IP ))))
349
+ ip_config = network .get (CONF_MANUAL_IP , config .get (CONF_MANUAL_IP ))
350
+ cg .add (var .add_sta (wifi_network (network , ip_config )))
338
351
339
352
if CONF_AP in config :
340
353
conf = config [CONF_AP ]
Original file line number Diff line number Diff line change 16
16
networks :
17
17
- ssid : ' MySSID'
18
18
password : ' password1'
19
+ manual_ip :
20
+ static_ip : 192.168.1.23
21
+ gateway : 192.168.1.1
22
+ subnet : 255.255.255.0
19
23
20
24
api :
21
25
You can’t perform that action at this time.
0 commit comments