3 Commits

Author SHA1 Message Date
a9fb58c87a Repeat relative dimming steps 2026-02-15 21:06:22 +01:00
c8d05acae9 Tune relative dimming steps 2026-02-15 21:00:24 +01:00
082ce93334 Fix light color temperature decoding 2026-02-15 20:42:32 +01:00
5 changed files with 58 additions and 22 deletions

View File

@@ -41,7 +41,10 @@ Completed:
- Light port support added with full KNX color/temperature mappings and individual color channels.
- Light port keys renamed to avoid conflicts; outgoing updates now only target light state addresses.
- Light port optional relative dimming address (DPT 3.007) added.
- Project version set to 0.0.23 and `CHANGELOG.md` maintained.
- Light color temperature event type mapping and relative dimming decoding fixed.
- Relative dimming step mapping tuned to avoid on/off jumps.
- Relative dimming now repeats steps until a stop telegram is received.
- Project version set to 0.0.26 and `CHANGELOG.md` maintained.
Files created:
- `custom_components/ha_knx_bridge/__init__.py`

View File

@@ -1,5 +1,14 @@
# Changelog
## 0.0.26 - 2026-02-15
- Repeat relative dimming steps until a stop telegram is received.
## 0.0.25 - 2026-02-15
- Tune light relative dimming step mapping to avoid on/off jumps.
## 0.0.24 - 2026-02-15
- Fix light color temperature event type mapping and improve relative dimming decoding.
## 0.0.23 - 2026-02-15
- Add optional light relative dimming address (DPT 3.007).

View File

@@ -73,7 +73,9 @@ Only state addresses expose an `invert outgoing` toggle to flip KNX payloads.
Notes:
- For XY color, the bridge sends the brightness as the Y (luminance) component.
- Relative dimming (DPT 3.007) maps KNX step values to `brightness_step_pct` in Home Assistant.
- Relative dimming (DPT 3.007) maps KNX step values to small `brightness_step_pct` changes in Home Assistant.
- For relative dimming, the bridge repeats steps until a KNX stop telegram (0 or 8) is received.
- Color temperature mode must match the KNX telegram DPT: `relative` for 5.001, `absolute` for 7.600, `absolute_float` for DPT 9.
## Notes
- For DPT 1.008 (Up/Down), the bridge treats `0 = Up/Open` and `1 = Down/Close`.
@@ -107,5 +109,5 @@ Notes:
- Advanced DPT mapping options and inversion settings.
## Versioning and Releases
- Current version: 0.0.23
- Current version: 0.0.26
- `CHANGELOG.md` lists versions with the newest entries at the top.

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
from dataclasses import dataclass
import asyncio
import logging
from typing import Any
@@ -181,6 +182,7 @@ class BridgeManager:
self._registered_addresses: list[tuple[str, str | None]] = []
self._address_options: dict[str, AddressOptions] = {}
self._light_components: dict[str, dict[str, int]] = {}
self._light_dimming_tasks: dict[str, asyncio.Task] = {}
async def async_setup(self) -> None:
if not self.hass.services.has_service(KNX_DOMAIN, "send"):
@@ -199,6 +201,10 @@ class BridgeManager:
self._knx_event_unsub()
self._knx_event_unsub = None
for task in self._light_dimming_tasks.values():
task.cancel()
self._light_dimming_tasks.clear()
await self._unregister_knx_events()
def _load_ports(
@@ -1155,6 +1161,7 @@ class BridgeManager:
if value is None:
return
if value in (0, 8):
self._stop_light_dimming(port.entity_id)
return
step = _relative_dimming_step(value)
if step is None:
@@ -1162,13 +1169,7 @@ class BridgeManager:
direction, percent = step
if percent <= 0:
return
if direction == "down":
percent = -percent
await self._call_light_service(
port.entity_id,
"turn_on",
{"brightness_step_pct": percent},
)
self._start_light_dimming(port.entity_id, direction, percent)
return
if action.startswith("red_"):
@@ -1399,6 +1400,28 @@ class BridgeManager:
},
)
def _start_light_dimming(
self, entity_id: str, direction: str, percent: int
) -> None:
self._stop_light_dimming(entity_id)
async def _runner() -> None:
while True:
step = percent if direction == "up" else -percent
await self._call_light_service(
entity_id, "turn_on", {"brightness_step_pct": step}
)
await asyncio.sleep(0.3)
self._light_dimming_tasks[entity_id] = self.hass.async_create_task(
_runner()
)
def _stop_light_dimming(self, entity_id: str) -> None:
task = self._light_dimming_tasks.pop(entity_id, None)
if task is not None:
task.cancel()
def _extract_event_value(event: Event) -> int | None:
if "value" in event.data:
@@ -1612,9 +1635,9 @@ def _light_color_temperature_event_type(mode: str) -> str | None:
if mode == "relative":
return "percent"
if mode == "absolute":
return "7.600"
return "2byte_unsigned"
if mode == "absolute_float":
return "9"
return "2byte_float"
return None
@@ -1668,8 +1691,7 @@ def _light_uses_white_channel(port: LightPort) -> bool:
def _relative_dimming_step(value: int) -> tuple[str, int] | None:
if value < 0 or value > 15:
return None
value = value & 0x0F
if value == 0 or value == 8:
return None
if value <= 7:
@@ -1679,13 +1701,13 @@ def _relative_dimming_step(value: int) -> tuple[str, int] | None:
direction = "up"
step = value - 8
percent_map = {
1: 100,
2: 50,
3: 25,
4: 13,
5: 6,
6: 3,
7: 2,
1: 10,
2: 8,
3: 6,
4: 4,
5: 3,
6: 2,
7: 1,
}
percent = percent_map.get(step)
if percent is None:

View File

@@ -1,7 +1,7 @@
{
"domain": "ha_knx_bridge",
"name": "HA KNX Bridge",
"version": "0.0.23",
"version": "0.0.26",
"config_flow": true,
"documentation": "https://github.com/bahmcloud/HA-KNX-Bridge",
"issue_tracker": "https://github.com/bahmcloud/HA-KNX-Bridge/issues",