mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-10-28 22:27:06 +01:00
A service that only returns data: for each light, the `light.turn_on` calls Adaptive Lighting would make to adapt it, now or for a given time of day (today), without making them. Each call has its service data and the time to wait before it (between split calls, with `separate_turn_on_commands`). This lets automations use Adaptive Lighting's curves for other times, e.g. to step lights to later or earlier settings from a button: when the automation makes the calls, Adaptive Lighting treats them like any other change (with `take_over_control`, it stops adapting those lights until manual control is reset). - Only the lights and light groups in the switches' `lights` are allowed. Without `entity_id`, each gets the calls of the switch it's in (of several, the one that's on). A light group is replaced by its members when the switch expands light groups, as Adaptive Lighting does. - Omitted options follow the switch (its adapt switches, `prefer_rgb_color` and `initial_transition`), and settings are for when the transition ends, as for the regular adaptation. Manual control and whether the lights are on don't change the calls. - The calls are built by the same code as Adaptive Lighting's own, factored out of `prepare_adaptation_data` (`_build_service_data`) and `adaptation_utils.prepare_adaptation_data` (`plan_service_calls`), without changing their behaviour. `SunLightSettings.get_settings` takes an optional time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1 KiB
Python
31 lines
1 KiB
Python
"""Creates a services.yaml file with the latest docs."""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
sys.path.append(str(Path(__file__).parent.parent))
|
|
|
|
from custom_components.adaptive_lighting import const
|
|
|
|
services_filename = Path("custom_components") / "adaptive_lighting" / "services.yaml"
|
|
with open(services_filename) as f: # noqa: PTH123
|
|
services = yaml.safe_load(f)
|
|
|
|
for service_name, dct in services.items():
|
|
_docs = {
|
|
"set_manual_control": const.DOCS_MANUAL_CONTROL,
|
|
"apply": const.DOCS_APPLY,
|
|
"get_commands": const.DOCS_GET_COMMANDS,
|
|
}
|
|
alternative_docs = _docs.get(service_name, const.DOCS)
|
|
for field_name, field in dct["fields"].items():
|
|
description = alternative_docs.get(field_name, const.DOCS[field_name])
|
|
field["description"] = description
|
|
|
|
comment = "# This file is auto-generated by .github/update-services.py."
|
|
|
|
with services_filename.open("w") as f:
|
|
f.write(comment + "\n")
|
|
yaml.dump(services, f, sort_keys=False, width=1000, allow_unicode=True)
|