3e959b3df9
Everything a user sees or reads is now English: both boards' labels, status replies and logs, the ESP Screens editor and Alerts cheatsheet, and the README and guides (docs/TILES.md, CALIBRATING.md, ACCEPTANCE.md and TROUBLESHOOTING.md replace the Dutch file names). Labels follow Home Assistant's own English names (Heat/Cool modes, Heating/Cooling actions, Away, Returning to dock, weather conditions), dates use English abbreviations and the top bar writes numbers the English way. Docs use HA 2026.9's menu names (Settings -> Apps, App store, Settings -> Tools). Unused legacy files (home-like.yaml, buttons.yaml, a.out) are removed. Firmware 0.2.34 names its entities in English. Home Assistant registers a renamed ESPHome entity under a new entity ID, so the inbox text.<screen>_tegelinstellingen becomes text.<screen>_tile_settings and the layout stored under the old ID would be lost. The manager now recognises the screen by its device, during a run or after a restart, and moves its layout and update history along; the Update button and the nightly round follow the screen through the rename. Screens that still run 0.2.33 or older keep working: both languages are matched. Main is the only release branch from now on. Tested on a Home Assistant Yellow (HA 2026.9.1) with both bench boards: see docs/TEST_RESULTS_0240.md. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
66 lines
3.1 KiB
Python
66 lines
3.1 KiB
Python
"""Create local device, calibration and secrets files without overwriting any."""
|
|
import argparse
|
|
import base64
|
|
import os
|
|
from pathlib import Path
|
|
import re
|
|
import secrets
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def create(directory, name, friendly_name, board="cyd"):
|
|
if not re.fullmatch(r'[a-z][a-z0-9-]{0,30}', name) or name.endswith('-'):
|
|
raise ValueError('Use a unique name of 1-31 characters: lowercase letters, digits, and dashes.')
|
|
if board not in ("cyd", "guition"):
|
|
raise ValueError("Unknown board profile")
|
|
import json
|
|
device = (ROOT / ('guition-device.example.yaml' if board == 'guition' else 'device.example.yaml')).read_text().replace('"guition-new"' if board == 'guition' else '"cyd-new"', json.dumps(name), 1)
|
|
device = device.replace('"My Guition"' if board == 'guition' else '"My CYD"', json.dumps(friendly_name, ensure_ascii=False), 1)
|
|
secret_text = (ROOT / 'secrets.yaml.example').read_text()
|
|
replacements = [base64.b64encode(secrets.token_bytes(32)).decode(), secrets.token_urlsafe(24), secrets.token_urlsafe(18)]
|
|
for value in replacements:
|
|
secret_text = secret_text.replace('WILL_BE_UNIQUELY_GENERATED', value, 1)
|
|
files = {'guition-device.yaml' if board == 'guition' else 'device.yaml': device, 'secrets.yaml': secret_text}
|
|
if board == 'cyd': files['calibration.yaml'] = (ROOT / 'calibration.example.yaml').read_text()
|
|
directory = Path(directory)
|
|
if not directory.is_dir():
|
|
raise ValueError('The target folder must already exist and contain the unpacked code.')
|
|
for name in files:
|
|
if (directory / name).exists():
|
|
raise ValueError(f'{directory / name} already exists; nothing overwritten. Use a fresh copy of the folder.')
|
|
created = []
|
|
try:
|
|
for name, contents in files.items():
|
|
path = directory / name
|
|
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
|
|
created.append(path)
|
|
with os.fdopen(fd, 'w', encoding='utf-8') as handle:
|
|
handle.write(contents)
|
|
except Exception:
|
|
for path in created:
|
|
path.unlink(missing_ok=True)
|
|
raise
|
|
return created
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--board', choices=['cyd', 'guition'], default='cyd')
|
|
parser.add_argument('--name', required=True, help='Unique ESPHome name, for example display-kitchen')
|
|
parser.add_argument('--friendly-name')
|
|
parser.add_argument('--directory', type=Path, default=ROOT)
|
|
args = parser.parse_args()
|
|
args.friendly_name = args.friendly_name or ('My Guition' if args.board == 'guition' else 'My CYD')
|
|
try:
|
|
for path in create(args.directory, args.name, args.friendly_name, args.board):
|
|
print(f'Created: {path}')
|
|
print('Fill in Wi-Fi locally in secrets.yaml. Keys are uniquely generated and are not shown.')
|
|
print('Follow docs/GUITION.md; flash guition-device.yaml.' if args.board == 'guition' else 'Follow README.md; flash device.yaml.')
|
|
except (ValueError, OSError) as exc:
|
|
parser.exit(1, f'Error: {exc}\n')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|