Merge remote-tracking branch 'origin/main' into fix-async

This commit is contained in:
Bas Nijholt 2025-01-01 12:19:58 -08:00
commit c85254bfed
28 changed files with 1087 additions and 177 deletions

View file

@ -891,6 +891,51 @@
"contributions": [
"translation"
]
},
{
"login": "TamilNeram",
"name": "தமிழ் நேரம்",
"avatar_url": "https://avatars.githubusercontent.com/u/67970539?v=4",
"profile": "https://github.com/TamilNeram",
"contributions": [
"translation"
]
},
{
"login": "Thunderstrike116",
"name": "Thunderstrike116",
"avatar_url": "https://avatars.githubusercontent.com/u/23220766?v=4",
"profile": "https://github.com/Thunderstrike116",
"contributions": [
"translation"
]
},
{
"login": "immeteor2",
"name": "immeteor2",
"avatar_url": "https://avatars.githubusercontent.com/u/125735487?v=4",
"profile": "https://github.com/immeteor2",
"contributions": [
"translation"
]
},
{
"login": "pbassut",
"name": "Patrick Bassut",
"avatar_url": "https://avatars.githubusercontent.com/u/1500037?v=4",
"profile": "https://github.com/pbassut",
"contributions": [
"translation"
]
},
{
"login": "Ricky-Tigg",
"name": "Ricky Tigg",
"avatar_url": "https://avatars.githubusercontent.com/u/26058215?v=4",
"profile": "https://github.com/Ricky-Tigg",
"contributions": [
"translation"
]
}
],
"contributorsPerLine": 7,

View file

@ -18,7 +18,7 @@ If you need help with using or configuring Adaptive Lighting, please [open a Q&A
Please confirm that you have completed the following steps:
- [ ] I have updated to the [latest Adaptive Lighting version](https://github.com/basnijholt/adaptive-lighting/releases) available in [HACS](https://hacs.xyz/).
- [ ] I have reviewed the [Troubleshooting Section](https://github.com/basnijholt/adaptive-lighting#troubleshooting) in the [README](https://github.com/basnijholt/adaptive-lighting#readme).
- [ ] I have reviewed the [Troubleshooting Section](https://github.com/basnijholt/adaptive-lighting#sos-troubleshooting) in the [README](https://github.com/basnijholt/adaptive-lighting#readme).
- [ ] (If using Zigbee2MQTT) I have read the [Zigbee2MQTT troubleshooting guide](https://github.com/basnijholt/adaptive-lighting#zigbee2mqtt) in the [README](https://github.com/basnijholt/adaptive-lighting#readme).
- [ ] I have checked the [V2 Roadmap](https://github.com/basnijholt/adaptive-lighting/discussions/291) and [open issues](https://github.com/basnijholt/adaptive-lighting/issues) to ensure my issue isn't a duplicate.

38
.github/renovate.json vendored Normal file
View file

@ -0,0 +1,38 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"rebaseWhen": "behind-base-branch",
"dependencyDashboard": true,
"labels": [
"dependencies",
"no-stale"
],
"commitMessagePrefix": "⬆️",
"commitMessageTopic": "{{depName}}",
"prBodyDefinitions": {
"Release": "yes"
},
"packageRules": [
{
"matchManagers": [
"github-actions"
],
"addLabels": [
"github_actions"
],
"rangeStrategy": "pin"
},
{
"matchManagers": [
"github-actions"
],
"matchUpdateTypes": [
"minor",
"patch"
],
"automerge": true
}
],
"extends": [
"config:recommended"
]
}

View file

@ -30,16 +30,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set Up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install Dependencies
run: |
pip install -r webapp/requirements-locked.txt
pip install -r webapp/requirements.txt
pip install shinylive
- name: Build the WebAssembly app
run: |
@ -49,14 +50,14 @@ jobs:
shinylive export webapp site
- name: Setup Pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
# Upload the 'site' directory, where your app has been built
path: "site"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4

View file

@ -15,16 +15,16 @@ jobs:
- linux/arm64
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
# Only push on the master branch
push: ${{ github.ref == 'refs/heads/master' }}

View file

@ -11,5 +11,5 @@ jobs:
validate_hassfest:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3.0.2"
- uses: "actions/checkout@v4.2.2"
- uses: home-assistant/actions/hassfest@master

View file

@ -14,21 +14,21 @@ runs:
using: "composite"
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.ref }}
persist-credentials: false
fetch-depth: 0
- name: Check out code from GitHub
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: home-assistant/core
path: core
ref: ${{ inputs.core-version }}
- name: Set up Python ${{ inputs.python-version }}
id: python
uses: actions/setup-python@v4.1.0
uses: actions/setup-python@v5.3.0
with:
python-version: ${{ inputs.python-version }}
- name: Install dependencies

View file

@ -11,7 +11,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0

View file

@ -9,6 +9,6 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1

View file

@ -8,7 +8,7 @@ on:
jobs:
pytest:
name: Run pytest
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 60
strategy:
fail-fast: false
@ -58,11 +58,19 @@ jobs:
core-version: "2024.7.4"
- python-version: "3.12"
core-version: "2024.8.3"
- python-version: "3.12"
core-version: "2024.9.3"
- python-version: "3.12"
core-version: "2024.10.4"
- python-version: "3.12"
core-version: "2024.11.3"
- python-version: "3.12"
core-version: "2024.12.0"
- python-version: "3.12"
core-version: "dev"
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Home Assistant
uses: ./.github/workflows/install_dependencies

View file

@ -17,6 +17,6 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Home Assistant
uses: ./.github/workflows/install_dependencies

View file

@ -11,7 +11,7 @@ jobs:
validate_hacs:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2"
- uses: "actions/checkout@v4"
- name: HACS validation
uses: "hacs/action@main"
with:

View file

@ -7,7 +7,7 @@
# Optionally build the image yourself with:
# docker build -t basnijholt/adaptive-lighting:latest .
FROM python:3.12-bookworm
FROM python:3.13-bookworm
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \

111
README.md
View file

@ -1,7 +1,7 @@
[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge)](https://github.com/hacs/integration)
![Version](https://img.shields.io/github/v/release/basnijholt/adaptive-lighting?style=for-the-badge)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-97-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-102-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
# 🌞 Adaptive Lighting: Enhance Your Home's Atmosphere with Smart, Sun-Synchronized Lighting 🌙
@ -103,46 +103,46 @@ The YAML and frontend configuration methods support all of the options listed be
<!-- START_OUTPUT -->
<!-- THIS CONTENT IS AUTOMATICALLY GENERATED -->
| Variable name | Description | Default | Type |
|:-------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------|:---------------------------------------|
| `lights` | List of light entity_ids to be controlled (may be empty). 🌟 | `[]` | list of `entity_id`s |
| `interval` | Frequency to adapt the lights, in seconds. 🔄 | `90` | `int > 0` |
| `transition` | Duration of transition when lights change, in seconds. 🕑 | `45` | `float` 0-6553 |
| `initial_transition` | Duration of the first transition when lights turn from `off` to `on` in seconds. ⏲️ | `1` | `float` 0-6553 |
| `min_brightness` | Minimum brightness percentage. 💡 | `1` | `int` 1-100 |
| `max_brightness` | Maximum brightness percentage. 💡 | `100` | `int` 1-100 |
| `min_color_temp` | Warmest color temperature in Kelvin. 🔥 | `2000` | `int` 1000-10000 |
| `max_color_temp` | Coldest color temperature in Kelvin. ❄️ | `5500` | `int` 1000-10000 |
| `prefer_rgb_color` | Whether to prefer RGB color adjustment over light color temperature when possible. 🌈 | `False` | `bool` |
| `sleep_brightness` | Brightness percentage of lights in sleep mode. 😴 | `1` | `int` 1-100 |
| `sleep_rgb_or_color_temp` | Use either `"rgb_color"` or `"color_temp"` in sleep mode. 🌙 | `color_temp` | one of `['color_temp', 'rgb_color']` |
| `sleep_color_temp` | Color temperature in sleep mode (used when `sleep_rgb_or_color_temp` is `color_temp`) in Kelvin. 😴 | `1000` | `int` 1000-10000 |
| `sleep_rgb_color` | RGB color in sleep mode (used when `sleep_rgb_or_color_temp` is "rgb_color"). 🌈 | `[255, 56, 0]` | RGB color |
| `sleep_transition` | Duration of transition when "sleep mode" is toggled in seconds. 😴 | `1` | `float` 0-6553 |
| `transition_until_sleep` | When enabled, Adaptive Lighting will treat sleep settings as the minimum, transitioning to these values after sunset. 🌙 | `False` | `bool` |
| `sunrise_time` | Set a fixed time (HH:MM:SS) for sunrise. 🌅 | `None` | `str` |
| `min_sunrise_time` | Set the earliest virtual sunrise time (HH:MM:SS), allowing for later sunrises. 🌅 | `None` | `str` |
| `max_sunrise_time` | Set the latest virtual sunrise time (HH:MM:SS), allowing for earlier sunrises. 🌅 | `None` | `str` |
| `sunrise_offset` | Adjust sunrise time with a positive or negative offset in seconds. ⏰ | `0` | `int` |
| `sunset_time` | Set a fixed time (HH:MM:SS) for sunset. 🌇 | `None` | `str` |
| `min_sunset_time` | Set the earliest virtual sunset time (HH:MM:SS), allowing for later sunsets. 🌇 | `None` | `str` |
| `max_sunset_time` | Set the latest virtual sunset time (HH:MM:SS), allowing for earlier sunsets. 🌇 | `None` | `str` |
| `sunset_offset` | Adjust sunset time with a positive or negative offset in seconds. ⏰ | `0` | `int` |
| `brightness_mode` | Brightness mode to use. Possible values are `default`, `linear`, and `tanh` (uses `brightness_mode_time_dark` and `brightness_mode_time_light`). 📈 | `default` | one of `['default', 'linear', 'tanh']` |
| Variable name | Description | Default | Type |
|:-------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------|:---------------------------------------|
| `lights` | List of light entity_ids to be controlled (may be empty). 🌟 | `[]` | list of `entity_id`s |
| `interval` | Frequency to adapt the lights, in seconds. 🔄 | `90` | `int > 0` |
| `transition` | Duration of transition when lights change, in seconds. 🕑 | `45` | `float` 0-6553 |
| `initial_transition` | Duration of the first transition when lights turn from `off` to `on` in seconds. ⏲️ | `1` | `float` 0-6553 |
| `min_brightness` | Minimum brightness percentage. 💡 | `1` | `int` 1-100 |
| `max_brightness` | Maximum brightness percentage. 💡 | `100` | `int` 1-100 |
| `min_color_temp` | Warmest color temperature in Kelvin. 🔥 | `2000` | `int` 1000-10000 |
| `max_color_temp` | Coldest color temperature in Kelvin. ❄️ | `5500` | `int` 1000-10000 |
| `prefer_rgb_color` | Whether to prefer RGB color adjustment over light color temperature when possible. 🌈 | `False` | `bool` |
| `sleep_brightness` | Brightness percentage of lights in sleep mode. 😴 | `1` | `int` 1-100 |
| `sleep_rgb_or_color_temp` | Use either `"rgb_color"` or `"color_temp"` in sleep mode. 🌙 | `color_temp` | one of `['color_temp', 'rgb_color']` |
| `sleep_color_temp` | Color temperature in sleep mode (used when `sleep_rgb_or_color_temp` is `color_temp`) in Kelvin. 😴 | `1000` | `int` 1000-10000 |
| `sleep_rgb_color` | RGB color in sleep mode (used when `sleep_rgb_or_color_temp` is "rgb_color"). 🌈 | `[255, 56, 0]` | RGB color |
| `sleep_transition` | Duration of transition when "sleep mode" is toggled in seconds. 😴 | `1` | `float` 0-6553 |
| `transition_until_sleep` | When enabled, Adaptive Lighting will treat sleep settings as the minimum, transitioning to these values after sunset. 🌙 | `False` | `bool` |
| `sunrise_time` | Set a fixed time (HH:MM:SS) for sunrise. 🌅 | `None` | `str` |
| `min_sunrise_time` | Set the earliest virtual sunrise time (HH:MM:SS), allowing for later sunrises. 🌅 | `None` | `str` |
| `max_sunrise_time` | Set the latest virtual sunrise time (HH:MM:SS), allowing for earlier sunrises. 🌅 | `None` | `str` |
| `sunrise_offset` | Adjust sunrise time with a positive or negative offset in seconds. ⏰ | `0` | `int` |
| `sunset_time` | Set a fixed time (HH:MM:SS) for sunset. 🌇 | `None` | `str` |
| `min_sunset_time` | Set the earliest virtual sunset time (HH:MM:SS), allowing for later sunsets. 🌇 | `None` | `str` |
| `max_sunset_time` | Set the latest virtual sunset time (HH:MM:SS), allowing for earlier sunsets. 🌇 | `None` | `str` |
| `sunset_offset` | Adjust sunset time with a positive or negative offset in seconds. ⏰ | `0` | `int` |
| `brightness_mode` | Brightness mode to use. Possible values are `default`, `linear`, and `tanh` (uses `brightness_mode_time_dark` and `brightness_mode_time_light`). 📈 | `default` | one of `['default', 'linear', 'tanh']` |
| `brightness_mode_time_dark` | (Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness before/after sunrise/sunset. 📈📉 | `900` | `int` |
| `brightness_mode_time_light` | (Ignored if `brightness_mode='default'`) The duration in seconds to ramp up/down the brightness after/before sunrise/sunset. 📈📉. | `3600` | `int` |
| `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`! 🔒 | `True` | `bool` |
| `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. | `False` | `bool` |
| `autoreset_control_seconds` | Automatically reset the manual control after a number of seconds. Set to 0 to disable. ⏲️ | `0` | `int` 0-31536000 |
| `only_once` | Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). 🔄 | `False` | `bool` |
| `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`! 🔒 | `True` | `bool` |
| `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. | `False` | `bool` |
| `autoreset_control_seconds` | Automatically reset the manual control after a number of seconds. Set to 0 to disable. ⏲️ | `0` | `int` 0-31536000 |
| `only_once` | Adapt lights only when they are turned on (`true`) or keep adapting them (`false`). 🔄 | `False` | `bool` |
| `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. 🕵️ | `False` | `bool` |
| `separate_turn_on_commands` | Use separate `light.turn_on` calls for color and brightness, needed for some light types. 🔀 | `False` | `bool` |
| `send_split_delay` | Delay (ms) between `separate_turn_on_commands` for lights that don't support simultaneous brightness and color setting. ⏲️ | `0` | `int` 0-10000 |
| `adapt_delay` | Wait time (seconds) between light turn on and Adaptive Lighting applying changes. Might help to avoid flickering. ⏲️ | `0` | `float > 0` |
| `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. | `False` | `bool` |
| `intercept` | Intercept and adapt `light.turn_on` calls to enabling instantaneous color and brightness adaptation. 🏎️ Disable for lights that do not support `light.turn_on` with color and brightness. | `True` | `bool` |
| `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. Requires `intercept` to be enabled. | `True` | `bool` |
| `include_config_in_attributes` | Show all options as attributes on the switch in Home Assistant when set to `true`. 📝 | `False` | `bool` |
| `separate_turn_on_commands` | Use separate `light.turn_on` calls for color and brightness, needed for some light types. 🔀 | `False` | `bool` |
| `send_split_delay` | Delay (ms) between `separate_turn_on_commands` for lights that don't support simultaneous brightness and color setting. ⏲️ | `0` | `int` 0-10000 |
| `adapt_delay` | Wait time (seconds) between light turn on and Adaptive Lighting applying changes. Might help to avoid flickering. ⏲️ | `0` | `float > 0` |
| `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. | `False` | `bool` |
| `intercept` | Intercept and adapt `light.turn_on` calls to enabling instantaneous color and brightness adaptation. 🏎️ Disable for lights that do not support `light.turn_on` with color and brightness. | `True` | `bool` |
| `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. Requires `intercept` to be enabled. | `True` | `bool` |
| `include_config_in_attributes` | Show all options as attributes on the switch in Home Assistant when set to `true`. 📝 | `False` | `bool` |
<!-- END_OUTPUT -->
@ -186,15 +186,15 @@ adaptive_lighting:
<!-- START_OUTPUT -->
<!-- THIS CONTENT IS AUTOMATICALLY GENERATED -->
| Service data attribute | Description | Required | Type |
|:-------------------------|:--------------------------------------------------------------------------------------|:-----------|:---------------------|
| `entity_id` | The `entity_id` of the switch with the settings to apply. 📝 | ✅ | list of `entity_id`s |
| `lights` | A light (or list of lights) to apply the settings to. 💡 | ❌ | list of `entity_id`s |
| `transition` | Duration of transition when lights change, in seconds. 🕑 | ❌ | `float` 0-6553 |
| `adapt_brightness` | Whether to adapt the brightness of the light. 🌞 | ❌ | bool |
| `adapt_color` | Whether to adapt the color on supporting lights. 🌈 | ❌ | bool |
| `prefer_rgb_color` | Whether to prefer RGB color adjustment over light color temperature when possible. 🌈 | ❌ | bool |
| `turn_on_lights` | Whether to turn on lights that are currently off. 🔆 | ❌ | bool |
| Service data attribute | Description | Required | Type |
|:-------------------------|:-------------------------------------------------------------------------------------|:-----------|:---------------------|
| `entity_id` | The `entity_id` of the switch with the settings to apply. 📝 | ✅ | list of `entity_id`s |
| `lights` | A light (or list of lights) to apply the settings to. 💡 | ❌ | list of `entity_id`s |
| `transition` | Duration of transition when lights change, in seconds. 🕑 | ❌ | `float` 0-6553 |
| `adapt_brightness` | Whether to adapt the brightness of the light. 🌞 | ❌ | bool |
| `adapt_color` | Whether to adapt the color on supporting lights. 🌈 | ❌ | bool |
| `prefer_rgb_color` | Whether to prefer RGB color adjustment over light color temperature when possible. 🌈 | ❌ | bool |
| `turn_on_lights` | Whether to turn on lights that are currently off. 🔆 | ❌ | bool |
<!-- END_OUTPUT -->
#### `adaptive_lighting.set_manual_control`
@ -208,11 +208,11 @@ adaptive_lighting:
<!-- START_OUTPUT -->
<!-- THIS CONTENT IS AUTOMATICALLY GENERATED -->
| Service data attribute | Description | Required | Type |
|:-------------------------|:------------------------------------------------------------------------------------------------|:-----------|:---------------------|
| `entity_id` | The `entity_id` of the switch in which to (un)mark the light as being `manually controlled`. 📝 | ✅ | list of `entity_id`s |
| `lights` | entity_id(s) of lights, if not specified, all lights in the switch are selected. 💡 | ❌ | list of `entity_id`s |
| `manual_control` | Whether to add ("true") or remove ("false") the light from the "manual_control" list. 🔒 | ❌ | bool |
| Service data attribute | Description | Required | Type |
|:-------------------------|:-----------------------------------------------------------------------------------------------|:-----------|:---------------------|
| `entity_id` | The `entity_id` of the switch in which to (un)mark the light as being `manually controlled`. 📝 | ✅ | list of `entity_id`s |
| `lights` | entity_id(s) of lights, if not specified, all lights in the switch are selected. 💡 | ❌ | list of `entity_id`s |
| `manual_control` | Whether to add ("true") or remove ("false") the light from the "manual_control" list. 🔒 | ❌ | bool |
<!-- END_OUTPUT -->
#### `adaptive_lighting.change_switch_settings`
@ -589,6 +589,13 @@ Notice the values of `brightness_mode_time_light` and `brightness_mode_time_dark
<td align="center" valign="top" width="14.28%"><a href="https://carmodsheaven.com"><img src="https://avatars.githubusercontent.com/u/11273726?v=4?s=100" width="100px;" alt="Lucho Gizdov"/><br /><sub><b>Lucho Gizdov</b></sub></a><br /><a href="#translation-lachezar-gizdov" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/MizterB"><img src="https://avatars.githubusercontent.com/u/5458030?v=4?s=100" width="100px;" alt="MizterB"/><br /><sub><b>MizterB</b></sub></a><br /><a href="https://github.com/basnijholt/adaptive-lighting/commits?author=MizterB" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/brietman"><img src="https://avatars.githubusercontent.com/u/17436537?v=4?s=100" width="100px;" alt="brietman"/><br /><sub><b>brietman</b></sub></a><br /><a href="#translation-brietman" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/TamilNeram"><img src="https://avatars.githubusercontent.com/u/67970539?v=4?s=100" width="100px;" alt="தமிழ் நேரம்"/><br /><sub><b>தமிழ் நேரம்</b></sub></a><br /><a href="#translation-TamilNeram" title="Translation">🌍</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Thunderstrike116"><img src="https://avatars.githubusercontent.com/u/23220766?v=4?s=100" width="100px;" alt="Thunderstrike116"/><br /><sub><b>Thunderstrike116</b></sub></a><br /><a href="#translation-Thunderstrike116" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/immeteor2"><img src="https://avatars.githubusercontent.com/u/125735487?v=4?s=100" width="100px;" alt="immeteor2"/><br /><sub><b>immeteor2</b></sub></a><br /><a href="#translation-immeteor2" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/pbassut"><img src="https://avatars.githubusercontent.com/u/1500037?v=4?s=100" width="100px;" alt="Patrick Bassut"/><br /><sub><b>Patrick Bassut</b></sub></a><br /><a href="#translation-pbassut" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Ricky-Tigg"><img src="https://avatars.githubusercontent.com/u/26058215?v=4?s=100" width="100px;" alt="Ricky Tigg"/><br /><sub><b>Ricky Tigg</b></sub></a><br /><a href="#translation-Ricky-Tigg" title="Translation">🌍</a></td>
</tr>
</tbody>
<tfoot>

View file

@ -0,0 +1,19 @@
{
"title": "Adaptive Lighting",
"options": {
"step": {
"init": {
"title": "Επιλογές Adaptive Lighting"
}
}
},
"services": {
"change_switch_settings": {
"fields": {
"only_once": {
"description": "Προσαρμογή των φώτων μόνο όταν είναι αναμμένα (`true`) ή συνεχής προσαρμογή αυτών (`false`). 🔄"
}
}
}
}
}

View file

@ -28,8 +28,69 @@
},
"transition": {
"description": "Valojen siirtymän kesto sekunneissa, kun valaistusta muutetaan."
},
"sleep_color_temp": {
"description": "Värilämpötila lepotilassa (käytetään, kun `sleep_rgb_or_color_temp` on `color_temp`) kelvineinä. 😴"
},
"detect_non_ha_changes": {
"description": "Havaitsee ja pysäyttää mukautukset ei-\"light.turn_on\" -tilanmuutoksille. Vaatii \"take_over_control\":n käyttöönoton. 🕵️ Varoitus: ⚠️ Jotkut valot saatavat osoittaa virheellisesti 'on'-tilan, mikä voi johtaa valojen syttymiseen odottamatta. Poista tämä ominaisuus käytöstä, jos kohtaat tällaisia ongelmia."
},
"sunrise_time": {
"description": "Aseta kiinteä aika (TT:MM:SS) auringonnousulle. 🌅"
},
"use_defaults": {
"description": "Asettaa oletusarvot, joita ei ole määritetty tässä palvelukutsussa. Vaihtoehdot: \"nykyinen\" (oletus, säilyttää nykyiset arvot), \"tehdas\" (palauttaa dokumentoituihin oletusasetuksiin) tai \"kokoonpano\" (palaa kokoonpanon oletusasetusten vaihtamiseksi). ⚙️"
},
"max_sunrise_time": {
"description": "Aseta viimeisin virtuaalinen auringonnousuaika (TT:MM:SS), aikaisempia auringonnousuja sallien. 🌅"
},
"separate_turn_on_commands": {
"description": "Käytä erillisiä \"light.turn_on\" -kutsuja värin ja kirkkauden määrittämiseksi, joita tarvitaan joissakin valotyypeissä. 🔀"
},
"entity_id": {
"description": "Kytkimen entiteettitunnus. 📝"
},
"turn_on_lights": {
"description": "Sytytetäänkö valot, jotka ovat tällä hetkellä pois päältä. 🔆"
},
"include_config_in_attributes": {
"description": "Näytä kaikki vaihtoehdot attribuutteina kotiavustajan kytkimellä, kun sen arvo on \"true\". 📝"
},
"sleep_transition": {
"description": "Siirtymän kesto, kun \"lepotila\" vaihdetaan sekunneiksi. 😴"
},
"max_brightness": {
"description": "Enimmäiskirkkausprosentti. 💡"
},
"min_brightness": {
"description": "Vähittäiskirkkausprosentti. 💡"
},
"sleep_rgb_color": {
"description": "RGB-väri lepotilassa (käytetään, kun `sleep_rgb_or_color_temp` on \"rgb_color\"). 🌈"
},
"sunset_time": {
"description": "Aseta kiinteä aika (TT:MM:SS) auringonlaskulle. 🌇"
},
"sleep_rgb_or_color_temp": {
"description": "Käytä joko `\"rgb_color\"` tai `\"color_temp\"` lepotilassa. 🌙"
},
"min_color_temp": {
"description": "Lämpimin värilämpötila kelvineissä. 🔥"
},
"prefer_rgb_color": {
"description": "Halutaanko RGB-värinsäätö mieluummin valon värilämpötilan sijaan, kun mahdollista. 🌈"
},
"take_over_control": {
"description": "Poista Adaptive Lighting käytöstä, jos toinen lähde kutsuu `light.turn_on`, kun valot ovat päällä ja niitä mukautetaan. Huomaa, että tämä kutsuu `homeassistant.update_entity` joka `interval`! 🔒"
},
"min_sunset_time": {
"description": "Aseta aikaisin virtuaalinen auringonlaskuaika (TT:MM:SS), myöhempiä auringonlaskuja sallien. 🌇"
},
"adapt_delay": {
"description": "Odotusaika (sekunteina) valon syttymisen ja Adaptive Lightingin muutosten käyttöönoton välillä. Saattaa auttaa välttämään välkkymistä. ⏲️"
}
}
},
"description": "Muuta haluamiasi asetuksia kytkimessä. Kaikki vaihtoehdot ovat samat kuin kokoonpanon kulussa."
},
"apply": {
"description": "Asettaa nykyiset Adaptiivisen Valaistuksen asetukset valoihin.",
@ -39,8 +100,37 @@
},
"transition": {
"description": "Valojen siirtymän kesto sekunneissa, kun valaistusta muutetaan."
},
"entity_id": {
"description": "Kytkimen `entity_id` ja käytettävät asetukset. 📝"
},
"adapt_brightness": {
"description": "Mukautetaanko valon kirkkautta. 🌞"
},
"adapt_color": {
"description": "Mukautetaanko tukivalojen väriä. 🌈"
},
"prefer_rgb_color": {
"description": "Halutaanko RGB-värinsäätö mieluummin valon värilämpötilan sijaan, kun mahdollista. 🌈"
},
"turn_on_lights": {
"description": "Sytytetäänkö valot, jotka ovat tällä hetkellä pois päältä. 🔆"
}
}
},
"set_manual_control": {
"fields": {
"lights": {
"description": "Valojen entity_id(s), jos sitä ei ole määritetty, kaikki kytkimen valot valitaan. 💡"
},
"entity_id": {
"description": "Kytkimen `entity_id`, jolla valo määritetään `manuaalisesti ohjattavaksi`. 📝"
},
"manual_control": {
"description": "Lisätäänkö (\"true\") vai poistetaanko (\"false\") valo \"manual_control\"-luettelosta. 🔒"
}
},
"description": "Merkitse, onko valo 'manuaalisesti ohjattu'."
}
},
"title": "Adaptiivinen valaistus",
@ -55,16 +145,57 @@
"brightness_mode": "Kirkkaus-moodi jota käytetään. Mahdolliset arvot ovat `default`, `linear`, and `tanh` (käyttää arvoja `brightness_mode_time_dark` ja `brightness_mode_time_light`).",
"sunset_offset": "Muuta auringonlaskun aikaa positiivisella tai negatiivisella korjauksella määritettynä sekunneissa.",
"initial_transition": "Ensimmäisen siirtymän kesto sekunneissa, kun valot kytketään 'off'-tilasta 'on'-tilaan.",
"send_split_delay": "Viive (ms) `separate_turn_on_commands` välillä valoille, jotka eivät tue yhtäaikaista kirkkauden ja värilämpötilan säätöä."
}
"send_split_delay": "Viive (ms) `separate_turn_on_commands` välillä valoille, jotka eivät tue yhtäaikaista kirkkauden ja värilämpötilan säätöä.",
"sleep_color_temp": "Värilämpötila lepotilassa (käytetään, kun `sleep_rgb_or_color_temp` on `color_temp`) kelvineinä. 😴",
"brightness_mode_time_dark": "(Ohitetaan, jos `brightness_mode='default'`) Kesto sekunteina kirkkauden lisäämiseen/vähentämiseen auringonnousun/auringonlaskun jälkeen/ennen. 📈📉.",
"adapt_delay": "Odotusaika (sekunteina) valon syttymisen ja Adaptive Lightingin muutosten käyttöönoton välillä. Saattaa auttaa välttämään välkkymistä. ⏲️",
"sleep_transition": "Siirtymän kesto, kun \"lepotila\" vaihdetaan sekunneiksi. 😴",
"interval": "Tiheys valojen mukauttamiseen sekunneissa. 🔄",
"brightness_mode_time_light": "(Ohitetaan, jos `brightness_mode='default'`) Kesto sekunteina kirkkauden lisäämiseen/vähentämiseen auringonnousun/auringonlaskun jälkeen/ennen. 📈📉.",
"sleep_rgb_color": "RGB-väri lepotilassa (käytetään, kun `sleep_rgb_or_color_temp` on \"rgb_color\"). 🌈",
"sunrise_time": "Aseta kiinteä aika (TT:MM:SS) auringonnousulle. 🌅",
"sunset_time": "Aseta kiinteä aika (TT:MM:SS) auringonlaskulle. 🌇",
"min_sunset_time": "Aseta aikaisin virtuaalinen auringonlaskuaika (TT:MM:SS), myöhempiä auringonlaskuja sallien. 🌅",
"min_sunrise_time": "Aseta aikaisin virtuaalinen auringonnousuaika (TT:MM:SS), myöhempiä auringonnousuja sallien. 🌅",
"max_sunrise_time": "Aseta aikaisin virtuaalinen auringonnousuaika (TT:MM:SS), aikaisempia auringonnousuja sallien. 🌅",
"sleep_rgb_or_color_temp": "Käytä joko `\"rgb_color\"` tai `\"color_temp\"` lepotilassa. 🌙"
},
"description": "Määritä Adaptive Lighting -komponentti. Vaihtoehtojen nimet vastaavat YAML-asetuksia. Jos olet määrittänyt tämän merkinnän YAML:ssa, tässä ei näy vaihtoehtoja. Interaktiiviset kaaviot, jotka esittelevät parametrien vaikutuksia, on [tässä verkkosovelluksessa](https://basnijholt.github.io/adaptive-lighting). Lisätietoja löytyy [virallisesta dokumentaatiosta](https://github.com/basnijholt/adaptive-lighting#readme).",
"data": {
"adapt_only_on_bare_turn_on": "adapt_only_on_bare_turn_on: Kun valot sytytetään ensimmäisen kerran. Jos asetuksena on \"true\", Adaptive Lighting mukautuu vain, jos \"light.turn_on\" kutsutaan määrittelemättä väriä tai kirkkautta. ❌🌈 Tämä esimerkiksi estää mukautumisen näkymää aktivoitaessa. Jos \"false\", Adaptive Lighting mukautuu riippumatta siitä, onko alkuperäisessä \"service_data\"-arvossa väri tai kirkkaus. Vaatii \"take_over_control\":n käyttöönoton. 🕵️ ",
"multi_light_intercept": "multi_light_intercept: sieppaa ja mukauta light.turn_on-kutsut, jotka kohdistuvat useisiin valoihin. ➗⚠️ Tämä saattaa johtaa yksittäisen light.turn_on-kutsun jakamiseen useiksi kutsuiksi, esimerkiksi kun valot ovat eri kytkimissä. Vaadi `intercept`:n käyttöönotto.",
"only_once": "only_once: Mukauta valot vain, kun ne ovat päällä (\"true\") tai mukauta niitä jatkuvasti (\"false\"). 🔄",
"skip_redundant_commands": "skip_redundant_commands: Ohita mukautuskomentojen lähettäminen, joiden kohdetila on jo yhtä suuri kuin valon tunnettu tila. Minimoi verkkoliikenteen ja parantaa mukautumisvastetta joissain tilanteissa. 📉 Poista käytöstä, jos fyysiset valotilat eivät ole synkronoitu kotiavustajan tallennetun tilan kanssa.",
"take_over_control": "take_over_control: Poista mukautuva valaistus käytöstä, jos toinen lähde kutsuu `light.turn_on`, kun valot ovat päällä ja niitä mukautetaan. Huomaa, että tämä kutsuu `homeassistant.update_entity` joka `interval`! 🔒",
"detect_non_ha_changes": "detect_non_ha_changes: Havaitsee ja pysäyttää mukautukset ei-\"light.turn_on\" -tilanmuutoksille. Vaatii \"take_over_control\" käyttöönoton. 🕵️ Varoitus: ⚠️ Jotkut valot saatavat osoittaa virheellisesti 'on'-tilan, mikä voi johtaa valojen syttymiseen odottamatta. Poista tämä ominaisuus käytöstä, jos kohtaat tällaisia ongelmia.",
"lights": "lights: Luettelo ohjattavista valon entity_ids:stä (voi olla tyhjä). 🌟",
"max_brightness": "max_brightness: Enimmäiskirkkausprosentti. 💡",
"max_color_temp": "max_color_temp: Kylmin värilämpötila kelvineinä. ❄️",
"min_brightness": "min_brightness: Vähittäiskirkkausprosentti. 💡",
"min_color_temp": "min_color_temp: Lämpimin värilämpötila kelvineinä. 🔥",
"prefer_rgb_color": "prefer_rgb_color: valitaanko RGB-värien säätö valon värilämpötilan sijaan, kun mahdollista. 🌈",
"transition_until_sleep": "shift_until_sleep: Kun käytössä, Adaptive Lighting käsittelee lepoasetukset miniminä ja siirtyy näihin arvoihin auringonlaskun jälkeen. 🌙",
"include_config_in_attributes": "include_config_in_attributes: Näytä kaikki vaihtoehdot attribuutteina Kotiavustajan kytkimessä, kun asetuksena on \"true\". 📝",
"intercept": "intercept: sieppaa ja mukauta \"light.turn_on\"-kutsut mahdollistamaan välitön värin ja kirkkauden mukauttaminen. 🏎️ Poista käytöstä valot, jotka eivät tue \"light.turn_on\" värin ja kirkkauden kanssa.",
"separate_turn_on_commands": "separate_turn_on_commands: Käytä erillisiä `light.turn_on`-kutsuja värin ja kirkkauden määrittämiseksi, joita tarvitaan joissakin valotyypeissä. 🔀"
},
"title": "Adaptive Lightingin vaihtoehdot"
}
},
"error": {
"option_error": "Virheellinen vaihtoehto",
"entity_missing": "Kotiavustajasta puuttuu yksi tai useampi valittu valoentiteetti"
}
},
"config": {
"step": {
"user": {
"title": "Valitse nimi tälle Adaptiivisen Valaistuksen esiintymälle"
"title": "Valitse nimi tälle Adaptiivisen Valaistuksen esiintymälle",
"description": "Jokainen esiintymä voi sisältää useita valoja!"
}
},
"abort": {
"already_configured": "Tämä laite on jo määritetty"
}
}
}

View file

@ -11,6 +11,9 @@
},
"sunset_offset": {
"description": "日の入時間を基準に秒単位で正値もしくは負値で調整する。⏰"
},
"entity_id": {
"description": "スイッチのエンティティID。 📝"
}
}
},

View file

@ -43,7 +43,7 @@
"sunset_time": "sunset_time: handmatige onderdrukking van de zonsondergangstijd, indien 'Geen', wordt de werkelijke zonsopgangstijd op uw locatie gebruikt (UU:MM:SS)",
"min_sunset_time": "min_sunset_time: handmatige onderdrukking van de minimale zonsondergangstijd, indien 'Geen', wordt de werkelijke zonsondergangstijd op uw locatie gebruikt (UU:MM:SS)",
"take_over_control": "take_over_control: Als iets anders dan Adaptieve verlichting 'light.turn_on' roept wanneer een lamp al aan is, stop dan met het aanpassen van het licht totdat het (of de schakelaar) uit -> aan gaat.",
"detect_non_ha_changes": "detect_non_ha_changes: detecteert alle >10% wijzigingen aan de lichten (ook buiten HA), vereist dat 'take_over_control' is ingeschakeld (heet 'homeassistant.update_entity' elke 'interval'!)",
"detect_non_ha_changes": "detect_non_ha_changes: Detecteert en stopt aanpassingen voor`light.turn_on` statuswijzigingen. Vereist dat`take_over_control` is ingeschakeld. 🕵️ Voorzichtig: ⚠️ Sommige lampen kunnen een 'aan' status vals aangeven, wat kan leiden tot onverwacht inschakelen van lampen. Schakel deze functie uit als je dergelijke problemen tegenkomt.",
"transition": "Overgangstijd bij het aanbrengen van een wijziging op de lichten (seconden)",
"adapt_delay": "adapt_delay: wachttijd tussen het inschakelen van het licht (seconden) en het aanbrengen van wijzigingen in de lichtstatus door Adaptieve verlichting. Kan flikkering voorkomen.",
"adapt_only_on_bare_turn_on": "adapt_only_on_bare_turn_on: Bij het initieel inschakelen van de lampen. Als dit op `true` is ingesteld, past Av alleen aan als `light.turn_on` wordt aangeroepen zonder een kleur of helderheid te specificeren. ❌🌈 Dit voorkomt bijvoorbeeld aanpassing bij het activeren van een scène. Als het `false` is, past Av aan ongeacht de aanwezigheid van kleur of helderheid in de initiële `service_data`. `take_over_control` moet ingeschakeld zijn. 🕵️ ",
@ -121,7 +121,7 @@
"description": "Duur van de eerste overgang wanneer de lampen van `uit` naar `aan`gaan, in seconden. ⏲️"
},
"take_over_control": {
"description": "Schakel Adaptieve verlichting uit wanneer een andere bron `light.turn_on` aanroept terwijl de lampen aan staan en worden aangepast. N.b. dit zal `homeassistant.update_entity` elke `interval` uitvoeren."
"description": "Schakel Adaptieve verlichting uit als een andere bron `light.turn_on` aanroept terwijl de lampen aan zijn en worden aangepast. Let op dit roept`homeassistant.update_entity` elke `interval`aan."
},
"detect_non_ha_changes": {
"description": "Detecteert en stopt aanpassingen voor niet-`light.turn_on` state veranderingen. `take_over_control` moet actief zijn. 🕵️ Let op:⚠Sommige lampen kunnen incorrect een 'on' state weergeven, wat resulteert in lampen die onverwacht aan gaan. Schakel deze feature uit wanneer deze fout zich voordoet."

View file

@ -26,8 +26,15 @@
},
"transition": {
"description": "Duração da transição quando as luzes mudam, em segundos. 🕑"
},
"max_color_temp": {
"description": "Cor mais fria em Kelvin. ❄️"
},
"sleep_brightness": {
"description": "Porcentagem do brilho da lâmpadas no modo \"sleep mode\"."
}
}
},
"description": "Muda alguma configuração que você quiser no interruptor. Todas as opções aqui são as mesmas que estão no processo de configuração."
},
"apply": {
"description": "Aplica as definições atuais da Iluminação Adaptativa às luzes.",
@ -60,9 +67,12 @@
"sunset_offset": "Ajustar a hora do pôr do sol com um offset positivo ou negativo em segundos. ⏰",
"sleep_transition": "Duração da transição quando o \"modo dormir\" é alternado em segundos. 😴",
"autoreset_control_seconds": "Reiniciar o controlo manual automaticamente após um número de segundos. Definir 0 para desativar. ⏲️",
"transition": "Duração da transição quando as luzes mudam, em segundos. 🕑"
"transition": "Duração da transição quando as luzes mudam, em segundos. 🕑",
"sleep_brightness": "Porcentagem do brilho da lâmpadas no modo \"sleep mode\".",
"brightness_mode": "Brilho que irá ser usado. Possíveis valores são `default`, `linear` e `tanh`(usa `brightness_mode_time_dark` e `brightness_mode_time_light`). 📈"
},
"title": "Opções da Iluminação Adaptativa"
"title": "Opções da Iluminação Adaptativa",
"description": "Configure um componente da Iluminação Adaptativa. O nome das opções são as mesmas que as do YML. Se você já definiu essa configuração no YAML, nenhuma opção vai aparecer aqui. Para acessar um gráfico que demonstra o efeito dos parâmetros, acesse [esse app](https://basnijholt.github.io/adaptive-lighting). Para mais detalhes, veja a [documentação oficial](https://github.com/basnijholt/adaptive-lighting#readme)."
}
},
"error": {

View file

@ -36,7 +36,7 @@
"sunrise_offset": "Upravte čas východu slnka o sekundy vpred alebo vzad. ⏰",
"transition": "Trvanie prechodu, keď sú svetlá zmenené (v sekundách). ⏲️",
"brightness_mode": "Výber režimu jasu. Možné hodnotu sú `default`, `linear` a `tanh` (používa `brightness_mode_time_dark` a `brightness_mode_time_light`). 📈",
"brightness_mode_time_light": "(Ignorované ak `brightness_mode='default'`) Čas na zvýšenie/zníženie jasu po udalosti/pred udalosťou východu/západu slnka. 📈📉",
"brightness_mode_time_light": "(Ignorovaný, ak `brightness_mode = 'predvolené') Trvanie v sekundách na rampu / vypnutie jasu po / pred východ slnka/sunset. 📈📉.",
"sunset_offset": "Upravte čas západu slnka o sekundy vpred alebo vzad. ⏰",
"max_sunset_time": "Nastavte najneskorší možný virtuálny západ slnka (HH:MM:SS). Umožňuje skorší západ slnka. 🌅",
"initial_transition": "Trvanie prvého prechodu, keď sú svetlá zapnuté z `off` na `on` (v sekundách). ⏲️",
@ -132,7 +132,7 @@
"description": "Prispôsobiť svetlá len pri zapnutí (`true`) alebo prispôsobovať ich priebežne (`false`). 🔄"
},
"use_defaults": {
"description": "Nastaví predvolené hodnoty, ktoré nie sú špecifikované v tomto volaní služby. Možnosti: \"current\" (predvolené, zachová aktuálne hodnoty), \"factory\" (použije predvolené hodnoty z dokumentácie) alebo \"configuration\" (vráti na predvolené nastavenia prepínača). ⚙️"
"description": "Stanovuje predvolené hodnoty nie sú uvedené v tomto servisnom hovore. Možnosti: \"current\" (predvolené, zachováva aktuálne hodnoty), \"chôdzky na zdokumentované predvolené nastavenia), alebo \"konfigurácia\" (odkazy prepínať predvolené nastavenia). ⚙️"
},
"separate_turn_on_commands": {
"description": "Použiť samostatné volania služby `light.turn_on` pre nastavenie teploty svetla a jasu (môže byť potrebné pre niektoré typy svetiel). 🔀"
@ -196,7 +196,7 @@
"description": "`entity_id` prepínača u ktorého sa majú svetlá o(d)značiť ako \"manuálne ovládané\". 📝"
},
"lights": {
"description": "entity_id svetiel, ak nie sú špecifikované, tak sú vybrané všetky svetlá prepínača. 💡"
"description": "subjekt_id(s) svietidiel, ak nie je špecifikované, všetky svetlá v prepínači sú vybrané. 💡"
}
},
"description": "Či označiť svetlo ako \"manuálne ovládané\"."

View file

@ -0,0 +1,202 @@
{
"services": {
"set_manual_control": {
"description": "ஒரு ஒளி 'கைமுறையாக கட்டுப்படுத்தப்பட்டதா' என்பதைக் குறிக்கவும்.",
"fields": {
"entity_id": {
"description": "சுவிட்சின் `நிறுவனம்_ஐடி`, இதில் (அன்) ஒளியை` கைமுறையாக கட்டுப்படுத்தப்படுகிறது 'என்று குறிக்கவும். ."
},
"lights": {
"description": "விளக்குகளின் entity_id (கள்), குறிப்பிடப்படாவிட்டால், சுவிட்சில் உள்ள அனைத்து விளக்குகளும் தேர்ந்தெடுக்கப்படுகின்றன. ."
},
"manual_control": {
"description": "\"கையேடு_ கன்ட்ரோல்\" பட்டியலிலிருந்து ஒளியை சேர்க்க வேண்டுமா அல்லது அகற்ற வேண்டுமா அல்லது அகற்ற வேண்டுமா அல்லது அகற்ற வேண்டுமா? ."
}
}
},
"change_switch_settings": {
"fields": {
"sunrise_offset": {
"description": "விநாடிகளில் நேர்மறை அல்லது எதிர்மறை ஆஃப்செட் மூலம் சூரிய தோன்றுகை நேரத்தை சரிசெய்யவும். ."
},
"sunrise_time": {
"description": "சூரிய உதயத்திற்கு ஒரு நிலையான நேரத்தை (HH: MM: SS) அமைக்கவும். ."
},
"entity_id": {
"description": "சுவிட்சின் நிறுவன ஐடி. ."
},
"use_defaults": {
"description": "இந்த பணி அழைப்பில் குறிப்பிடப்படாத இயல்புநிலை மதிப்புகளை அமைக்கிறது. விருப்பங்கள்: \"நடப்பு\" (இயல்புநிலை, தற்போதைய மதிப்புகளைத் தக்க வைத்துக் கொள்கிறது), \"தொழிற்சாலை\" (ஆவணப்படுத்தப்பட்ட இயல்புநிலைகளுக்கு மீட்டமைக்கிறது) அல்லது \"உள்ளமைவு\" (கட்டமைப்பு இயல்புநிலைகளை மாற்றுவதற்கு மாற்றுகிறது). ."
},
"include_config_in_attributes": {
"description": "`உண்மை` என அமைக்கப்பட்டிருக்கும் போது வீட்டு உதவியாளரின் சுவிட்சில் உள்ள அனைத்து விருப்பங்களையும் பண்புகளாகக் காட்டுங்கள். ."
},
"turn_on_lights": {
"description": "தற்போது முடக்கப்பட்ட விளக்குகளை இயக்க வேண்டுமா. ."
},
"initial_transition": {
"description": "விளக்குகள் `ஆஃப்` முதல்` ஆன் `வரை நொடிகளில் மாறும் போது முதல் மாற்றத்தின் காலம். ."
},
"sleep_transition": {
"description": "\"தூக்க பயன்முறை\" நொடிகளில் மாற்றப்படும்போது மாற்றத்தின் காலம். ."
},
"max_brightness": {
"description": "அதிகபட்ச ஒளி விழுக்காடு. ."
},
"max_color_temp": {
"description": "கெல்வினில் குளிரான வண்ண வெப்பநிலை. ."
},
"min_brightness": {
"description": "குறைந்தபட்ச ஒளி விழுக்காடு. ."
},
"min_color_temp": {
"description": "கெல்வினில் வெப்பமான வண்ண வெப்பநிலை. ."
},
"only_once": {
"description": "விளக்குகள் இயக்கப்படும்போது மட்டுமே (`உண்மை`) மாற்றியமைக்கும்போது அல்லது அவற்றைத் தழுவிக்கொள்ளுங்கள் (` பொய்`). ."
},
"prefer_rgb_color": {
"description": "முடிந்தவரை ஒளி வண்ண வெப்பநிலையை விட RGB வண்ண சரிசெய்தலை விரும்பலாமா. ."
},
"separate_turn_on_commands": {
"description": "சில ஒளி வகைகளுக்கு தேவைப்படும் வண்ணம் மற்றும் பிரகாசத்திற்கான தனித்தனி `லைட்.டர்ன்_ஓஎன்` அழைப்புகளைப் பயன்படுத்தவும். ."
},
"send_split_delay": {
"description": "ஒரே நேரத்தில் ஒளி மற்றும் வண்ண அமைப்பை ஆதரிக்காத விளக்குகளுக்கு `தனி_டர்ன்_ஆன்_காமண்ட்ச்` இடையே நேரந்தவறுகை (எம்.எச்). ."
},
"sleep_brightness": {
"description": "தூக்க பயன்முறையில் விளக்குகளின் ஒளி விழுக்காடு. ."
},
"sleep_rgb_or_color_temp": {
"description": "தூக்க பயன்முறையில் `\" rgb_color \"` அல்லது `\" Color_Temp \"key ஐப் பயன்படுத்தவும். ."
},
"sleep_rgb_color": {
"description": "தூக்க பயன்முறையில் RGB வண்ணம் (`SLEEP_RGB_OR_COLOR_TEMP`\" RGB_COLOR \"ஆக இருக்கும்போது பயன்படுத்தப்படுகிறது). ."
},
"sleep_color_temp": {
"description": "ச்லீப் பயன்முறையில் வண்ண வெப்பநிலை (கெல்வினில் `SLEEP_RGB_OR_COLOR_TEMP` என்பது` color_temp` ஆக இருக்கும்போது பயன்படுத்தப்படுகிறது). ."
},
"sunset_offset": {
"description": "வினாடிகளில் நேர்மறை அல்லது எதிர்மறை ஆஃப்செட் மூலம் சூரிய மறைவு நேரத்தை சரிசெய்யவும். ."
},
"sunset_time": {
"description": "சூரிய அச்தமனத்திற்கு ஒரு நிலையான நேரத்தை (HH: MM: SS) அமைக்கவும். ."
},
"max_sunrise_time": {
"description": "ஆரம்பகால சூரிய உதயத்தை அனுமதிக்கும் அண்மைக் கால மெய்நிகர் சூரிய தோன்றுகை நேரத்தை (HH: MM: SS) அமைக்கவும். ."
},
"min_sunset_time": {
"description": "ஆரம்பகால மெய்நிகர் சூரிய மறைவு நேரத்தை (HH: MM: SS) அமைக்கவும், பின்னர் சூரிய அச்தமனங்களை அனுமதிக்கிறது. ."
},
"take_over_control": {
"description": "விளக்குகள் இயக்கத்தில் இருக்கும்போது மற்றொரு சான்று `லைட்.டர்ன்_ஒன்` என்று அழைத்தால் தகவமைப்பு விளக்குகளை முடக்கு. இது `ஓமாசிச்டன்ட்.பிடேட்_என்டிட்டி` ஒவ்வொரு` இடைவெளியையும் 'என்று அழைக்கிறது என்பதை நினைவில் கொள்க! ."
},
"detect_non_ha_changes": {
"description": "`விளக்கு அல்லாத. டர்ன்_ஓஎன்` மாநில மாற்றங்களுக்கான தழுவல்களைக் கண்டறிந்து நிறுத்துகிறது. `Take_over_control` இயக்கப்பட்டது. 🕵œ எச்சரிக்கை: ⚠œ சில விளக்குகள் ஒரு 'ஆன்' நிலையை பொய்யாகக் குறிக்கக்கூடும், இதனால் விளக்குகள் எதிர்பாராத விதமாக இயக்கப்படலாம். இதுபோன்ற சிக்கல்களை நீங்கள் சந்தித்தால் இந்த அம்சத்தை முடக்கு."
},
"transition": {
"description": "விளக்குகள் மாறும்போது, நொடிகளில் மாற்றத்தின் காலம். ."
},
"adapt_delay": {
"description": "லைட் டர்ன் மற்றும் தகவமைப்பு விளக்குகள் இடையே காத்திருப்பு நேரம் (விநாடிகள்) மாற்றங்களைப் பயன்படுத்துகிறது. ஒளிரும் தவிர்க்க உதவலாம். ."
},
"autoreset_control_seconds": {
"description": "பல விநாடிகளுக்குப் பிறகு தானாகவே கையேடு கட்டுப்பாட்டை மீட்டமைக்கவும். முடக்க 0 என அமைக்கவும். ."
}
},
"description": "சுவிட்சில் நீங்கள் விரும்பும் எந்த அமைப்புகளையும் மாற்றவும். இங்குள்ள அனைத்து விருப்பங்களும் கட்டமைப்பு ஓட்டத்தில் உள்ளதைப் போலவே இருக்கும்."
},
"apply": {
"description": "தற்போதைய தகவமைப்பு லைட்டிங் அமைப்புகளை விளக்குகளுக்கு பயன்படுத்துகிறது.",
"fields": {
"entity_id": {
"description": "விண்ணப்பிக்க அமைப்புகளுடன் சுவிட்சின் `ENTITY_ID`. ."
},
"lights": {
"description": "அமைப்புகளைப் பயன்படுத்த ஒரு ஒளி (அல்லது விளக்குகளின் பட்டியல்). ."
},
"transition": {
"description": "விளக்குகள் மாறும்போது, நொடிகளில் மாற்றத்தின் காலம். ."
},
"adapt_brightness": {
"description": "ஒளியின் பிரகாசத்தை மாற்றியமைக்க வேண்டுமா. ."
},
"adapt_color": {
"description": "துணை விளக்குகளில் வண்ணத்தை மாற்றியமைக்க வேண்டுமா. ."
},
"prefer_rgb_color": {
"description": "முடிந்தவரை ஒளி வண்ண வெப்பநிலையை விட RGB வண்ண சரிசெய்தலை விரும்பலாமா. ."
},
"turn_on_lights": {
"description": "தற்போது முடக்கப்பட்ட விளக்குகளை இயக்க வேண்டுமா. ."
}
}
}
},
"title": "தகவமைப்பு விளக்குகள்",
"config": {
"step": {
"user": {
"title": "தகவமைப்பு விளக்கு உதாரணத்திற்கு ஒரு பெயரைத் தேர்வுசெய்க",
"description": "ஒவ்வொரு நிகழ்விலும் பல விளக்குகள் இருக்கலாம்!"
}
},
"abort": {
"already_configured": "இந்த சாதனம் ஏற்கனவே கட்டமைக்கப்பட்டுள்ளது"
}
},
"options": {
"step": {
"init": {
"title": "தகவமைப்பு விளக்கு விருப்பங்கள்",
"description": "தகவமைப்பு விளக்கு கூறுகளை உள்ளமைக்கவும். விருப்பப் பெயர்கள் YAML அமைப்புகளுடன் சீரமைக்கப்படுகின்றன. இந்த உள்ளீட்டை நீங்கள் YAML இல் வரையறுத்திருந்தால், இங்கே எந்த விருப்பங்களும் தோன்றாது. அளவுரு விளைவுகளை நிரூபிக்கும் ஊடாடும் வரைபடங்களுக்கு, [இந்த வலை பயன்பாடு] (https://basnijholt.github.io/adaptive-lighting) ஐப் பார்வையிடவும். மேலும் விவரங்களுக்கு, [அதிகாரப்பூர்வ ஆவணங்கள்] (https://github.com/basnijholt/adaptive-lighting#readme) ஐப் பார்க்கவும்.",
"data": {
"lights": "விளக்குகள்: கட்டுப்படுத்தப்பட வேண்டிய ஒளி நிறுவனம்_டுகளின் பட்டியல் (காலியாக இருக்கலாம்). .",
"min_brightness": "min_brightness: குறைந்தபட்ச ஒளி விழுக்காடு. .",
"max_brightness": "அதிகபட்ச பிரகாசம்: அதிகபட்ச ஒளி விழுக்காடு. .",
"min_color_temp": "min_color_temp: கெல்வினில் வெப்பமான வண்ண வெப்பநிலை. .",
"max_color_temp": "MAX_COLOR_TEMP: கெல்வினில் குளிரான வண்ண வெப்பநிலை. .",
"prefer_rgb_color": "bey_rgb_color: முடிந்தவரை ஒளி வண்ண வெப்பநிலையை விட RGB வண்ண சரிசெய்தலை விரும்பலாமா. .",
"transition_until_sleep": "Transition_until_sleep: இயக்கப்பட்டால், தகவமைப்பு விளக்குகள் தூக்க அமைப்புகளை குறைந்தபட்சமாகக் கருதும், சூரிய அச்தமனத்திற்குப் பிறகு இந்த மதிப்புகளுக்கு மாறும். .",
"take_over_control": "Take_over_control: விளக்குகள் இயக்கத்தில் இருக்கும்போது மற்றொரு சான்று `லைட்.டர்ன்_ஓஎன்` என்று அழைத்தால் தகவமைப்பு விளக்குகளை முடக்கு. இது `ஓமாசிச்டன்ட்.பிடேட்_என்டிட்டி` ஒவ்வொரு` இடைவெளியையும் 'என்று அழைக்கிறது என்பதை நினைவில் கொள்க! .",
"detect_non_ha_changes": "கண்டறிதல்_நான்_ஆ_சேஞ்ச்ச்: `விளக்கு அல்லாத. டர்ன்_ஓஎன்` மாநில மாற்றங்களுக்கான தழுவல்களைக் கண்டறிந்து நிறுத்துகிறது. `Take_over_control` இயக்கப்பட்டது. 🕵œ எச்சரிக்கை: ⚠œ சில விளக்குகள் ஒரு 'ஆன்' நிலையை பொய்யாகக் குறிக்கக்கூடும், இதனால் விளக்குகள் எதிர்பாராத விதமாக இயக்கப்படலாம். இதுபோன்ற சிக்கல்களை நீங்கள் சந்தித்தால் இந்த அம்சத்தை முடக்கு.",
"only_once": "மட்டும்_இன்: விளக்குகள் இயக்கப்படும்போது மட்டுமே (`உண்மை`) மாற்றியமைக்கும்போது அல்லது அவற்றைத் தழுவிக்கொள்ளுங்கள் (` தவறு`). .",
"adapt_only_on_bare_turn_on": "Sadve_only_on_bare_turn_on: ஆரம்பத்தில் விளக்குகளை இயக்கும்போது. `உண்மை` என அமைக்கப்பட்டால், வண்ணம் அல்லது பிரகாசத்தைக் குறிப்பிடாமல்` லைட்.டர்ன்_ஓஎன்` செயல்படுத்தப்பட்டால் மட்டுமே அல் மாற்றியமைக்கிறது. ❌🌈 இது எ.கா., ஒரு காட்சியை செயல்படுத்தும்போது தழுவலைத் தடுக்கிறது. `தவறு` என்றால், ஆரம்ப` சேவை_டா` இல் நிறம் அல்லது ஒளி இருப்பதைப் பொருட்படுத்தாமல் AL மாற்றியமைக்கிறது. `Take_over_control` இயக்கப்பட்டது. . ",
"separate_turn_on_commands": "தனித்தனி_டர்ன்_ஆன்_காமண்ட்ச்: சில ஒளி வகைகளுக்கு தேவைப்படும் வண்ணம் மற்றும் பிரகாசத்திற்கான தனித்தனி `லைட்.டர்ன்_ஓஎன்` அழைப்புகளைப் பயன்படுத்தவும். .",
"skip_redundant_commands": "Skip_redundant_commands: தழுவல் கட்டளைகளை அனுப்புவதைத் தவிர்க்கவும், அதன் இலக்கு நிலை ஏற்கனவே ஒளியின் அறியப்பட்ட நிலைக்கு சமம். பிணையம் போக்குவரத்தை குறைக்கிறது மற்றும் சில சூழ்நிலைகளில் தழுவல் மறுமொழியை மேம்படுத்துகிறது. ஆ இன் பதிவு செய்யப்பட்ட நிலையுடன் இயற்பியல் ஒளி நிலைகள் ஒத்திசைவிலிருந்து வெளியேறினால் அது காணக்கூடியது.",
"intercept": "இடைமறிப்பு: உடனடி வண்ணம் மற்றும் பிரகாசமான தழுவலை செயல்படுத்த `ஒளி. Color வண்ணம் மற்றும் பிரகாசத்துடன் `ஒளி.",
"multi_light_intercept": "Mulli_light_intect: பல விளக்குகளை குறிவைக்கும் `light.turn_on` அழைப்புகளை இடைமறிக்கவும் மாற்றவும். ➗⚠œ இது ஒரு `லைட்.டர்ன்_ஒன்` அழைப்பை பல அழைப்புகளாக பிரிக்கக்கூடும், எ.கா., விளக்குகள் வெவ்வேறு சுவிட்சுகளில் இருக்கும்போது. இயக்கப்பட வேண்டும் `இடைமறிப்பு` தேவை.",
"include_config_in_attributes": "அடங்கும்_கான்ஃபிக்_இன்_அட்ரிபியூட்: `உண்மை` என அமைக்கப்பட்டிருக்கும் போது வீட்டு உதவியாளரின் சுவிட்சில் உள்ள பண்புகளாக அனைத்து விருப்பங்களையும் காட்டுங்கள். ."
},
"data_description": {
"interval": "விளக்குகளை மாற்றியமைக்க அதிர்வெண், நொடிகளில். .",
"transition": "விளக்குகள் மாறும்போது, நொடிகளில் மாற்றத்தின் காலம். .",
"initial_transition": "விளக்குகள் `ஆஃப்` முதல்` ஆன் `வரை நொடிகளில் மாறும் போது முதல் மாற்றத்தின் காலம். .",
"sleep_brightness": "தூக்க பயன்முறையில் விளக்குகளின் ஒளி விழுக்காடு. .",
"sleep_rgb_or_color_temp": "தூக்க பயன்முறையில் `\" rgb_color \"` அல்லது `\" Color_Temp \"key ஐப் பயன்படுத்தவும். .",
"sleep_color_temp": "ச்லீப் பயன்முறையில் வண்ண வெப்பநிலை (கெல்வினில் `SLEEP_RGB_OR_COLOR_TEMP` என்பது` color_temp` ஆக இருக்கும்போது பயன்படுத்தப்படுகிறது). .",
"sleep_rgb_color": "தூக்க பயன்முறையில் RGB வண்ணம் (`SLEEP_RGB_OR_COLOR_TEMP`\" RGB_COLOR \"ஆக இருக்கும்போது பயன்படுத்தப்படுகிறது). .",
"sleep_transition": "\"தூக்க பயன்முறை\" நொடிகளில் மாற்றப்படும்போது மாற்றத்தின் காலம். .",
"sunrise_time": "சூரிய உதயத்திற்கு ஒரு நிலையான நேரத்தை (HH: MM: SS) அமைக்கவும். .",
"min_sunrise_time": "ஆரம்பகால மெய்நிகர் சூரிய உதய நேரத்தை (HH: MM: SS) அமைக்கவும், பின்னர் சூரிய உதயங்களை அனுமதிக்கிறது. .",
"max_sunrise_time": "ஆரம்பகால சூரிய உதயத்தை அனுமதிக்கும் அண்மைக் கால மெய்நிகர் சூரிய தோன்றுகை நேரத்தை (HH: MM: SS) அமைக்கவும். .",
"sunrise_offset": "விநாடிகளில் நேர்மறை அல்லது எதிர்மறை ஆஃப்செட் மூலம் சூரிய தோன்றுகை நேரத்தை சரிசெய்யவும். .",
"sunset_time": "சூரிய அச்தமனத்திற்கு ஒரு நிலையான நேரத்தை (HH: MM: SS) அமைக்கவும். .",
"min_sunset_time": "ஆரம்பகால மெய்நிகர் சூரிய மறைவு நேரத்தை (HH: MM: SS) அமைக்கவும், பின்னர் சூரிய அச்தமனங்களை அனுமதிக்கிறது. .",
"max_sunset_time": "முந்தைய சூரிய அச்தமனங்களை அனுமதிக்கும் அண்மைக் கால மெய்நிகர் சன்செட் நேரத்தை (HH: MM: SS) அமைக்கவும். .",
"sunset_offset": "விநாடிகளில் நேர்மறை அல்லது எதிர்மறை ஆஃப்செட் மூலம் சூரிய மறைவு நேரத்தை சரிசெய்யவும். .",
"send_split_delay": "ஒரே நேரத்தில் ஒளி மற்றும் வண்ண அமைப்பை ஆதரிக்காத விளக்குகளுக்கு `தனி_டர்ன்_ஆன்_காமண்ட்ச்` இடையே நேரந்தவறுகை (எம்.எச்). .",
"adapt_delay": "லைட் டர்ன் மற்றும் தகவமைப்பு விளக்குகள் இடையே காத்திருப்பு நேரம் (விநாடிகள்) மாற்றங்களைப் பயன்படுத்துகிறது. ஒளிரும் தவிர்க்க உதவலாம். .",
"brightness_mode": "பயன்படுத்த பிரகாசமான முறை. சாத்தியமான மதிப்புகள் `இயல்புநிலை`,` லீனியர்`, மற்றும் `டான்` (` பிரகாசம்_மோட்_ நேரம்_டார்க்` மற்றும் `பிரகாசம்_மோட்_மட்_லிட்` ஆகியவற்றைப் பயன்படுத்துகின்றன). .",
"brightness_mode_time_dark": ". .",
"brightness_mode_time_light": ". ..",
"autoreset_control_seconds": "பல விநாடிகளுக்குப் பிறகு தானாகவே கையேடு கட்டுப்பாட்டை மீட்டமைக்கவும். முடக்க 0 என அமைக்கவும். ."
}
}
},
"error": {
"option_error": "தவறான விருப்பம்",
"entity_missing": "ஒன்று அல்லது அதற்கு மேற்பட்ட தேர்ந்தெடுக்கப்பட்ட ஒளி நிறுவனங்கள் வீட்டு உதவியாளரிடமிருந்து காணவில்லை"
}
}
}

1
webapp/__init__.py Normal file
View file

@ -0,0 +1 @@
"""Shiny webapp for Adaptive Lighting."""

View file

@ -217,10 +217,9 @@ Dive into the simulator, experiment with different settings, and fine-tune the b
# Shiny UI
app_ui = ui.page_fluid(
shinyswatch.theme.sandstone(),
ui.panel_title("🌞 Adaptive Lighting Simulator WebApp 🌛"),
ui.layout_sidebar(
ui.panel_sidebar(
ui.sidebar(
ui.input_switch("adapt_until_sleep", "adapt_until_sleep", value=False),
ui.input_switch("sleep_mode", "sleep_mode", value=False),
ui.input_slider("min_brightness", "min_brightness", 1, 100, 30, post="%"),
@ -277,13 +276,12 @@ app_ui = ui.page_fluid(
post=" hr",
),
),
ui.panel_main(
ui.markdown(desc_top),
ui.output_plot(id="brightness_plot"),
ui.output_plot(id="color_temp_plot"),
ui.markdown(desc_bottom),
),
ui.markdown(desc_top),
ui.output_plot(id="brightness_plot"),
ui.output_plot(id="color_temp_plot"),
ui.markdown(desc_bottom),
),
theme=shinyswatch.theme.sandstone,
)

View file

@ -0,0 +1,521 @@
"""Switch for the Adaptive Lighting integration."""
from __future__ import annotations
import bisect
import colorsys
import datetime
import logging
import math
from dataclasses import dataclass
from datetime import timedelta
from functools import cached_property, partial
from typing import TYPE_CHECKING, Any, Literal, cast
from homeassistant_util_color import (
color_RGB_to_xy,
color_temperature_to_rgb,
color_xy_to_hs,
)
if TYPE_CHECKING:
import astral
# Same as homeassistant.const.SUN_EVENT_SUNRISE and homeassistant.const.SUN_EVENT_SUNSET
# We re-define them here to not depend on homeassistant in this file.
SUN_EVENT_SUNRISE = "sunrise"
SUN_EVENT_SUNSET = "sunset"
SUN_EVENT_NOON = "solar_noon"
SUN_EVENT_MIDNIGHT = "solar_midnight"
_ORDER = (SUN_EVENT_SUNRISE, SUN_EVENT_NOON, SUN_EVENT_SUNSET, SUN_EVENT_MIDNIGHT)
_ALLOWED_ORDERS = {_ORDER[i:] + _ORDER[:i] for i in range(len(_ORDER))}
UTC = datetime.timezone.utc
utcnow: partial[datetime.datetime] = partial(datetime.datetime.now, UTC)
utcnow.__doc__ = "Get now in UTC time."
_LOGGER = logging.getLogger(__name__)
@dataclass(frozen=True)
class SunEvents:
"""Track the state of the sun and associated light settings."""
name: str
astral_location: astral.Location
sunrise_time: datetime.time | None
min_sunrise_time: datetime.time | None
max_sunrise_time: datetime.time | None
sunset_time: datetime.time | None
min_sunset_time: datetime.time | None
max_sunset_time: datetime.time | None
sunrise_offset: datetime.timedelta = datetime.timedelta()
sunset_offset: datetime.timedelta = datetime.timedelta()
timezone: datetime.tzinfo = UTC
def sunrise(self, dt: datetime.date) -> datetime.datetime:
"""Return the (adjusted) sunrise time for the given datetime."""
sunrise = (
self.astral_location.sunrise(dt, local=False)
if self.sunrise_time is None
else self._replace_time(dt, self.sunrise_time)
) + self.sunrise_offset
if self.min_sunrise_time is not None:
min_sunrise = self._replace_time(dt, self.min_sunrise_time)
if min_sunrise > sunrise:
sunrise = min_sunrise
if self.max_sunrise_time is not None:
max_sunrise = self._replace_time(dt, self.max_sunrise_time)
if max_sunrise < sunrise:
sunrise = max_sunrise
return sunrise
def sunset(self, dt: datetime.date) -> datetime.datetime:
"""Return the (adjusted) sunset time for the given datetime."""
sunset = (
self.astral_location.sunset(dt, local=False)
if self.sunset_time is None
else self._replace_time(dt, self.sunset_time)
) + self.sunset_offset
if self.min_sunset_time is not None:
min_sunset = self._replace_time(dt, self.min_sunset_time)
if min_sunset > sunset:
sunset = min_sunset
if self.max_sunset_time is not None:
max_sunset = self._replace_time(dt, self.max_sunset_time)
if max_sunset < sunset:
sunset = max_sunset
return sunset
def _replace_time(
self,
dt: datetime.date,
time: datetime.time,
) -> datetime.datetime:
date_time = datetime.datetime.combine(dt, time)
dt_with_tz = date_time.replace(tzinfo=self.timezone)
return dt_with_tz.astimezone(UTC)
def noon_and_midnight(
self,
dt: datetime.datetime,
sunset: datetime.datetime | None = None,
sunrise: datetime.datetime | None = None,
) -> tuple[datetime.datetime, datetime.datetime]:
"""Return the (adjusted) noon and midnight times for the given datetime."""
if (
self.sunrise_time is None
and self.sunset_time is None
and self.min_sunrise_time is None
and self.max_sunrise_time is None
and self.min_sunset_time is None
and self.max_sunset_time is None
):
solar_noon = self.astral_location.noon(dt, local=False)
solar_midnight = self.astral_location.midnight(dt, local=False)
return solar_noon, solar_midnight
if sunset is None:
sunset = self.sunset(dt)
if sunrise is None:
sunrise = self.sunrise(dt)
middle = abs(sunset - sunrise) / 2
if sunset > sunrise:
noon = sunrise + middle
midnight = noon + timedelta(hours=12) * (1 if noon.hour < 12 else -1)
else:
midnight = sunset + middle
noon = midnight + timedelta(hours=12) * (1 if midnight.hour < 12 else -1)
return noon, midnight
def sun_events(self, dt: datetime.datetime) -> list[tuple[str, float]]:
"""Get the four sun event's timestamps at 'dt'."""
sunrise = self.sunrise(dt)
sunset = self.sunset(dt)
solar_noon, solar_midnight = self.noon_and_midnight(dt, sunset, sunrise)
events = [
(SUN_EVENT_SUNRISE, sunrise.timestamp()),
(SUN_EVENT_SUNSET, sunset.timestamp()),
(SUN_EVENT_NOON, solar_noon.timestamp()),
(SUN_EVENT_MIDNIGHT, solar_midnight.timestamp()),
]
self._validate_sun_event_order(events)
return events
def _validate_sun_event_order(self, events: list[tuple[str, float]]) -> None:
"""Check if the sun events are in the expected order."""
events = sorted(events, key=lambda x: x[1])
events_names, _ = zip(*events, strict=True)
if events_names not in _ALLOWED_ORDERS:
msg = (
f"{self.name}: The sun events {events_names} are not in the expected"
" order. The Adaptive Lighting integration will not work!"
" This might happen if your sunrise/sunset offset is too large or"
" your manually set sunrise/sunset time is past/before noon/midnight."
)
_LOGGER.error(msg)
raise ValueError(msg)
def prev_and_next_events(self, dt: datetime.datetime) -> list[tuple[str, float]]:
"""Get the previous and next sun event."""
events = [
event
for days in [-1, 0, 1]
for event in self.sun_events(dt + timedelta(days=days))
]
events = sorted(events, key=lambda x: x[1])
i_now = bisect.bisect([ts for _, ts in events], dt.timestamp())
return events[i_now - 1 : i_now + 1]
def sun_position(self, dt: datetime.datetime) -> float:
"""Calculate the position of the sun, between [-1, 1]."""
target_ts = dt.timestamp()
(_, prev_ts), (next_event, next_ts) = self.prev_and_next_events(dt)
h, x = (
(prev_ts, next_ts)
if next_event in (SUN_EVENT_SUNSET, SUN_EVENT_SUNRISE)
else (next_ts, prev_ts)
)
# k = -1 between sunset and sunrise (sun below horizon)
# k = 1 between sunrise and sunset (sun above horizon)
k = 1 if next_event in (SUN_EVENT_SUNSET, SUN_EVENT_NOON) else -1
return k * (1 - ((target_ts - h) / (h - x)) ** 2)
def closest_event(self, dt: datetime.datetime) -> tuple[str, float]:
"""Get the closest sunset or sunrise event."""
(prev_event, prev_ts), (next_event, next_ts) = self.prev_and_next_events(dt)
if SUN_EVENT_SUNRISE in (prev_event, next_event):
ts_event = prev_ts if prev_event == SUN_EVENT_SUNRISE else next_ts
return SUN_EVENT_SUNRISE, ts_event
if SUN_EVENT_SUNSET in (prev_event, next_event):
ts_event = prev_ts if prev_event == SUN_EVENT_SUNSET else next_ts
return SUN_EVENT_SUNSET, ts_event
msg = "No sunrise or sunset event found."
raise ValueError(msg)
@dataclass(frozen=True)
class SunLightSettings:
"""Track the state of the sun and associated light settings."""
name: str
astral_location: astral.Location
adapt_until_sleep: bool
max_brightness: int
max_color_temp: int
min_brightness: int
min_color_temp: int
sleep_brightness: int
sleep_rgb_or_color_temp: Literal["color_temp", "rgb_color"]
sleep_color_temp: int
sleep_rgb_color: tuple[int, int, int]
sunrise_time: datetime.time | None
min_sunrise_time: datetime.time | None
max_sunrise_time: datetime.time | None
sunset_time: datetime.time | None
min_sunset_time: datetime.time | None
max_sunset_time: datetime.time | None
brightness_mode_time_dark: datetime.timedelta
brightness_mode_time_light: datetime.timedelta
brightness_mode: Literal["default", "linear", "tanh"] = "default"
sunrise_offset: datetime.timedelta = datetime.timedelta()
sunset_offset: datetime.timedelta = datetime.timedelta()
timezone: datetime.tzinfo = UTC
@cached_property
def sun(self) -> SunEvents:
"""Return the SunEvents object."""
return SunEvents(
name=self.name,
astral_location=self.astral_location,
sunrise_time=self.sunrise_time,
sunrise_offset=self.sunrise_offset,
min_sunrise_time=self.min_sunrise_time,
max_sunrise_time=self.max_sunrise_time,
sunset_time=self.sunset_time,
sunset_offset=self.sunset_offset,
min_sunset_time=self.min_sunset_time,
max_sunset_time=self.max_sunset_time,
timezone=self.timezone,
)
def _brightness_pct_default(self, dt: datetime.datetime) -> float:
"""Calculate the brightness percentage using the default method."""
sun_position = self.sun.sun_position(dt)
if sun_position > 0:
return self.max_brightness
delta_brightness = self.max_brightness - self.min_brightness
return (delta_brightness * (1 + sun_position)) + self.min_brightness
def _brightness_pct_tanh(self, dt: datetime.datetime) -> float:
event, ts_event = self.sun.closest_event(dt)
dark = self.brightness_mode_time_dark.total_seconds()
light = self.brightness_mode_time_light.total_seconds()
if event == SUN_EVENT_SUNRISE:
brightness = scaled_tanh(
dt.timestamp() - ts_event,
x1=-dark,
x2=+light,
y1=0.05, # be at 5% of range at x1
y2=0.95, # be at 95% of range at x2
y_min=self.min_brightness,
y_max=self.max_brightness,
)
elif event == SUN_EVENT_SUNSET:
brightness = scaled_tanh(
dt.timestamp() - ts_event,
x1=-light, # shifted timestamp for the start of sunset
x2=+dark, # shifted timestamp for the end of sunset
y1=0.95, # be at 95% of range at the start of sunset
y2=0.05, # be at 5% of range at the end of sunset
y_min=self.min_brightness,
y_max=self.max_brightness,
)
return clamp(brightness, self.min_brightness, self.max_brightness)
def _brightness_pct_linear(self, dt: datetime.datetime) -> float:
event, ts_event = self.sun.closest_event(dt)
# at ts_event - dt_start, brightness == start_brightness
# at ts_event + dt_end, brightness == end_brightness
dark = self.brightness_mode_time_dark.total_seconds()
light = self.brightness_mode_time_light.total_seconds()
if event == SUN_EVENT_SUNRISE:
brightness = lerp(
dt.timestamp() - ts_event,
x1=-dark,
x2=+light,
y1=self.min_brightness,
y2=self.max_brightness,
)
elif event == SUN_EVENT_SUNSET:
brightness = lerp(
dt.timestamp() - ts_event,
x1=-light,
x2=+dark,
y1=self.max_brightness,
y2=self.min_brightness,
)
return clamp(brightness, self.min_brightness, self.max_brightness)
def brightness_pct(self, dt: datetime.datetime, is_sleep: bool) -> float:
"""Calculate the brightness in %."""
if is_sleep:
return self.sleep_brightness
assert self.brightness_mode in ("default", "linear", "tanh")
if self.brightness_mode == "default":
return self._brightness_pct_default(dt)
if self.brightness_mode == "linear":
return self._brightness_pct_linear(dt)
if self.brightness_mode == "tanh":
return self._brightness_pct_tanh(dt)
return None
def color_temp_kelvin(self, sun_position: float) -> int:
"""Calculate the color temperature in Kelvin."""
if sun_position > 0:
delta = self.max_color_temp - self.min_color_temp
ct = (delta * sun_position) + self.min_color_temp
return 5 * round(ct / 5) # round to nearest 5
if sun_position == 0 or not self.adapt_until_sleep:
return self.min_color_temp
if self.adapt_until_sleep and sun_position < 0:
delta = abs(self.min_color_temp - self.sleep_color_temp)
ct = (delta * abs(1 + sun_position)) + self.sleep_color_temp
return 5 * round(ct / 5) # round to nearest 5
msg = "Should not happen"
raise ValueError(msg)
def brightness_and_color(
self,
dt: datetime.datetime,
is_sleep: bool,
) -> dict[str, Any]:
"""Calculate the brightness and color."""
sun_position = self.sun.sun_position(dt)
rgb_color: tuple[float, float, float]
# Variable `force_rgb_color` is needed for RGB color after sunset (if enabled)
force_rgb_color = False
brightness_pct = self.brightness_pct(dt, is_sleep)
if is_sleep:
color_temp_kelvin = self.sleep_color_temp
rgb_color = self.sleep_rgb_color
elif (
self.sleep_rgb_or_color_temp == "rgb_color"
and self.adapt_until_sleep
and sun_position < 0
):
# Feature requested in
# https://github.com/basnijholt/adaptive-lighting/issues/624
# This will result in a perceptible jump in color at sunset and sunrise
# because the `color_temperature_to_rgb` function is not 100% accurate.
min_color_rgb = color_temperature_to_rgb(self.min_color_temp)
rgb_color = lerp_color_hsv(
min_color_rgb,
self.sleep_rgb_color,
sun_position,
)
color_temp_kelvin = self.color_temp_kelvin(sun_position)
force_rgb_color = True
else:
color_temp_kelvin = self.color_temp_kelvin(sun_position)
rgb_color = color_temperature_to_rgb(color_temp_kelvin)
# backwards compatibility for versions < 1.3.1 - see #403
color_temp_mired: float = math.floor(1000000 / color_temp_kelvin)
xy_color: tuple[float, float] = color_RGB_to_xy(*rgb_color)
hs_color: tuple[float, float] = color_xy_to_hs(*xy_color)
return {
"brightness_pct": brightness_pct,
"color_temp_kelvin": color_temp_kelvin,
"color_temp_mired": color_temp_mired,
"rgb_color": rgb_color,
"xy_color": xy_color,
"hs_color": hs_color,
"sun_position": sun_position,
"force_rgb_color": force_rgb_color,
}
def get_settings(
self,
is_sleep,
transition,
) -> dict[str, float | int | tuple[float, float] | tuple[float, float, float]]:
"""Get all light settings.
Calculating all values takes <0.5ms.
"""
dt = utcnow() + timedelta(seconds=transition or 0)
return self.brightness_and_color(dt, is_sleep)
def find_a_b(x1: float, x2: float, y1: float, y2: float) -> tuple[float, float]:
"""Compute the values of 'a' and 'b' for a scaled and shifted tanh function.
Given two points (x1, y1) and (x2, y2), this function calculates the coefficients 'a' and 'b'
for a tanh function of the form y = 0.5 * (tanh(a * (x - b)) + 1) that passes through these points.
The derivation is as follows:
1. Start with the equation of the tanh function:
y = 0.5 * (tanh(a * (x - b)) + 1)
2. Rearrange the equation to isolate tanh:
tanh(a * (x - b)) = 2*y - 1
3. Take the inverse tanh (or artanh) on both sides to solve for 'a' and 'b':
a * (x - b) = artanh(2*y - 1)
4. Plug in the points (x1, y1) and (x2, y2) to get two equations.
Using these, we can solve for 'a' and 'b' as:
a = (artanh(2*y2 - 1) - artanh(2*y1 - 1)) / (x2 - x1)
b = x1 - (artanh(2*y1 - 1) / a)
Parameters
----------
x1
x-coordinate of the first point.
x2
x-coordinate of the second point.
y1
y-coordinate of the first point (should be between 0 and 1).
y2
y-coordinate of the second point (should be between 0 and 1).
Returns
-------
a
Coefficient 'a' for the tanh function.
b
Coefficient 'b' for the tanh function.
Notes
-----
The values of y1 and y2 should lie between 0 and 1, inclusive.
"""
a = (math.atanh(2 * y2 - 1) - math.atanh(2 * y1 - 1)) / (x2 - x1)
b = x1 - (math.atanh(2 * y1 - 1) / a)
return a, b
def scaled_tanh(
x: float,
x1: float,
x2: float,
y1: float = 0.05,
y2: float = 0.95,
y_min: float = 0.0,
y_max: float = 100.0,
) -> float:
"""Apply a scaled and shifted tanh function to a given input.
This function represents a transformation of the tanh function that scales and shifts
the output to lie between y_min and y_max. For values of 'x' close to 'x1' and 'x2'
(used to calculate 'a' and 'b'), the output of this function will be close to 'y_min'
and 'y_max', respectively.
The equation of the function is as follows:
y = y_min + (y_max - y_min) * 0.5 * (tanh(a * (x - b)) + 1)
Parameters
----------
x
The input to the function.
x1
x-coordinate of the first point.
x2
x-coordinate of the second point.
y1
y-coordinate of the first point (should be between 0 and 1). Defaults to 0.05.
y2
y-coordinate of the second point (should be between 0 and 1). Defaults to 0.95.
y_min
The minimum value of the output range. Defaults to 0.
y_max
The maximum value of the output range. Defaults to 100.
Returns
-------
float: The output of the function, which lies in the range [y_min, y_max].
"""
a, b = find_a_b(x1, x2, y1, y2)
return y_min + (y_max - y_min) * 0.5 * (math.tanh(a * (x - b)) + 1)
def lerp_color_hsv(
rgb1: tuple[float, float, float],
rgb2: tuple[float, float, float],
t: float,
) -> tuple[int, int, int]:
"""Linearly interpolate between two RGB colors in HSV color space."""
t = abs(t)
assert 0 <= t <= 1
# Convert RGB to HSV
hsv1 = colorsys.rgb_to_hsv(*[x / 255.0 for x in rgb1])
hsv2 = colorsys.rgb_to_hsv(*[x / 255.0 for x in rgb2])
# Linear interpolation in HSV space
hsv = (
hsv1[0] + t * (hsv2[0] - hsv1[0]),
hsv1[1] + t * (hsv2[1] - hsv1[1]),
hsv1[2] + t * (hsv2[2] - hsv1[2]),
)
# Convert back to RGB
rgb = tuple(int(round(x * 255)) for x in colorsys.hsv_to_rgb(*hsv))
assert all(0 <= x <= 255 for x in rgb), f"Invalid RGB color: {rgb}"
return cast(tuple[int, int, int], rgb)
def lerp(x, x1, x2, y1, y2):
"""Linearly interpolate between two values."""
return y1 + (x - x1) * (y2 - y1) / (x2 - x1)
def clamp(value: float, minimum: float, maximum: float) -> float:
"""Clamp value between minimum and maximum."""
return max(minimum, min(value, maximum))

View file

@ -1,77 +0,0 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --output-file=requirements-locked.txt requirements.txt
#
anyio==4.2.0
# via
# starlette
# watchfiles
appdirs==1.4.4
# via
# shiny
# shinylive
asgiref==3.7.2
# via shiny
astral==2.2
# via -r requirements.txt
click==8.1.7
# via
# shiny
# shinylive
# uvicorn
h11==0.14.0
# via uvicorn
htmltools==0.5.1
# via
# shiny
# shinyswatch
idna==3.6
# via anyio
linkify-it-py==2.0.2
# via shiny
markdown-it-py==3.0.0
# via
# mdit-py-plugins
# shiny
mdit-py-plugins==0.4.0
# via shiny
mdurl==0.1.2
# via markdown-it-py
packaging==23.2
# via
# htmltools
# shinyswatch
python-multipart==0.0.6
# via shiny
pytz==2023.3.post1
# via astral
shiny==0.5.0
# via
# -r requirements.txt
# shinylive
# shinyswatch
shinylive==0.1.1
# via -r requirements.txt
shinyswatch==0.3.1
# via -r requirements.txt
sniffio==1.3.0
# via anyio
starlette==0.34.0
# via shiny
typing-extensions==4.9.0
# via
# htmltools
# shiny
# shinyswatch
uc-micro-py==1.0.2
# via linkify-it-py
uvicorn==0.25.0
# via shiny
watchfiles==0.21.0
# via shiny
websockets==12.0
# via shiny
xstatic-bootswatch==3.3.7.0
# via shinyswatch

View file

@ -1,4 +1,6 @@
shinylive==0.1.1
# This file was autogenerated by uv via the following command:
# uv pip compile --output-file=requirements.txt requirements.txt.in
astral==2.2
shinyswatch==0.3.1
shiny==0.5.0
# via -r requirements.txt.in
pytz==2023.3.post1
# via astral

View file

@ -0,0 +1 @@
astral==2.2