### Full Adaptive Lighting Configuration Example Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/configuration.md Use this comprehensive example for a complete Adaptive Lighting setup. It includes all available options for fine-tuning light behavior. ```yaml adaptive_lighting: - name: "default" lights: [] prefer_rgb_color: false transition: 45 initial_transition: 1 interval: 90 min_brightness: 1 max_brightness: 100 min_color_temp: 2000 max_color_temp: 5500 sleep_brightness: 1 sleep_color_temp: 1000 sunrise_time: "08:00:00" # override the sunrise time sunrise_offset: sunset_time: sunset_offset: 1800 # in seconds or '00:30:00' take_over_control: true detect_non_ha_changes: false only_once: false ``` -------------------------------- ### Example configuration.yaml Entry for Adaptive Lighting Source: https://github.com/basnijholt/adaptive-lighting/blob/main/README.md This is a full example of how to configure the Adaptive Lighting integration in your Home Assistant configuration.yaml file. It includes various options for controlling light behavior, transitions, and sleep settings. ```yaml adaptive_lighting: - name: "default" lights: [] prefer_rgb_color: false transition: 45 initial_transition: 1 interval: 90 min_brightness: 1 max_brightness: 100 min_color_temp: 2000 max_color_temp: 5500 sleep_brightness: 1 sleep_color_temp: 1000 sunrise_time: "08:00:00" # override the sunrise time sunrise_offset: sunset_time: sunset_offset: 1800 # in seconds or '00:30:00' take_over_control: true detect_non_ha_changes: false only_once: false ``` -------------------------------- ### Clone HA Core and Setup Symlinks Source: https://github.com/basnijholt/adaptive-lighting/blob/main/tests/README.md One-time setup commands to clone the Home Assistant core repository and establish necessary symlinks for testing. ```bash # Clone HA core (one-time setup) git clone --depth 1 https://github.com/home-assistant/core.git core # Setup symlinks (one-time setup) ./scripts/setup-symlinks ``` -------------------------------- ### Run Adaptive Lighting App Locally Source: https://github.com/basnijholt/adaptive-lighting/blob/main/webapp/README.md Install dependencies and run the Shiny application. Access the interface via the provided local URL. ```bash $ cd webapp $ pip install -r requirements-dev.txt $ shiny run ``` -------------------------------- ### Basic Adaptive Lighting Configuration Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/getting-started.md A simple configuration to get started with Adaptive Lighting, defining a name for the group of lights and setting basic brightness and color temperature limits. Ensure the specified lights are correctly configured in Home Assistant. ```yaml adaptive_lighting: - name: "Main Lights" lights: - light.living_room - light.bedroom - light.kitchen transition: 30 min_brightness: 10 max_brightness: 100 min_color_temp: 2000 max_color_temp: 5500 ``` -------------------------------- ### SunLightSettings Internal API Example Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt Demonstrates importing and using the SunLightSettings dataclass for testing light settings outside of Home Assistant. Requires datetime and unittest.mock. ```python import datetime from unittest.mock import MagicMock from custom_components.adaptive_lighting.color_and_brightness import SunLightSettings ``` -------------------------------- ### Run Tests with Custom Pytest Arguments Source: https://github.com/basnijholt/adaptive-lighting/blob/main/tests/README.md Example command to run adaptive-lighting tests with specific pytest arguments, such as custom log formatting and suppressing stderr output. ```bash docker run -v $(pwd):/app basnijholt/adaptive-lighting:latest --show-capture=log --log-format="%(asctime)s %(levelname)-8s %(name)s:%(filename)s:%(lineno)s %(message)s" --log-date-format="%H:%M:%S" tests/components/adaptive_lighting/ ``` -------------------------------- ### Minimal Configuration for Adaptive Lighting Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/index.md This is the most basic configuration entry required in your configuration.yaml file to enable Adaptive Lighting. Even if you plan to use the UI exclusively for setup, this entry must be present. ```yaml adaptive_lighting: lights: - light.living_room ``` -------------------------------- ### Get Current Light Settings (Daytime) Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt This Python code snippet shows how to retrieve the current light settings for daytime by calling the `brightness_and_color` method with a daytime timestamp and `is_sleep=False`. ```python # Get current light settings (daytime) noon_utc = datetime.datetime(2024, 6, 21, 12, 30, tzinfo=datetime.timezone.utc) result = settings.brightness_and_color(noon_utc, is_sleep=False) ``` -------------------------------- ### Configure Sleep Mode Transition Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt Define sleep mode parameters within the Adaptive Lighting configuration. `transition_until_sleep: true` enables a gradual dimming towards sleep values starting at sunset. ```yaml # Configuration for gradual transition to sleep values after sunset adaptive_lighting: - name: "Bedroom" lights: - light.bedroom_lamp sleep_brightness: 1 sleep_rgb_or_color_temp: color_temp sleep_color_temp: 1000 sleep_transition: 5 # 5-second fade when sleep mode toggled transition_until_sleep: true # start dimming toward sleep values at sunset ``` -------------------------------- ### Get Light Settings in Sleep Mode Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt This Python code snippet demonstrates how to retrieve light settings when the system is in sleep mode by calling the `brightness_and_color` method with `is_sleep=True`. ```python # Get settings in sleep mode result_sleep = settings.brightness_and_color(noon_utc, is_sleep=True) ``` -------------------------------- ### Dynamic Sunrise/Sunset Time Setting Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/automation-examples.md Sets the sunrise and sunset times for Adaptive Lighting switches dynamically. This example shows how to set the sunset time exactly 12 hours after a custom sunrise time, triggered by a specific event or condition. ```yaml iphone_carly_wakeup: alias: iPhone Carly Wakeup sequence: - condition: state entity_id: input_boolean.carly_iphone_wakeup state: "off" - service: input_datetime.set_datetime target: entity_id: input_datetime.carly_iphone_wakeup data: time: '{{ now().strftime("%H:%M:%S") }}' - service: input_boolean.turn_on target: entity_id: input_boolean.carly_iphone_wakeup - repeat: count: > {{ (states.switch | map(attribute="entity_id") | select(">","switch.adaptive_lighting_al_") | select("<", "switch.adaptive_lighting_al_z") | join(",") ).split(",") | length }} sequence: - service: adaptive_lighting.change_switch_settings data: entity_id: switch.adaptive_lighting_al_den_ceilingfan_lights sunrise_time: '{{ now().strftime("%H:%M:%S") }}' sunset_time: > {{ (as_timestamp(now()) + 12*60*60) | timestamp_custom("%H:%M:%S") }} - service: script.turn_on target: entity_id: script.run_wakeup_routine - service: input_boolean.turn_off target: entity_id: - input_boolean.carly_iphone_winddown - input_boolean.carly_iphone_bedtime - service: input_datetime.set_datetime target: entity_id: input_datetime.wakeup_time data: time: '{{ now().strftime("%H:%M:%S") }}' - service: script.adaptive_lighting_disable_sleep_mode mode: queued icon: mdi:weather-sunset max: 10 ``` -------------------------------- ### Basic Adaptive Lighting Configuration Source: https://github.com/basnijholt/adaptive-lighting/blob/main/README.md Add this entry to your `configuration.yaml` file to enable Adaptive Lighting for your lights. Ensure the `adaptive_lighting:` key is present even if you primarily use the UI for configuration. ```yaml adaptive_lighting: lights: - light.living_room_lights ``` -------------------------------- ### Run Adaptive Lighting Tests with Docker (Windows Command Prompt) Source: https://github.com/basnijholt/adaptive-lighting/blob/main/tests/README.md Command to run adaptive-lighting tests using a Docker image on Windows Command Prompt. Ensure the entire repository is mounted to avoid breaking symlinks. ```bash docker run -v %cd%:/app basnijholt/adaptive-lighting:latest ``` -------------------------------- ### YAML Configuration Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt Configuration options for setting up Adaptive Lighting instances in Home Assistant's configuration.yaml. Each instance can control a different set of lights with unique parameters. ```APIDOC ## YAML Configuration The complete `configuration.yaml` entry for one or more named Adaptive Lighting instances. Each entry creates its own set of switches and can control a different set of lights with different parameters. ```yaml # configuration.yaml — minimal setup adaptive_lighting: # activates the integration; UI config is still possible # configuration.yaml — full example with all options adaptive_lighting: - name: "Living Room" lights: - light.living_room_ceiling - light.living_room_lamp interval: 90 # re-adapt every 90 seconds transition: 45 # smooth 45-second fade on each adaptation initial_transition: 1 # fast 1-second fade when light first turns on min_brightness: 1 # 1 % at night max_brightness: 100 # 100 % at solar noon min_color_temp: 2000 # warm amber (Kelvin) max_color_temp: 5500 # cool daylight (Kelvin) prefer_rgb_color: false # prefer color-temp mode over RGB sleep_brightness: 1 sleep_color_temp: 1000 sleep_rgb_or_color_temp: color_temp # or "rgb_color" sleep_rgb_color: [255, 56, 0] sleep_transition: 1 transition_until_sleep: false # gradually reach sleep values after sunset sunrise_time: "07:00:00" # override real sunrise min_sunrise_time: "06:30:00" # never earlier than this max_sunrise_time: "09:00:00" # never later than this sunrise_offset: 0 sunset_time: # leave blank for real sunset min_sunset_time: max_sunset_time: sunset_offset: 1800 # shift sunset 30 min later (seconds or HH:MM:SS) brightness_mode: default # "default" | "linear" | "tanh" brightness_mode_time_dark: 900 brightness_mode_time_light: 3600 take_over_control: true take_over_control_mode: pause_all # "pause_all" | "pause_changed" detect_non_ha_changes: false autoreset_control_seconds: 0 # 0 = disabled; e.g. 7200 = auto-reset after 2 h only_once: false adapt_only_on_bare_turn_on: false separate_turn_on_commands: false # useful for IKEA Trådfri send_split_delay: 0 # ms between split commands adapt_delay: 0 # seconds to wait after turn-on before adapting skip_redundant_commands: false intercept: true multi_light_intercept: true include_config_in_attributes: false - name: "Bedroom" lights: - light.bedroom_ceiling min_brightness: 5 max_brightness: 80 sleep_brightness: 1 sleep_color_temp: 1000 transition_until_sleep: true # gradually dim to sleep values after sunset ``` ``` -------------------------------- ### Run Adaptive Lighting Tests with Docker (Linux/macOS/Windows PowerShell) Source: https://github.com/basnijholt/adaptive-lighting/blob/main/tests/README.md Command to run adaptive-lighting tests using a Docker image. Ensure the entire repository is mounted to avoid breaking symlinks. ```bash docker run -v ${PWD}:/app basnijholt/adaptive-lighting:latest ``` -------------------------------- ### Build Adaptive Lighting Docker Image Locally Source: https://github.com/basnijholt/adaptive-lighting/blob/main/tests/README.md Command to build the adaptive-lighting Docker image locally. This is useful if the Docker Hub image is outdated or dependencies have changed. ```bash docker build -t basnijholt/adaptive-lighting:latest --no-cache --progress=plain . ``` -------------------------------- ### Basic YAML Configuration for Adaptive Lighting Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/configuration.md Configure Adaptive Lighting with a specific name and list of lights directly in your configuration.yaml file. ```yaml adaptive_lighting: - name: "Living Room" lights: - light.living_room_ceiling - light.living_room_lamp ``` -------------------------------- ### Configure Quick Transition (Linear) Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/advanced/brightness-modes.md Use the 'linear' brightness mode for quick transitions. Adjust 'brightness_mode_time_dark' and 'brightness_mode_time_light' to control the duration of these transitions. ```yaml adaptive_lighting: - name: "Quick transitions" lights: - light.living_room brightness_mode: linear brightness_mode_time_dark: 600 # 10 minutes brightness_mode_time_light: 1800 # 30 minutes ``` -------------------------------- ### Configure Adaptive Lighting via YAML Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/getting-started.md Configure specific adaptive lighting instances with custom names, light entities, and brightness/color temperature ranges. This allows for fine-grained control over different rooms or lighting groups. ```yaml adaptive_lighting: - name: "Living Room" lights: - light.living_room_ceiling - light.living_room_lamp min_brightness: 20 max_brightness: 100 min_color_temp: 2200 max_color_temp: 5500 ``` -------------------------------- ### Add Adaptive Lighting to configuration.yaml Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/getting-started.md This entry is required in configuration.yaml even if you plan to configure everything through the UI. It serves as the base for the integration. ```yaml adaptive_lighting: ``` -------------------------------- ### Service Data for adaptive_lighting.apply Source: https://github.com/basnijholt/adaptive-lighting/blob/main/README.md Use this service to apply Adaptive Lighting settings to lights on demand. Specify the entity_id of the switch and optionally target specific lights, transitions, and color/brightness adaptations. ```yaml service: adaptive_lighting.apply entity_id: switch.adaptive_lighting_default lights: - light.living_room_main transition: 30 adapt_brightness: true adapt_color: true prefer_rgb_color: true turn_on_lights: true ``` -------------------------------- ### Mock Astral Location and SunLightSettings Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt This Python code demonstrates how to mock an astral location and configure SunLightSettings for testing purposes. It sets up mock sunrise, sunset, noon, and midnight times, and then initializes SunLightSettings with various parameters. ```python loc = MagicMock() loc.sunrise.return_value = datetime.datetime(2024, 6, 21, 4, 30, tzinfo=datetime.timezone.utc) loc.sunset.return_value = datetime.datetime(2024, 6, 21, 20, 30, tzinfo=datetime.timezone.utc) loc.noon.return_value = datetime.datetime(2024, 6, 21, 12, 30, tzinfo=datetime.timezone.utc) loc.midnight.return_value= datetime.datetime(2024, 6, 21, 0, 30, tzinfo=datetime.timezone.utc) settings = SunLightSettings( name="test", astral_location=loc, adapt_until_sleep=False, max_brightness=100, max_color_temp=5500, min_brightness=1, min_color_temp=2000, sleep_brightness=1, sleep_rgb_or_color_temp="color_temp", sleep_color_temp=1000, sleep_rgb_color=(255, 56, 0), sunrise_time=None, min_sunrise_time=None, max_sunrise_time=None, sunset_time=None, min_sunset_time=None, max_sunset_time=None, brightness_mode_time_dark=datetime.timedelta(seconds=900), brightness_mode_time_light=datetime.timedelta(seconds=3600), brightness_mode="default", ) ``` -------------------------------- ### Apply Adaptive Lighting Settings to Lights Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/services.md Use this service to apply current Adaptive Lighting settings to specific lights on demand. It can force an immediate update or apply settings to lights not in the regular adaptation cycle. Specify the switch entity ID and optionally the lights, transition duration, brightness/color adaptation preferences, and whether to turn on lights. ```yaml service: adaptive_lighting.apply data: entity_id: switch.adaptive_lighting_living_room lights: - light.floor_lamp - light.desk_lamp turn_on_lights: false ``` ```yaml service: adaptive_lighting.apply data: entity_id: switch.adaptive_lighting_bedroom transition: 5 adapt_brightness: true adapt_color: true ``` -------------------------------- ### Service: adaptive_lighting.apply Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt Immediately applies the current adaptive settings of a switch to a set of lights on demand, without waiting for the next interval tick. This service allows for manual triggering of adaptive lighting adjustments. ```APIDOC ## Service: adaptive_lighting.apply Immediately applies the current adaptive settings of a switch to a set of lights on demand, without waiting for the next `interval` tick. ```yaml # Apply living-room switch settings to a specific lamp on demand service: adaptive_lighting.apply data: entity_id: switch.adaptive_lighting_living_room # which switch's settings to use lights: - light.floor_lamp transition: 10 # override transition (seconds) adapt_brightness: true adapt_color: true prefer_rgb_color: false turn_on_lights: false # set true to also turn on lights that are currently off # Apply to all lights managed by the switch (omit the 'lights' key) service: adaptive_lighting.apply data: entity_id: switch.adaptive_lighting_living_room turn_on_lights: true # turn on any lights that are off, then adapt them ``` ``` -------------------------------- ### Include Configuration in Attributes Source: https://github.com/basnijholt/adaptive-lighting/blob/main/README.md Set `include_config_in_attributes` to `true` to display all options as attributes on the switch in Home Assistant. ```yaml include_config_in_attributes: true ``` -------------------------------- ### Enable Debug Logging for Adaptive Lighting Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/troubleshooting.md Enable debug logging for the adaptive_lighting custom component in your configuration.yaml to help diagnose issues. After enabling, reproduce the problem and check the Home Assistant log file. ```yaml logger: default: warning logs: custom_components.adaptive_lighting: debug ``` -------------------------------- ### Multiple Adaptive Lighting Configurations Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/configuration.md Define multiple Adaptive Lighting configurations to manage different zones or use cases independently. This allows for tailored lighting settings across your home. ```yaml adaptive_lighting: - name: "Daytime Spaces" lights: - light.living_room - light.kitchen - light.office min_brightness: 30 max_brightness: 100 - name: "Bedroom" lights: - light.bedroom_ceiling - light.bedroom_lamp min_brightness: 5 max_brightness: 80 sleep_brightness: 1 sleep_color_temp: 1000 ``` -------------------------------- ### Initialize Plausible Analytics Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/overrides/partials/integrations/analytics/custom.html This snippet initializes the Plausible Analytics tracking script. It ensures that the `plausible` function is available and then calls `plausible.init()` to set up the analytics. ```javascript window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}}; plausible.init() ``` -------------------------------- ### Adapt Only on Bare Turn On Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/advanced/manual-control.md Configure Adaptive Lighting to only adapt lights when `light.turn_on` is called without specifying brightness or color. This is useful for preserving scene settings. ```yaml adaptive_lighting: - name: "Respect scenes" lights: - light.living_room take_over_control: true adapt_only_on_bare_turn_on: true ``` -------------------------------- ### Apply Adaptive Lighting Settings to Specific Lights Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt Use the `adaptive_lighting.apply` service to manually apply the current adaptive settings from a specified switch to a list of lights. This allows for on-demand adjustments without waiting for the next interval. You can also choose to turn on lights that are currently off. ```yaml service: adaptive_lighting.apply data: entity_id: switch.adaptive_lighting_living_room # which switch's settings to use lights: - light.floor_lamp transition: 10 # override transition (seconds) adapt_brightness: true adapt_color: true prefer_rgb_color: false turn_on_lights: false # set true to also turn on lights that are currently off ``` -------------------------------- ### adaptive_lighting.apply Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/services.md Applies the current Adaptive Lighting settings to lights on demand. This is useful for forcing an immediate update or applying settings to lights that are not part of the regular adaptation cycle. ```APIDOC ## adaptive_lighting.apply ### Description Applies the current Adaptive Lighting settings to lights on demand. Useful for forcing an immediate update or applying settings to lights that aren't in the regular adaptation cycle. ### Parameters #### Request Body - **entity_id** (list of `entity_id`) - Required - The `entity_id` of the switch with the settings to apply. - **lights** (list of `entity_id`) - Optional - A light (or list of lights) to apply the settings to. - **transition** (float) - Optional - Duration of transition when lights change, in seconds. Range: 0-6553. - **adapt_brightness** (bool) - Optional - Whether to adapt the brightness of the light. - **adapt_color** (bool) - Optional - Whether to adapt the color on supporting lights. - **prefer_rgb_color** (bool) - Optional - Whether to prefer RGB color adjustment over light color temperature when possible. - **turn_on_lights** (bool) - Optional - Whether to turn on lights that are currently off. ### Request Example ```yaml service: adaptive_lighting.apply data: entity_id: switch.adaptive_lighting_living_room lights: - light.floor_lamp - light.desk_lamp turn_on_lights: false ``` ```yaml service: adaptive_lighting.apply data: entity_id: switch.adaptive_lighting_bedroom transition: 5 adapt_brightness: true adapt_color: true ``` ``` -------------------------------- ### Reset Manual Control via Service Call Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/advanced/manual-control.md Use the `adaptive_lighting.set_manual_control` service to resume adaptation for specific lights. ```yaml service: adaptive_lighting.set_manual_control data: entity_id: switch.adaptive_lighting_living_room lights: - light.floor_lamp manual_control: false # Resume adaptation ``` -------------------------------- ### Enable Manual Control Detection Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/advanced/manual-control.md Configure Adaptive Lighting to detect manual changes to light settings. This is enabled by default. ```yaml adaptive_lighting: - name: "With manual control detection" lights: - light.living_room take_over_control: true # default ``` -------------------------------- ### Configure Smooth Transition (Tanh) Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/advanced/brightness-modes.md Utilize the 'tanh' brightness mode for smooth, S-curve transitions. Customize 'brightness_mode_time_dark' and 'brightness_mode_time_light' to fine-tune the ramp duration. ```yaml adaptive_lighting: - name: "Smooth transitions" lights: - light.bedroom brightness_mode: tanh brightness_mode_time_dark: 1200 # 20 minutes brightness_mode_time_light: 3600 # 1 hour ``` -------------------------------- ### Mark/Unmark Lights for Manual Control Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt Use this service to suspend or resume adaptive lighting adaptation for specific lights. Set `manual_control` to `true` to mark, `false` to unmark. You can also selectively pause brightness or color adaptation by setting `manual_control` to "brightness" or "color". ```yaml # Mark a light as manually controlled (suspend adaptation) service: adaptive_lighting.set_manual_control data: entity_id: switch.adaptive_lighting_living_room lights: - light.floor_lamp manual_control: true # true = mark, false = unmark (resume adaptation) ``` ```yaml # Resume adaptation for a specific light service: adaptive_lighting.set_manual_control data: entity_id: switch.adaptive_lighting_living_room lights: - light.floor_lamp manual_control: false ``` ```yaml # Selectively pause only brightness or only color adaptation service: adaptive_lighting.set_manual_control data: entity_id: switch.adaptive_lighting_living_room lights: - light.floor_lamp manual_control: "brightness" # or "color" ``` ```yaml # Unmark all lights in a switch at once (omit 'lights' key) service: adaptive_lighting.set_manual_control data: entity_id: switch.adaptive_lighting_living_room manual_control: false ``` -------------------------------- ### Set Manual Control Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/services.md This service allows you to pause brightness adaptation while continuing color adaptation for specific lights. It's useful for scenarios where you want manual control over brightness without affecting the color temperature or hue. ```APIDOC ## adaptive_lighting.set_manual_control ### Description Only pause brightness adaptation, continue color adaptation. ### Method service ### Endpoint adaptive_lighting.set_manual_control ### Parameters #### Request Body - **entity_id** (string) - Required - The entity ID of the Adaptive Lighting switch. - **lights** (list of strings) - Required - A list of light entity IDs to apply manual control to. - **manual_control** (string) - Required - The type of manual control to apply (e.g., "brightness"). ``` -------------------------------- ### Apply Adaptive Lighting Settings to All Managed Lights Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt This service call applies the adaptive settings from a switch to all lights it manages. By omitting the 'lights' key, you can trigger adaptations for all associated lights, optionally turning them on if they are currently off. ```yaml service: adaptive_lighting.apply data: entity_id: switch.adaptive_lighting_living_room turn_on_lights: true # turn on any lights that are off, then adapt them ``` -------------------------------- ### Dynamically Change Switch Settings Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt Modify Adaptive Lighting switch settings at runtime. Changes are immediate but not persistent across Home Assistant restarts. Use `use_defaults` to reset to 'current', 'configuration', or 'factory' defaults. ```yaml # Override sunrise/sunset to align with an alarm schedule service: adaptive_lighting.change_switch_settings data: entity_id: switch.adaptive_lighting_living_room use_defaults: current # "current" | "configuration" | "factory" sunrise_time: "07:30:00" sunset_time: "19:30:00" ``` ```yaml # Switch to tanh brightness mode with custom ramp times service: adaptive_lighting.change_switch_settings data: entity_id: switch.adaptive_lighting_living_room brightness_mode: tanh brightness_mode_time_dark: 600 # 10 min dark ramp brightness_mode_time_light: 3600 # 1 h light ramp ``` ```yaml # Tighten brightness limits for an office screen-glare scenario service: adaptive_lighting.change_switch_settings data: entity_id: switch.adaptive_lighting_office min_brightness: 40 max_brightness: 85 take_over_control_mode: pause_changed ``` ```yaml # Reset all settings to factory defaults service: adaptive_lighting.change_switch_settings data: entity_id: switch.adaptive_lighting_living_room use_defaults: factory ``` -------------------------------- ### switch.turn_on / switch.turn_off (Sleep Mode) Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt Controls the sleep mode for Adaptive Lighting instances. Turning the sleep mode switch on shifts lights to sleep values, and turning it off resumes normal adaptation. ```APIDOC ## Sleep Mode Switches ### Description Each configured instance automatically creates a sleep-mode switch named `switch.adaptive_lighting_sleep_mode_`. Turning it on immediately shifts the lights to `sleep_brightness`, `sleep_color_temp` (or `sleep_rgb_color`) with a `sleep_transition`. Turning it off resumes normal adaptation. ### Method Call ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **entity_id** (string) - Required - The entity ID of the sleep mode switch (e.g., `switch.adaptive_lighting_sleep_mode_living_room`). ### Request Example ```yaml # Turn sleep mode on for a room service: switch.turn_on target: entity_id: switch.adaptive_lighting_sleep_mode_living_room # Turn sleep mode off (resume normal adaptation) service: switch.turn_off target: entity_id: switch.adaptive_lighting_sleep_mode_living_room ``` ### Response #### Success Response (200) None explicitly documented. #### Response Example None explicitly documented. ``` -------------------------------- ### Enable Selective Pause Mode Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt Configure adaptive lighting to only suspend changed attributes and auto-resume after a specified duration. Set 'detect_non_ha_changes' to false to prevent spurious turn-ons. ```yaml adaptive_lighting: - name: "Selective pause" lights: - light.living_room take_over_control: true take_over_control_mode: pause_changed # only suspend the changed attribute autoreset_control_seconds: 7200 # auto-resume after 2 hours detect_non_ha_changes: false # keep false to avoid spurious turn-ons ``` -------------------------------- ### Enable Multi-Light Interception Source: https://github.com/basnijholt/adaptive-lighting/blob/main/README.md Set `multi_light_intercept` to `True` to intercept and adapt `light.turn_on` calls targeting multiple lights. This may split calls if lights are on different switches and requires `intercept` to be enabled. ```yaml multi_light_intercept: True ``` -------------------------------- ### Change Switch Settings Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/services.md This service allows you to dynamically change various configuration options of an Adaptive Lighting switch without restarting Home Assistant. These changes are temporary and will be reset on restart unless explicitly saved. ```APIDOC ## adaptive_lighting.change_switch_settings ### Description Change any of the configuration options of Adaptive Lighting with a service call directly from your script/automation. These settings will not be written to your config and will be reset on restart of Home Assistant. ### Method service ### Endpoint adaptive_lighting.change_switch_settings ### Parameters #### Request Body - **entity_id** (string) - Required - The entity ID of the Adaptive Lighting switch. - **use_defaults** (string) - Optional - Choose from `factory`, `configuration`, or `current` to reset variables not being set with this service call. `current` leaves them as they are, `configuration` resets to initial startup values, `factory` resets to default values listed in the documentation. - **all other keys** (except the ones in the table below ⚠️) - Optional - See the table below for disallowed keys. #### Disallowed Service Data - **entity_id**: You cannot change the switch's `entity_id`, as it has already been registered. - **lights**: You may call `adaptive_lighting.apply` with your lights or create a new config instead. - **name**: You can rename your switch's display name in Home Assistant's UI. - **interval**: The interval is used only once when the config loads. A config change and restart are required. ### Request Example ```yaml service: adaptive_lighting.change_switch_settings data: entity_id: switch.adaptive_lighting_living_room min_color_temp: 2500 max_color_temp: 4000 ``` ### Request Example ```yaml service: adaptive_lighting.change_switch_settings data: entity_id: switch.adaptive_lighting_bedroom sunrise_time: "07:00:00" use_defaults: current ``` ### Request Example ```yaml service: adaptive_lighting.change_switch_settings data: entity_id: switch.adaptive_lighting_living_room use_defaults: configuration ``` ``` -------------------------------- ### Configure Brightness Modes Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt Set the `brightness_mode` to control how brightness is calculated around sunrise and sunset. Options include `default` (mirrors sun position), `linear`, and `tanh` (time-windowed ramps). Configure ramp times with `brightness_mode_time_dark` and `brightness_mode_time_light`. ```yaml # Default mode — brightness mirrors sun position (parabolic curve) adaptive_lighting: - name: "Default curve" lights: [light.hall] brightness_mode: default # max at noon, min at midnight ``` ```yaml # Linear mode — flat ramp around sunrise/sunset adaptive_lighting: - name: "Linear ramp" lights: [light.kitchen] brightness_mode: linear brightness_mode_time_dark: 600 # ramp 10 min into darkness brightness_mode_time_light: 1800 # ramp 30 min into daylight ``` ```yaml # Tanh mode — smooth S-curve (avoids abrupt changes at ramp boundaries) adaptive_lighting: - name: "Smooth S-curve" lights: [light.bedroom] brightness_mode: tanh brightness_mode_time_dark: 1200 # 20 min dark ramp brightness_mode_time_light: 3600 # 1 h light ramp min_brightness: 5 max_brightness: 100 ``` -------------------------------- ### Set Manual Control for Lights Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/services.md Use this service to mark or unmark a light as manually controlled, preventing Adaptive Lighting from adjusting it. Specify the switch entity ID and optionally the lights to affect. Set `manual_control` to `true` to pause adaptation or `false` to resume. You can also specify selective attributes like 'brightness' or 'color' for partial manual control. ```yaml service: adaptive_lighting.set_manual_control data: entity_id: switch.adaptive_lighting_living_room lights: - light.floor_lamp manual_control: false ``` ```yaml service: adaptive_lighting.set_manual_control data: entity_id: switch.adaptive_lighting_living_room lights: - light.floor_lamp manual_control: true ``` -------------------------------- ### adaptive_lighting.change_switch_settings Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt Dynamically changes any configuration option of a running Adaptive Lighting switch at runtime. Changes take effect immediately but are not persisted — they reset on HA restart. ```APIDOC ## adaptive_lighting.change_switch_settings ### Description Dynamically changes any configuration option of a running Adaptive Lighting switch at runtime. Changes take effect immediately but are **not** persisted — they reset on HA restart. ### Method Call ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **entity_id** (string) - Required - The entity ID of the Adaptive Lighting switch. - **use_defaults** (string) - Optional - Resets settings to "current", "configuration", or "factory" defaults. - **sunrise_time** (string) - Optional - Sets the sunrise time (e.g., "07:30:00"). - **sunset_time** (string) - Optional - Sets the sunset time (e.g., "19:30:00"). - **brightness_mode** (string) - Optional - Sets the brightness calculation mode: "default", "linear", or "tanh". - **brightness_mode_time_dark** (integer) - Optional - Duration in seconds for the dark ramp in brightness mode. - **brightness_mode_time_light** (integer) - Optional - Duration in seconds for the light ramp in brightness mode. - **min_brightness** (integer) - Optional - Sets the minimum brightness level. - **max_brightness** (integer) - Optional - Sets the maximum brightness level. - **take_over_control_mode** (string) - Optional - Defines how the switch takes over control (e.g., "pause_changed"). ### Request Example ```yaml service: adaptive_lighting.change_switch_settings data: entity_id: switch.adaptive_lighting_living_room sunrise_time: "07:30:00" sunset_time: "19:30:00" ``` ### Response #### Success Response (200) None explicitly documented. #### Response Example None explicitly documented. ``` -------------------------------- ### Trigger Automation on Manual Control Event Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/advanced/manual-control.md Use this automation to react when a light is manually adjusted. It triggers on the `adaptive_lighting.manual_control` event and sends a notification. ```yaml automation: - alias: "Notify on manual control" trigger: platform: event event_type: adaptive_lighting.manual_control action: - service: notify.mobile_app data: message: "{{ trigger.event.data.entity_id }} was manually adjusted" ``` -------------------------------- ### adaptive_lighting.change_switch_settings Source: https://github.com/basnijholt/adaptive-lighting/blob/main/README.md Change configuration options of Adaptive Lighting switches directly from your script or automation. Note that these settings are not persistent and will be reset on Home Assistant restart. ```APIDOC ## adaptive_lighting.change_switch_settings ### Description Change any of the configuration options of Adaptive Lighting (such as `sunrise_time` or `prefer_rgb_color`) with a service call directly from your script/automation. > [!WARNING] > These settings will **not** be written to your config and will be reset on restart of Home Assistant! You can see the current settings in the `switch.adaptive_lighting_XXX` attributes if `include_config_in_attributes` is enabled. ### Method Service Call ### Parameters #### Service Data - **use_defaults** (string) - Optional - Choose from `factory`, `configuration`, or `current` to reset variables not being set with this service call. `current` leaves them as they are, `configuration` resets to initial startup values, `factory` resets to default values listed in the documentation. (default: `current` for current settings) - **all other keys** (except the ones in the table below ⚠️) (any) - Optional - See the table below for disallowed keys. ### Disallowed Service Data Keys - **entity_id**: You cannot change the switch's `entity_id`, as it has already been registered. - **lights**: You may call `adaptive_lighting.apply` with your lights or create a new config instead. - **name**: You can rename your switch's display name in Home Assistant's UI. - **interval**: The interval is used only once when the config loads. A config change and restart are required. ``` -------------------------------- ### Pause Brightness Adaptation Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/services.md Use this service to pause only brightness adaptation while allowing color adaptation to continue. Specify the entity ID of the Adaptive Lighting switch and the lights to control. ```yaml service: adaptive_lighting.set_manual_control data: entity_id: switch.adaptive_lighting_living_room lights: - light.floor_lamp manual_control: brightness ``` -------------------------------- ### Change Adaptive Lighting Switch Settings Source: https://github.com/basnijholt/adaptive-lighting/blob/main/docs/services.md Temporarily modify Adaptive Lighting configuration options like color temperature range or sunrise time. These changes are not persistent and will reset upon Home Assistant restart. Use `use_defaults` to control how other settings are handled. ```yaml service: adaptive_lighting.change_switch_settings data: entity_id: switch.adaptive_lighting_living_room min_color_temp: 2500 max_color_temp: 4000 ``` ```yaml service: adaptive_timing.change_switch_settings data: entity_id: switch.adaptive_lighting_bedroom sunrise_time: "07:00:00" use_defaults: current ``` ```yaml service: adaptive_lighting.change_switch_settings data: entity_id: switch.adaptive_lighting_living_room use_defaults: configuration ``` -------------------------------- ### Service Data for adaptive_lighting.set_manual_control Source: https://github.com/basnijholt/adaptive-lighting/blob/main/README.md This service allows you to mark lights as manually controlled, preventing Adaptive Lighting from adapting them. You can specify the switch entity_id and optionally target specific lights or attributes like 'brightness' or 'color'. ```yaml service: adaptive_lighting.set_manual_control entity_id: switch.adaptive_lighting_default lights: - light.bedroom_lamp manual_control: true ``` -------------------------------- ### Automation: Notify on Manual Control Adjustment Source: https://context7.com/basnijholt/adaptive-lighting/llms.txt Sends a notification to a mobile app whenever any light is manually adjusted, triggering on the 'adaptive_lighting.manual_control' event. ```yaml automation: - alias: "Notify on manual control" trigger: platform: event event_type: adaptive_lighting.manual_control action: - service: notify.mobile_app_phone data: message: "{{ trigger.event.data.entity_id }} was manually adjusted" ```