mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-28 04:44:39 +02:00
Cleanup after add_to_platform_abort is called, try-except intercept, update strings.json, fixes #658 (#659)
* Cleanup after add_to_platform_abort is called, fixes #658 * Add note * try-catch because of priv * Catch all exceptions * Bump to 1.17.3 in manifest.json * assert that hass is not None * Rename _light_event_action -> _light_state_event_action * update .github/update-strings.py * Update README.md, strings.json, and services.yaml * update name * Fixes * Update README.md, strings.json, and services.yaml * Add name * Do not add name --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
8696092879
commit
e9297d562f
7 changed files with 447 additions and 51 deletions
24
.github/update-strings.py
vendored
24
.github/update-strings.py
vendored
|
|
@ -3,6 +3,8 @@ import json
|
|||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
sys.path.append(str(Path(__file__).parent.parent))
|
||||
|
||||
from custom_components.adaptive_lighting import const # noqa: E402
|
||||
|
|
@ -13,20 +15,40 @@ en_fname = folder / "translations" / "en.json"
|
|||
with strings_fname.open() as f:
|
||||
strings = json.load(f)
|
||||
|
||||
# Set "options"
|
||||
data = {k: f"{k}: {const.DOCS[k]}" for k, _, _ in const.VALIDATION_TUPLES}
|
||||
strings["options"]["step"]["init"]["data"] = data
|
||||
|
||||
# Set "services"
|
||||
services_filename = Path("custom_components") / "adaptive_lighting" / "services.yaml"
|
||||
with open(services_filename) as f: # noqa: PTH123
|
||||
services = yaml.safe_load(f)
|
||||
services_json = {}
|
||||
for service_name, dct in services.items():
|
||||
services_json[service_name] = {
|
||||
"name": service_name,
|
||||
"description": dct["description"],
|
||||
"fields": {},
|
||||
}
|
||||
for field_name, field in dct["fields"].items():
|
||||
services_json[service_name]["fields"][field_name] = {
|
||||
"description": field["description"],
|
||||
"name": field_name,
|
||||
}
|
||||
strings["services"] = services_json
|
||||
|
||||
# Write changes to strings.json
|
||||
with strings_fname.open("w") as f:
|
||||
json.dump(strings, f, indent=2, ensure_ascii=False)
|
||||
f.write("\n")
|
||||
|
||||
|
||||
# Sync changes from strings.json to en.json
|
||||
with en_fname.open() as f:
|
||||
en = json.load(f)
|
||||
|
||||
en["config"]["step"]["user"] = strings["config"]["step"]["user"]
|
||||
en["options"]["step"]["init"]["data"] = data
|
||||
en["services"] = services_json
|
||||
|
||||
with en_fname.open("w") as f:
|
||||
json.dump(en, f, indent=2, ensure_ascii=False)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue