mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 09:17:46 +01:00
Generate basic config for esphome-web devices (#3036)
This commit is contained in:
parent
d9c938de33
commit
c0ff899812
1 changed files with 22 additions and 9 deletions
|
@ -3,6 +3,7 @@ from pathlib import Path
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.components.packages import validate_source_shorthand
|
from esphome.components.packages import validate_source_shorthand
|
||||||
|
from esphome.wizard import wizard_file
|
||||||
from esphome.yaml_util import dump
|
from esphome.yaml_util import dump
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,12 +49,24 @@ def import_config(path: str, name: str, project_name: str, import_url: str) -> N
|
||||||
if p.exists():
|
if p.exists():
|
||||||
raise FileExistsError
|
raise FileExistsError
|
||||||
|
|
||||||
config = {
|
if project_name == "esphome.web":
|
||||||
"substitutions": {"name": name},
|
p.write_text(
|
||||||
"packages": {project_name: import_url},
|
wizard_file(
|
||||||
"esphome": {"name_add_mac_suffix": False},
|
name=name,
|
||||||
}
|
platform="ESP32" if "esp32" in import_url else "ESP8266",
|
||||||
p.write_text(
|
board="esp32dev" if "esp32" in import_url else "esp01_1m",
|
||||||
dump(config) + WIFI_CONFIG,
|
ssid="!secret wifi_ssid",
|
||||||
encoding="utf8",
|
psk="!secret wifi_password",
|
||||||
)
|
),
|
||||||
|
encoding="utf8",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
config = {
|
||||||
|
"substitutions": {"name": name},
|
||||||
|
"packages": {project_name: import_url},
|
||||||
|
"esphome": {"name_add_mac_suffix": False},
|
||||||
|
}
|
||||||
|
p.write_text(
|
||||||
|
dump(config) + WIFI_CONFIG,
|
||||||
|
encoding="utf8",
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue