Fix dashboard imports for adoption (#2684)

This commit is contained in:
Jesse Hills 2021-11-10 08:38:20 +13:00 committed by GitHub
parent f72389147d
commit d6717c0032
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,6 +29,14 @@ CONFIG_SCHEMA = cv.Schema(
} }
) )
WIFI_MESSAGE = """
# Do not forget to add your own wifi configuration before installing this configuration
# wifi:
# ssid: !secret wifi_ssid
# password: !secret wifi_password
"""
async def to_code(config): async def to_code(config):
cg.add_define("USE_DASHBOARD_IMPORT") cg.add_define("USE_DASHBOARD_IMPORT")
@ -41,5 +49,12 @@ 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 = {"substitutions": {"name": name}, "packages": {project_name: import_url}} config = {
p.write_text(dump(config), encoding="utf8") "substitutions": {"name": name},
"packages": {project_name: import_url},
"esphome": {"name_add_mac_suffix": False},
}
p.write_text(
dump(config) + WIFI_MESSAGE,
encoding="utf8",
)