mirror of
https://github.com/bahmcloud/HA-KNX-Bridge.git
synced 2026-04-06 19:11:15 +00:00
Repeat relative dimming steps
This commit is contained in:
3
.idea/PROJECT_STATE.md
generated
3
.idea/PROJECT_STATE.md
generated
@@ -43,7 +43,8 @@ Completed:
|
|||||||
- Light port optional relative dimming address (DPT 3.007) added.
|
- Light port optional relative dimming address (DPT 3.007) added.
|
||||||
- Light color temperature event type mapping and relative dimming decoding fixed.
|
- Light color temperature event type mapping and relative dimming decoding fixed.
|
||||||
- Relative dimming step mapping tuned to avoid on/off jumps.
|
- Relative dimming step mapping tuned to avoid on/off jumps.
|
||||||
- Project version set to 0.0.25 and `CHANGELOG.md` maintained.
|
- Relative dimming now repeats steps until a stop telegram is received.
|
||||||
|
- Project version set to 0.0.26 and `CHANGELOG.md` maintained.
|
||||||
|
|
||||||
Files created:
|
Files created:
|
||||||
- `custom_components/ha_knx_bridge/__init__.py`
|
- `custom_components/ha_knx_bridge/__init__.py`
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.0.26 - 2026-02-15
|
||||||
|
- Repeat relative dimming steps until a stop telegram is received.
|
||||||
|
|
||||||
## 0.0.25 - 2026-02-15
|
## 0.0.25 - 2026-02-15
|
||||||
- Tune light relative dimming step mapping to avoid on/off jumps.
|
- Tune light relative dimming step mapping to avoid on/off jumps.
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ Only state addresses expose an `invert outgoing` toggle to flip KNX payloads.
|
|||||||
Notes:
|
Notes:
|
||||||
- For XY color, the bridge sends the brightness as the Y (luminance) component.
|
- For XY color, the bridge sends the brightness as the Y (luminance) component.
|
||||||
- Relative dimming (DPT 3.007) maps KNX step values to small `brightness_step_pct` changes 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.
|
- Color temperature mode must match the KNX telegram DPT: `relative` for 5.001, `absolute` for 7.600, `absolute_float` for DPT 9.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
@@ -108,5 +109,5 @@ Notes:
|
|||||||
- Advanced DPT mapping options and inversion settings.
|
- Advanced DPT mapping options and inversion settings.
|
||||||
|
|
||||||
## Versioning and Releases
|
## Versioning and Releases
|
||||||
- Current version: 0.0.25
|
- Current version: 0.0.26
|
||||||
- `CHANGELOG.md` lists versions with the newest entries at the top.
|
- `CHANGELOG.md` lists versions with the newest entries at the top.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@@ -181,6 +182,7 @@ class BridgeManager:
|
|||||||
self._registered_addresses: list[tuple[str, str | None]] = []
|
self._registered_addresses: list[tuple[str, str | None]] = []
|
||||||
self._address_options: dict[str, AddressOptions] = {}
|
self._address_options: dict[str, AddressOptions] = {}
|
||||||
self._light_components: dict[str, dict[str, int]] = {}
|
self._light_components: dict[str, dict[str, int]] = {}
|
||||||
|
self._light_dimming_tasks: dict[str, asyncio.Task] = {}
|
||||||
|
|
||||||
async def async_setup(self) -> None:
|
async def async_setup(self) -> None:
|
||||||
if not self.hass.services.has_service(KNX_DOMAIN, "send"):
|
if not self.hass.services.has_service(KNX_DOMAIN, "send"):
|
||||||
@@ -199,6 +201,10 @@ class BridgeManager:
|
|||||||
self._knx_event_unsub()
|
self._knx_event_unsub()
|
||||||
self._knx_event_unsub = None
|
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()
|
await self._unregister_knx_events()
|
||||||
|
|
||||||
def _load_ports(
|
def _load_ports(
|
||||||
@@ -1155,6 +1161,7 @@ class BridgeManager:
|
|||||||
if value is None:
|
if value is None:
|
||||||
return
|
return
|
||||||
if value in (0, 8):
|
if value in (0, 8):
|
||||||
|
self._stop_light_dimming(port.entity_id)
|
||||||
return
|
return
|
||||||
step = _relative_dimming_step(value)
|
step = _relative_dimming_step(value)
|
||||||
if step is None:
|
if step is None:
|
||||||
@@ -1162,13 +1169,7 @@ class BridgeManager:
|
|||||||
direction, percent = step
|
direction, percent = step
|
||||||
if percent <= 0:
|
if percent <= 0:
|
||||||
return
|
return
|
||||||
if direction == "down":
|
self._start_light_dimming(port.entity_id, direction, percent)
|
||||||
percent = -percent
|
|
||||||
await self._call_light_service(
|
|
||||||
port.entity_id,
|
|
||||||
"turn_on",
|
|
||||||
{"brightness_step_pct": percent},
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if action.startswith("red_"):
|
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:
|
def _extract_event_value(event: Event) -> int | None:
|
||||||
if "value" in event.data:
|
if "value" in event.data:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"domain": "ha_knx_bridge",
|
"domain": "ha_knx_bridge",
|
||||||
"name": "HA KNX Bridge",
|
"name": "HA KNX Bridge",
|
||||||
"version": "0.0.25",
|
"version": "0.0.26",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://github.com/bahmcloud/HA-KNX-Bridge",
|
"documentation": "https://github.com/bahmcloud/HA-KNX-Bridge",
|
||||||
"issue_tracker": "https://github.com/bahmcloud/HA-KNX-Bridge/issues",
|
"issue_tracker": "https://github.com/bahmcloud/HA-KNX-Bridge/issues",
|
||||||
|
|||||||
Reference in New Issue
Block a user