mirror of
https://github.com/esphome/esphome.git
synced 2025-09-27 15:42:22 +01:00
Add Captive Portal (#624)
* WIP: Captive Portal * Updates * Updates * Lint * Fixes
This commit is contained in:
@@ -2,6 +2,8 @@ from __future__ import print_function
|
||||
|
||||
import codecs
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
import unicodedata
|
||||
|
||||
import voluptuous as vol
|
||||
@@ -52,6 +54,13 @@ wifi:
|
||||
ssid: "{ssid}"
|
||||
password: "{psk}"
|
||||
|
||||
# Enable fallback network (captive portal)
|
||||
ap:
|
||||
ssid: "{name} Fallback AP"
|
||||
password: "{fallback_psk}"
|
||||
|
||||
captive_portal:
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
@@ -65,6 +74,9 @@ def sanitize_double_quotes(value):
|
||||
|
||||
|
||||
def wizard_file(**kwargs):
|
||||
letters = string.ascii_letters + string.digits
|
||||
kwargs['fallback_psk'] = ''.join(random.choice(letters) for _ in range(12))
|
||||
|
||||
config = BASE_CONFIG.format(**kwargs)
|
||||
|
||||
if kwargs['password']:
|
||||
@@ -117,8 +129,8 @@ def default_input(text, default):
|
||||
|
||||
|
||||
# From https://stackoverflow.com/a/518232/8924614
|
||||
def strip_accents(string):
|
||||
return u''.join(c for c in unicodedata.normalize('NFD', text_type(string))
|
||||
def strip_accents(value):
|
||||
return u''.join(c for c in unicodedata.normalize('NFD', text_type(value))
|
||||
if unicodedata.category(c) != 'Mn')
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user