1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-27 07:32:22 +01:00

Add friendly_name to device (#4296)

This commit is contained in:
Jesse Hills
2023-01-17 10:28:09 +13:00
committed by GitHub
parent 3d2d681a7b
commit c301ae3645
18 changed files with 137 additions and 18 deletions

View File

@@ -46,6 +46,11 @@ BASE_CONFIG = """esphome:
name: {name}
"""
BASE_CONFIG_FRIENDLY = """esphome:
name: {name}
friendly_name: {friendly_name}
"""
LOGGER_API_CONFIG = """
# Enable logging
logger:
@@ -110,7 +115,12 @@ def wizard_file(**kwargs):
kwargs["fallback_name"] = ap_name
kwargs["fallback_psk"] = "".join(random.choice(letters) for _ in range(12))
config = BASE_CONFIG.format(**kwargs)
if kwargs.get("friendly_name"):
base = BASE_CONFIG_FRIENDLY
else:
base = BASE_CONFIG
config = base.format(**kwargs)
config += HARDWARE_BASE_CONFIGS[kwargs["platform"]].format(**kwargs)
@@ -192,7 +202,7 @@ def wizard_write(path, **kwargs):
hardware = kwargs["platform"]
write_file(path, wizard_file(**kwargs))
storage = StorageJSON.from_wizard(name, f"{name}.local", hardware)
storage = StorageJSON.from_wizard(name, name, f"{name}.local", hardware)
storage_path = ext_storage_path(os.path.dirname(path), os.path.basename(path))
storage.save(storage_path)