mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use KNX group address format from project (#124084)
This commit is contained in:
parent
41e66edd14
commit
8504a16e83
@ -297,6 +297,7 @@ class KNXModule:
|
||||
self.config_store = KNXConfigStore(hass=hass, config_entry=entry)
|
||||
|
||||
self.xknx = XKNX(
|
||||
address_format=self.project.get_address_format(),
|
||||
connection_config=self.connection_config(),
|
||||
rate_limit=self.entry.data[CONF_KNX_RATE_LIMIT],
|
||||
state_updater=self.entry.data[CONF_KNX_STATE_UPDATER],
|
||||
|
@ -8,12 +8,13 @@ from typing import Final
|
||||
|
||||
from xknx import XKNX
|
||||
from xknx.dpt import DPTBase
|
||||
from xknx.telegram.address import DeviceAddressableType
|
||||
from xknx.telegram.address import DeviceAddressableType, GroupAddress, GroupAddressType
|
||||
from xknxproject import XKNXProj
|
||||
from xknxproject.models import (
|
||||
Device,
|
||||
DPTType,
|
||||
GroupAddress as GroupAddressModel,
|
||||
GroupAddressStyle as XknxProjectGroupAddressStyle,
|
||||
KNXProject as KNXProjectModel,
|
||||
ProjectInfo,
|
||||
)
|
||||
@ -90,6 +91,7 @@ class KNXProject:
|
||||
if project := data or await self._store.async_load():
|
||||
self.devices = project["devices"]
|
||||
self.info = project["info"]
|
||||
GroupAddress.address_format = self.get_address_format()
|
||||
xknx.group_address_dpt.clear()
|
||||
xknx_ga_dict: dict[DeviceAddressableType, DPTType] = {}
|
||||
|
||||
@ -133,3 +135,13 @@ class KNXProject:
|
||||
async def get_knxproject(self) -> KNXProjectModel | None:
|
||||
"""Load the project file from local storage."""
|
||||
return await self._store.async_load()
|
||||
|
||||
def get_address_format(self) -> GroupAddressType:
|
||||
"""Return the address format for group addresses used in the project."""
|
||||
if self.info:
|
||||
match self.info["group_address_style"]:
|
||||
case XknxProjectGroupAddressStyle.TWOLEVEL.value:
|
||||
return GroupAddressType.SHORT
|
||||
case XknxProjectGroupAddressStyle.FREE.value:
|
||||
return GroupAddressType.FREE
|
||||
return GroupAddressType.LONG
|
||||
|
Loading…
x
Reference in New Issue
Block a user