Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6c4a30e
Implement a get_version_str() function for each version data-type
Guzz-T Nov 18, 2026
d646231
Move the get_version_definitions to a more general location
Guzz-T Nov 15, 2026
177ba07
Use the resolve_version_input() function within the SHI create_modbus…
Guzz-T Nov 15, 2026
de429ae
Merge pull request #79 from Guzz-T/issue/78/cfi-version-defs
Guzz-T Nov 18, 2026
69b955b
Use the Keys within the get_version_definitions() pytest
Guzz-T Nov 15, 2026
0b767a0
Add a pytest that checks whether all cfi/shi methods are unique
Guzz-T Nov 18, 2026
8c99644
Consistently use LUXTRONIK_VERSION_IGNORE instead of LUXTRONIK_LATEST…
Guzz-T Nov 18, 2026
1495ae8
Use the LuxtronikSmartHomeInterface inside of the determine_shi_versi…
Guzz-T Nov 18, 2026
265df0b
Make get_version_definitions available via the LuxtronikDefinitionsList
Guzz-T Nov 18, 2026
97f3252
Move the functionality to determine the version into the smart home i…
Guzz-T Nov 18, 2026
5e5e11c
Add a pytest for the version determination within the smart home inte…
Guzz-T Nov 18, 2026
615bd5d
Merge pull request #80 from Guzz-T/issue/78/cfi-version-vector
Guzz-T Nov 18, 2026
e40a68f
Refactor determine_shi_version to determine_version
Guzz-T Nov 21, 2026
08b9ebb
Use a try-except block within the Version.get_version_str() method
Guzz-T Nov 21, 2026
6550b81
Improve the string output of the internal VER_IGNORE and VER_NONE obj…
Guzz-T Nov 21, 2026
9997128
Allow version strings with v/V like v1.2.3 as input for the parse_ver…
Guzz-T Nov 18, 2026
fbe3478
Add the possibility to filter the get_version_definitions definitions…
Guzz-T Nov 18, 2026
db53065
Implement a inputs.get_firmware_version() function that matches the i…
Guzz-T Nov 18, 2026
cebce09
Merge pull request #81 from Guzz-T/issue/78/cfi-version-common
Guzz-T Nov 22, 2026
4c8d0b1
Move the version-dependent SHI data vector constructor into the base …
Guzz-T Nov 18, 2026
7402e7f
Move the version-dependent SHI data vector add function into the base…
Guzz-T Nov 18, 2026
5b3e6d9
Merge pull request #82 from Guzz-T/issue/78/cfi-version-vector
Guzz-T Nov 22, 2026
0e279d4
Add a version argument to the LuxtronikData
Guzz-T Nov 18, 2026
560dd6a
Add an empty constructor for the LuxtronikData and LuxtronikAllData
Guzz-T Nov 18, 2026
f19412f
Merge pull request #83 from Guzz-T/issue/78/cfi-version-data
Guzz-T Nov 22, 2026
d06d891
Use only unique identifiers for methods and fields
Guzz-T Nov 21, 2026
ccfb450
Add an version argument to the LuxtronikSocketInterface constructor t…
Guzz-T Nov 21, 2026
305a579
Add a automatic version detection method to the LuxtronikSocketInterface
Guzz-T Nov 21, 2026
dd217e0
Add a base class for the LuxtronikSmartHomeInterface and the Luxtroni…
Guzz-T Nov 21, 2026
020ac0f
Merge pull request #84 from Guzz-T/issue/78/cfi-version-intf
Guzz-T Nov 22, 2026
24a2117
Improve the LuxtronikInterface to be able to set the desired version
Guzz-T Nov 21, 2026
e32385e
Implement and use a device information class within the luxtronik int…
Guzz-T Nov 21, 2026
8976668
Implement a pytest that checks that the LuxtronikSocketInterface and …
Guzz-T Nov 21, 2026
40543e0
Merge pull request #85 from Guzz-T/issue/78/cfi-version-lux
Guzz-T Nov 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 94 additions & 16 deletions luxtronik/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

import logging

from luxtronik.constants import LUXTRONIK_VERSION_DETECT, LUXTRONIK_VERSION_IGNORE
from luxtronik.common import get_host_lock
from luxtronik.discover import discover # noqa: F401
from luxtronik.interface import LuxtronikInterfaceInfo
from luxtronik.version import VER_IGNORE, resolve_version_input

from luxtronik.cfi import (
LUXTRONIK_DEFAULT_CFI_PORT,
Expand All @@ -24,7 +27,6 @@
Inputs, # noqa: F401
LuxtronikSmartHomeData,
LuxtronikSmartHomeInterface,
resolve_version,
)
# endregion Imports

Expand All @@ -51,7 +53,7 @@ def __init__(
visibilities=None,
holdings=None,
inputs=None,
version=None,
version=LUXTRONIK_VERSION_IGNORE,
safe=True
):
"""
Expand All @@ -68,32 +70,73 @@ def __init__(
a new `Holdings` instance is created.
inputs (Inputs): Optional inputs data vector. If not provided,
a new `Inputs` instance is created.
version (tuple[int] | None): Version to be used for creating the data vectors.
version (tuple[int] | str | None): Version to be used for creating the data vectors.
This ensures that the data vectors only contain valid fields.
If None is passed, all available fields are added.
safe (bool): If true, prevent parameter and holding fields marked as
not secure from being written to.
"""
LuxtronikData.__init__(self, parameters, calculations, visibilities, safe)
version, _ = resolve_version_input(version) # no auto-detect possible here
LuxtronikData.__init__(self, parameters, calculations, visibilities, version, safe)
LuxtronikSmartHomeData.__init__(self, holdings, inputs, version, safe)

@classmethod
def empty(
cls,
version=LUXTRONIK_VERSION_IGNORE,
safe=True
):
"""
Initialize an empty LuxtronikAllData instance
(= no fields are added to the data-vectors).

Args:
version (tuple[int] | str | None): The version is added to the data vectors
so some checks can be performed later.
(default: LUXTRONIK_VERSION_IGNORE)
safe (bool): If true, prevent holding fields marked as
not secure from being written to.
"""
obj = cls.__new__(cls)
version, _ = resolve_version_input(version) # no auto-detect possible here
LuxtronikData.empty(
obj,
Parameters.empty(version, safe),
Calculations.empty(version),
Visibilities.empty(version),
version,
safe
)
LuxtronikSmartHomeData.empty(
obj,
Holdings.empty(version, safe),
Inputs.empty(version),
version,
safe
)
return obj

def get_firmware_version(self):
return LuxtronikData.get_firmware_version(self)


class LuxtronikInterface(LuxtronikSocketInterface, LuxtronikSmartHomeInterface):
"""
Combined interface that can be used to control both
the configuration interface and the smart home interface.

For simplicity, only the basic functions are offered.

Attention! It must be ensured that `LuxtronikSocketInterface` and
`LuxtronikSmartHomeInterface` do not instantiate the same fields.
Otherwise, the derivations will overwrite each other.
Luckily, there's a pytest for that.
"""

def __init__(
self,
host,
port_config=LUXTRONIK_DEFAULT_CFI_PORT,
port_shi=LUXTRONIK_DEFAULT_MODBUS_PORT
port_shi=LUXTRONIK_DEFAULT_MODBUS_PORT,
version=LUXTRONIK_VERSION_DETECT
):
"""
Initialize the "combined" luxtronik interface.
Expand All @@ -104,18 +147,52 @@ def __init__(
(default: LUXTRONIK_DEFAULT_CFI_PORT).
port_shi (int): TCP port for the smart home interface (via modbusTCP)
(default: LUXTRONIK_DEFAULT_MODBUS_PORT).
version (tuple[int] | str | None): Version to be used for creating the interface.
This ensures that the created data vectors only contain valid fields.
If None is passed, all available fields will be added.
"""
self._lock = get_host_lock(host)
self.__lock = get_host_lock(host)

self._host = host
LuxtronikSocketInterface.__init__(self, host, port_config)
modbus_interface = LuxtronikModbusTcpInterface(host, port_shi)
resolved_version = resolve_version(modbus_interface)
LuxtronikSmartHomeInterface.__init__(self, modbus_interface, resolved_version)

version, auto_detect = resolve_version_input(version)
if auto_detect:
# Use the CFI since this should always be available
version = LuxtronikSocketInterface.determine_version(host, port_config)
# If the version is still unknown, try this via the SHI
if version == VER_IGNORE:
version = LuxtronikSmartHomeInterface.determine_version(modbus_interface)

self.__info = LuxtronikInterfaceInfo(
'Lux',
host,
f"{port_config};{port_shi}",
version
)

LuxtronikSocketInterface.__init__(self, host, port_config, version)
LuxtronikSmartHomeInterface.__init__(self, modbus_interface, version)

@property
def lock(self):
return self._lock
return self.__lock

@property
def info(self):
return self.__info

# We do not need to override the determine_version() method
# def determine_version(cls, host, port):

@property
def version(self):
return LuxtronikSocketInterface.version.fget(self)

def read_version(self):
return LuxtronikSocketInterface.read_version(self)

def create_data(self, safe=True):
return self.create_all_data(safe)

def create_all_data(self, safe=True):
"""
Expand All @@ -128,7 +205,7 @@ def create_all_data(self, safe=True):
Returns:
LuxtronikAllData: The created data-collection.
"""
return LuxtronikAllData(None, None, None, None, None, self._version, safe)
return LuxtronikAllData(None, None, None, None, None, self.version, safe)

def read_all(self, data=None):
"""
Expand Down Expand Up @@ -234,9 +311,10 @@ def __init__(
host,
port=LUXTRONIK_DEFAULT_CFI_PORT,
safe=True,
port_shi=LUXTRONIK_DEFAULT_MODBUS_PORT
port_shi=LUXTRONIK_DEFAULT_MODBUS_PORT,
version=LUXTRONIK_VERSION_DETECT
):
self._interface = LuxtronikInterface(host, port, port_shi)
self._interface = LuxtronikInterface(host, port, port_shi, version)
super().__init__(version=self._interface.version, safe=safe)
self.read()

Expand Down
2 changes: 1 addition & 1 deletion luxtronik/cfi/calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)

class Calculations(DataVectorConfig):
"""Class that holds all calculations."""
"""Class that holds calculation fields."""

name = CALCULATIONS_FIELD_NAME
definitions = CALCULATIONS_DEFINITIONS
Expand Down
Loading
Loading