From 5b7ee446295a5ff54dcfc54ba7e34cce0d271237 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Wed, 9 Aug 2023 17:17:25 -0700 Subject: [PATCH] Fix length of descriptions in UI (config flow) (#732) * Fix length of strings in UI * Update README.md, strings.json, and services.yaml * fix * add desc * Update README.md, strings.json, and services.yaml * mention webapp * Add desc * link --------- Co-authored-by: github-actions[bot] --- .github/update-strings.py | 13 +++- .../adaptive_lighting/strings.json | 70 +++++++++++++------ .../adaptive_lighting/translations/en.json | 70 +++++++++++++------ 3 files changed, 106 insertions(+), 47 deletions(-) diff --git a/.github/update-strings.py b/.github/update-strings.py index 44dc6bd6..f90ac437 100644 --- a/.github/update-strings.py +++ b/.github/update-strings.py @@ -3,6 +3,7 @@ import sys from pathlib import Path +import homeassistant.helpers.config_validation as cv import yaml sys.path.append(str(Path(__file__).parent.parent)) @@ -16,8 +17,17 @@ strings = json.load(f) # Set "options" -data = {k: f"{k}: {const.DOCS[k]}" for k, _, _ in const.VALIDATION_TUPLES} +data = {} +data_description = {} +for k, _, typ in const.VALIDATION_TUPLES: + desc = const.DOCS[k] + if len(desc) > 40 and typ != bool and typ != cv.entity_ids: + data[k] = k + data_description[k] = desc + else: + data[k] = f"{k}: {desc}" strings["options"]["step"]["init"]["data"] = data +strings["options"]["step"]["init"]["data_description"] = data_description # Set "services" services_filename = Path("custom_components") / "adaptive_lighting" / "services.yaml" @@ -48,6 +58,7 @@ en["config"]["step"]["user"] = strings["config"]["step"]["user"] en["options"]["step"]["init"]["data"] = data +en["options"]["step"]["init"]["data_description"] = data_description en["services"] = services_json with en_fname.open("w") as f: diff --git a/custom_components/adaptive_lighting/strings.json b/custom_components/adaptive_lighting/strings.json index 5e60ed79..5733bfd5 100644 --- a/custom_components/adaptive_lighting/strings.json +++ b/custom_components/adaptive_lighting/strings.json @@ -17,45 +17,69 @@ "step": { "init": { "title": "Adaptive Lighting options", - "description": "All settings for a Adaptive Lighting component. The option names correspond with the YAML settings. No options are shown if you have this entry defined in YAML.", + "description": "Configure an Adaptive Lighting component. Option names align with the YAML settings. If you've defined this entry in YAML, no options will appear here. For interactive graphs that demonstrate parameter effects, visit [this web app](https://basnijholt.github.io/adaptive-lighting). For further details, see the [official documentation](https://github.com/basnijholt/adaptive-lighting#readme).", "data": { "lights": "lights: List of light entity_ids to be controlled (may be empty). 🌟", - "interval": "interval: Frequency to adapt the lights, in seconds. πŸ”„", - "transition": "transition: Duration of transition when lights change, in seconds. πŸ•‘", - "initial_transition": "initial_transition: Duration of the first transition when lights turn from `off` to `on` in seconds. ⏲️", + "interval": "interval", + "transition": "transition", + "initial_transition": "initial_transition", "min_brightness": "min_brightness: Minimum brightness percentage. πŸ’‘", "max_brightness": "max_brightness: Maximum brightness percentage. πŸ’‘", "min_color_temp": "min_color_temp: Warmest color temperature in Kelvin. πŸ”₯", "max_color_temp": "max_color_temp: Coldest color temperature in Kelvin. ❄️", "prefer_rgb_color": "prefer_rgb_color: Whether to prefer RGB color adjustment over light color temperature when possible. 🌈", - "sleep_brightness": "sleep_brightness: Brightness percentage of lights in sleep mode. 😴", - "sleep_rgb_or_color_temp": "sleep_rgb_or_color_temp: Use either `\"rgb_color\"` or `\"color_temp\"` in sleep mode. πŸŒ™", - "sleep_color_temp": "sleep_color_temp: Color temperature in sleep mode (used when `sleep_rgb_or_color_temp` is `color_temp`) in Kelvin. 😴", - "sleep_rgb_color": "sleep_rgb_color: RGB color in sleep mode (used when `sleep_rgb_or_color_temp` is \"rgb_color\"). 🌈", - "sleep_transition": "sleep_transition: Duration of transition when \"sleep mode\" is toggled in seconds. 😴", + "sleep_brightness": "sleep_brightness", + "sleep_rgb_or_color_temp": "sleep_rgb_or_color_temp", + "sleep_color_temp": "sleep_color_temp", + "sleep_rgb_color": "sleep_rgb_color", + "sleep_transition": "sleep_transition", "transition_until_sleep": "transition_until_sleep: When enabled, Adaptive Lighting will treat sleep settings as the minimum, transitioning to these values after sunset. πŸŒ™", - "sunrise_time": "sunrise_time: Set a fixed time (HH:MM:SS) for sunrise. πŸŒ…", - "min_sunrise_time": "min_sunrise_time: Set the earliest virtual sunrise time (HH:MM:SS), allowing for later sunrises. πŸŒ…", - "max_sunrise_time": "max_sunrise_time: Set the latest virtual sunrise time (HH:MM:SS), allowing for earlier sunrises. πŸŒ…", - "sunrise_offset": "sunrise_offset: Adjust sunrise time with a positive or negative offset in seconds. ⏰", - "sunset_time": "sunset_time: Set a fixed time (HH:MM:SS) for sunset. πŸŒ‡", - "min_sunset_time": "min_sunset_time: Set the earliest virtual sunset time (HH:MM:SS), allowing for later sunsets. πŸŒ‡", - "max_sunset_time": "max_sunset_time: Set the latest virtual sunset time (HH:MM:SS), allowing for earlier sunsets. πŸŒ‡", - "sunset_offset": "sunset_offset: Adjust sunset time with a positive or negative offset in seconds. ⏰", - "brightness_mode": "brightness_mode: Brightness mode to use. Possible values are `default`, `linear`, and `tanh` (uses `brightness_mode_time_dark` and `brightness_mode_time_light`). πŸ“ˆ", - "brightness_mode_time_dark": "brightness_mode_time_dark: (Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness before/after sunrise/sunset. πŸ“ˆπŸ“‰", - "brightness_mode_time_light": "brightness_mode_time_light: (Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness after/before sunrise/sunset. πŸ“ˆπŸ“‰.", + "sunrise_time": "sunrise_time", + "min_sunrise_time": "min_sunrise_time", + "max_sunrise_time": "max_sunrise_time", + "sunrise_offset": "sunrise_offset", + "sunset_time": "sunset_time", + "min_sunset_time": "min_sunset_time", + "max_sunset_time": "max_sunset_time", + "sunset_offset": "sunset_offset", + "brightness_mode": "brightness_mode", + "brightness_mode_time_dark": "brightness_mode_time_dark", + "brightness_mode_time_light": "brightness_mode_time_light", "take_over_control": "take_over_control: Disable Adaptive Lighting if another source calls `light.turn_on` while lights are on and being adapted. Note that this calls `homeassistant.update_entity` every `interval`! πŸ”’", "detect_non_ha_changes": "detect_non_ha_changes: Detects and halts adaptations for non-`light.turn_on` state changes. Needs `take_over_control` enabled. πŸ•΅οΈ Caution: ⚠️ Some lights might falsely indicate an 'on' state, which could result in lights turning on unexpectedly. Disable this feature if you encounter such issues.", - "autoreset_control_seconds": "autoreset_control_seconds: Automatically reset the manual control after a number of seconds. Set to 0 to disable. ⏲️", + "autoreset_control_seconds": "autoreset_control_seconds", "only_once": "only_once: Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). πŸ”„", "adapt_only_on_bare_turn_on": "adapt_only_on_bare_turn_on: When turning lights on initially. If set to `true`, AL adapts only if `light.turn_on` is invoked without specifying color or brightness. ❌🌈 This e.g., prevents adaptation when activating a scene. If `false`, AL adapts regardless of the presence of color or brightness in the initial `service_data`. Needs `take_over_control` enabled. πŸ•΅οΈ ", "separate_turn_on_commands": "separate_turn_on_commands: Use separate `light.turn_on` calls for color and brightness, needed for some light types. πŸ”€", - "send_split_delay": "send_split_delay: Delay (ms) between `separate_turn_on_commands` for lights that don't support simultaneous brightness and color setting. ⏲️", - "adapt_delay": "adapt_delay: Wait time (seconds) between light turn on and Adaptive Lighting applying changes. Might help to avoid flickering. ⏲️", + "send_split_delay": "send_split_delay", + "adapt_delay": "adapt_delay", "skip_redundant_commands": "skip_redundant_commands: Skip sending adaptation commands whose target state already equals the light's known state. Minimizes network traffic and improves the adaptation responsivity in some situations. πŸ“‰Disable if physical light states get out of sync with HA's recorded state.", "multi_light_intercept": "multi_light_intercept: Intercept and adapt `light.turn_on` calls that target multiple lights. βž—βš οΈ This might result in splitting up a single `light.turn_on` call into multiple calls, e.g., when lights are in different switches.", "include_config_in_attributes": "include_config_in_attributes: Show all options as attributes on the switch in Home Assistant when set to `true`. πŸ“" + }, + "data_description": { + "interval": "Frequency to adapt the lights, in seconds. πŸ”„", + "transition": "Duration of transition when lights change, in seconds. πŸ•‘", + "initial_transition": "Duration of the first transition when lights turn from `off` to `on` in seconds. ⏲️", + "sleep_brightness": "Brightness percentage of lights in sleep mode. 😴", + "sleep_rgb_or_color_temp": "Use either `\"rgb_color\"` or `\"color_temp\"` in sleep mode. πŸŒ™", + "sleep_color_temp": "Color temperature in sleep mode (used when `sleep_rgb_or_color_temp` is `color_temp`) in Kelvin. 😴", + "sleep_rgb_color": "RGB color in sleep mode (used when `sleep_rgb_or_color_temp` is \"rgb_color\"). 🌈", + "sleep_transition": "Duration of transition when \"sleep mode\" is toggled in seconds. 😴", + "sunrise_time": "Set a fixed time (HH:MM:SS) for sunrise. πŸŒ…", + "min_sunrise_time": "Set the earliest virtual sunrise time (HH:MM:SS), allowing for later sunrises. πŸŒ…", + "max_sunrise_time": "Set the latest virtual sunrise time (HH:MM:SS), allowing for earlier sunrises. πŸŒ…", + "sunrise_offset": "Adjust sunrise time with a positive or negative offset in seconds. ⏰", + "sunset_time": "Set a fixed time (HH:MM:SS) for sunset. πŸŒ‡", + "min_sunset_time": "Set the earliest virtual sunset time (HH:MM:SS), allowing for later sunsets. πŸŒ‡", + "max_sunset_time": "Set the latest virtual sunset time (HH:MM:SS), allowing for earlier sunsets. πŸŒ‡", + "sunset_offset": "Adjust sunset time with a positive or negative offset in seconds. ⏰", + "brightness_mode": "Brightness mode to use. Possible values are `default`, `linear`, and `tanh` (uses `brightness_mode_time_dark` and `brightness_mode_time_light`). πŸ“ˆ", + "brightness_mode_time_dark": "(Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness before/after sunrise/sunset. πŸ“ˆπŸ“‰", + "brightness_mode_time_light": "(Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness after/before sunrise/sunset. πŸ“ˆπŸ“‰.", + "autoreset_control_seconds": "Automatically reset the manual control after a number of seconds. Set to 0 to disable. ⏲️", + "send_split_delay": "Delay (ms) between `separate_turn_on_commands` for lights that don't support simultaneous brightness and color setting. ⏲️", + "adapt_delay": "Wait time (seconds) between light turn on and Adaptive Lighting applying changes. Might help to avoid flickering. ⏲️" } } }, diff --git a/custom_components/adaptive_lighting/translations/en.json b/custom_components/adaptive_lighting/translations/en.json index cbf87f96..eaf28798 100644 --- a/custom_components/adaptive_lighting/translations/en.json +++ b/custom_components/adaptive_lighting/translations/en.json @@ -18,45 +18,69 @@ "step": { "init": { "title": "Adaptive Lighting options", - "description": "All settings for a Adaptive Lighting component. The option names correspond with the YAML settings. No options are shown if you have the adaptive_lighting entry defined in your YAML configuration.", + "description": "Configure an Adaptive Lighting component. Option names align with the YAML settings. If you've defined this entry in YAML, no options will appear here. For interactive graphs that demonstrate parameter effects, visit [this web app](https://basnijholt.github.io/adaptive-lighting). For further details, see the [official documentation](https://github.com/basnijholt/adaptive-lighting#readme).", "data": { "lights": "lights: List of light entity_ids to be controlled (may be empty). 🌟", - "interval": "interval: Frequency to adapt the lights, in seconds. πŸ”„", - "transition": "transition: Duration of transition when lights change, in seconds. πŸ•‘", - "initial_transition": "initial_transition: Duration of the first transition when lights turn from `off` to `on` in seconds. ⏲️", + "interval": "interval", + "transition": "transition", + "initial_transition": "initial_transition", "min_brightness": "min_brightness: Minimum brightness percentage. πŸ’‘", "max_brightness": "max_brightness: Maximum brightness percentage. πŸ’‘", "min_color_temp": "min_color_temp: Warmest color temperature in Kelvin. πŸ”₯", "max_color_temp": "max_color_temp: Coldest color temperature in Kelvin. ❄️", "prefer_rgb_color": "prefer_rgb_color: Whether to prefer RGB color adjustment over light color temperature when possible. 🌈", - "sleep_brightness": "sleep_brightness: Brightness percentage of lights in sleep mode. 😴", - "sleep_rgb_or_color_temp": "sleep_rgb_or_color_temp: Use either `\"rgb_color\"` or `\"color_temp\"` in sleep mode. πŸŒ™", - "sleep_color_temp": "sleep_color_temp: Color temperature in sleep mode (used when `sleep_rgb_or_color_temp` is `color_temp`) in Kelvin. 😴", - "sleep_rgb_color": "sleep_rgb_color: RGB color in sleep mode (used when `sleep_rgb_or_color_temp` is \"rgb_color\"). 🌈", - "sleep_transition": "sleep_transition: Duration of transition when \"sleep mode\" is toggled in seconds. 😴", + "sleep_brightness": "sleep_brightness", + "sleep_rgb_or_color_temp": "sleep_rgb_or_color_temp", + "sleep_color_temp": "sleep_color_temp", + "sleep_rgb_color": "sleep_rgb_color", + "sleep_transition": "sleep_transition", "transition_until_sleep": "transition_until_sleep: When enabled, Adaptive Lighting will treat sleep settings as the minimum, transitioning to these values after sunset. πŸŒ™", - "sunrise_time": "sunrise_time: Set a fixed time (HH:MM:SS) for sunrise. πŸŒ…", - "min_sunrise_time": "min_sunrise_time: Set the earliest virtual sunrise time (HH:MM:SS), allowing for later sunrises. πŸŒ…", - "max_sunrise_time": "max_sunrise_time: Set the latest virtual sunrise time (HH:MM:SS), allowing for earlier sunrises. πŸŒ…", - "sunrise_offset": "sunrise_offset: Adjust sunrise time with a positive or negative offset in seconds. ⏰", - "sunset_time": "sunset_time: Set a fixed time (HH:MM:SS) for sunset. πŸŒ‡", - "min_sunset_time": "min_sunset_time: Set the earliest virtual sunset time (HH:MM:SS), allowing for later sunsets. πŸŒ‡", - "max_sunset_time": "max_sunset_time: Set the latest virtual sunset time (HH:MM:SS), allowing for earlier sunsets. πŸŒ‡", - "sunset_offset": "sunset_offset: Adjust sunset time with a positive or negative offset in seconds. ⏰", - "brightness_mode": "brightness_mode: Brightness mode to use. Possible values are `default`, `linear`, and `tanh` (uses `brightness_mode_time_dark` and `brightness_mode_time_light`). πŸ“ˆ", - "brightness_mode_time_dark": "brightness_mode_time_dark: (Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness before/after sunrise/sunset. πŸ“ˆπŸ“‰", - "brightness_mode_time_light": "brightness_mode_time_light: (Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness after/before sunrise/sunset. πŸ“ˆπŸ“‰.", + "sunrise_time": "sunrise_time", + "min_sunrise_time": "min_sunrise_time", + "max_sunrise_time": "max_sunrise_time", + "sunrise_offset": "sunrise_offset", + "sunset_time": "sunset_time", + "min_sunset_time": "min_sunset_time", + "max_sunset_time": "max_sunset_time", + "sunset_offset": "sunset_offset", + "brightness_mode": "brightness_mode", + "brightness_mode_time_dark": "brightness_mode_time_dark", + "brightness_mode_time_light": "brightness_mode_time_light", "take_over_control": "take_over_control: Disable Adaptive Lighting if another source calls `light.turn_on` while lights are on and being adapted. Note that this calls `homeassistant.update_entity` every `interval`! πŸ”’", "detect_non_ha_changes": "detect_non_ha_changes: Detects and halts adaptations for non-`light.turn_on` state changes. Needs `take_over_control` enabled. πŸ•΅οΈ Caution: ⚠️ Some lights might falsely indicate an 'on' state, which could result in lights turning on unexpectedly. Disable this feature if you encounter such issues.", - "autoreset_control_seconds": "autoreset_control_seconds: Automatically reset the manual control after a number of seconds. Set to 0 to disable. ⏲️", + "autoreset_control_seconds": "autoreset_control_seconds", "only_once": "only_once: Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). πŸ”„", "adapt_only_on_bare_turn_on": "adapt_only_on_bare_turn_on: When turning lights on initially. If set to `true`, AL adapts only if `light.turn_on` is invoked without specifying color or brightness. ❌🌈 This e.g., prevents adaptation when activating a scene. If `false`, AL adapts regardless of the presence of color or brightness in the initial `service_data`. Needs `take_over_control` enabled. πŸ•΅οΈ ", "separate_turn_on_commands": "separate_turn_on_commands: Use separate `light.turn_on` calls for color and brightness, needed for some light types. πŸ”€", - "send_split_delay": "send_split_delay: Delay (ms) between `separate_turn_on_commands` for lights that don't support simultaneous brightness and color setting. ⏲️", - "adapt_delay": "adapt_delay: Wait time (seconds) between light turn on and Adaptive Lighting applying changes. Might help to avoid flickering. ⏲️", + "send_split_delay": "send_split_delay", + "adapt_delay": "adapt_delay", "skip_redundant_commands": "skip_redundant_commands: Skip sending adaptation commands whose target state already equals the light's known state. Minimizes network traffic and improves the adaptation responsivity in some situations. πŸ“‰Disable if physical light states get out of sync with HA's recorded state.", "multi_light_intercept": "multi_light_intercept: Intercept and adapt `light.turn_on` calls that target multiple lights. βž—βš οΈ This might result in splitting up a single `light.turn_on` call into multiple calls, e.g., when lights are in different switches.", "include_config_in_attributes": "include_config_in_attributes: Show all options as attributes on the switch in Home Assistant when set to `true`. πŸ“" + }, + "data_description": { + "interval": "Frequency to adapt the lights, in seconds. πŸ”„", + "transition": "Duration of transition when lights change, in seconds. πŸ•‘", + "initial_transition": "Duration of the first transition when lights turn from `off` to `on` in seconds. ⏲️", + "sleep_brightness": "Brightness percentage of lights in sleep mode. 😴", + "sleep_rgb_or_color_temp": "Use either `\"rgb_color\"` or `\"color_temp\"` in sleep mode. πŸŒ™", + "sleep_color_temp": "Color temperature in sleep mode (used when `sleep_rgb_or_color_temp` is `color_temp`) in Kelvin. 😴", + "sleep_rgb_color": "RGB color in sleep mode (used when `sleep_rgb_or_color_temp` is \"rgb_color\"). 🌈", + "sleep_transition": "Duration of transition when \"sleep mode\" is toggled in seconds. 😴", + "sunrise_time": "Set a fixed time (HH:MM:SS) for sunrise. πŸŒ…", + "min_sunrise_time": "Set the earliest virtual sunrise time (HH:MM:SS), allowing for later sunrises. πŸŒ…", + "max_sunrise_time": "Set the latest virtual sunrise time (HH:MM:SS), allowing for earlier sunrises. πŸŒ…", + "sunrise_offset": "Adjust sunrise time with a positive or negative offset in seconds. ⏰", + "sunset_time": "Set a fixed time (HH:MM:SS) for sunset. πŸŒ‡", + "min_sunset_time": "Set the earliest virtual sunset time (HH:MM:SS), allowing for later sunsets. πŸŒ‡", + "max_sunset_time": "Set the latest virtual sunset time (HH:MM:SS), allowing for earlier sunsets. πŸŒ‡", + "sunset_offset": "Adjust sunset time with a positive or negative offset in seconds. ⏰", + "brightness_mode": "Brightness mode to use. Possible values are `default`, `linear`, and `tanh` (uses `brightness_mode_time_dark` and `brightness_mode_time_light`). πŸ“ˆ", + "brightness_mode_time_dark": "(Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness before/after sunrise/sunset. πŸ“ˆπŸ“‰", + "brightness_mode_time_light": "(Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness after/before sunrise/sunset. πŸ“ˆπŸ“‰.", + "autoreset_control_seconds": "Automatically reset the manual control after a number of seconds. Set to 0 to disable. ⏲️", + "send_split_delay": "Delay (ms) between `separate_turn_on_commands` for lights that don't support simultaneous brightness and color setting. ⏲️", + "adapt_delay": "Wait time (seconds) between light turn on and Adaptive Lighting applying changes. Might help to avoid flickering. ⏲️" } } },