Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 18 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ There is no automatically rendered documentation of this library available yet,
so you'll have to fall back to using the source code itself as documentation.
It can be found in the [luxtronik](luxtronik/) directory.

Discovered data fields:

- Calculations holds measurement values (config interface): \
[luxtronik/definitions/calculations.py](luxtronik/definitions/calculations.py)

- Parameters holds parameter values (config interface): \
[luxtronik/definitions/parameters.py](luxtronik/definitions/parameters.py)

- Visibilities holds visibility values (config interface),
the function of visibilities is not clear at this point: \
[luxtronik/definitions/visibilities.py](luxtronik/definitions/visibilities.py)

- Inputs holds read-only values (smart home interface): \
[luxtronik/definitions/inputs.py](luxtronik/definitions/inputs.py)

- Holdings holds read-and-writeable values (smart home interface): \
[luxtronik/definitions/holdings.py](luxtronik/definitions/holdings.py)

## EXAMPLE USAGE

### READING VALUES FROM THE HEAT PUMP
Expand Down Expand Up @@ -84,21 +102,6 @@ print(t_forerun.unit) # gives you the unit of the value if known, °C for exampl
t_flowline = l.inputs["flow_line_temp"]

print(t_flowline) # returns 22.7 for example again

# calculations holds measurement values (config interface)
# check https://github.com/Bouni/python-luxtronik/blob/master/luxtronik/calculations.py for values you might need

# parameters holds parameter values (config interface)
# check https://github.com/Bouni/python-luxtronik/blob/master/luxtronik/parameters.py for values you might need

# visibilitys holds visibility values (config interface), the function of visibilities is not clear at this point
# check https://github.com/Bouni/python-luxtronik/blob/master/luxtronik/visibilities.py for values you might need

# inputs holds read-only values (smart home interface)
# check https://github.com/Bouni/python-luxtronik/blob/master/luxtronik/definitions/inputs.py for values you might need

# holdings holds read-and-writeable values (smart home interface)
# check https://github.com/Bouni/python-luxtronik/blob/master/luxtronik/definitions/holdings.py for values you might need
```

The method `read()` reads all those data vectors (calculations, parameters,
Expand Down
318 changes: 14 additions & 304 deletions luxtronik/calculations.py

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions luxtronik/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
# Content of response that is contained in responses to discovery broadcast
LUXTRONIK_DISCOVERY_RESPONSE_PREFIX = "2500;111;"

# Identifier of calculation data-vectors and partial name for unknown calculation fields
CALCULATIONS_FIELD_NAME = "calculation"

# Identifier of parameter data-vectors and partial name for unknown parameter fields
PARAMETERS_FIELD_NAME = "parameter"

# Identifier of visibilities data-vectors and partial name for unknown visibility fields
VISIBILITIES_FIELD_NAME = "visibility"

LUXTRONIK_NAME_CHECK_NONE = "none"
LUXTRONIK_NAME_CHECK_PREFERRED = "preferred"
LUXTRONIK_NAME_CHECK_OBSOLETE = "obsolete"
2 changes: 1 addition & 1 deletion luxtronik/data_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def parse(self, raw_data):
entry.raw = data
else:
# self.logger.warning(f"Entry '%d' not in list of {self.name}", index)
entry = Unknown(f"Unknown_{self.name}_{index}")
entry = Unknown(f"unknown_{self.name}_{index}")
entry.raw = data
self._data[index] = entry

Expand Down
1,205 changes: 14 additions & 1,191 deletions luxtronik/parameters.py

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions luxtronik/shi/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
# Default timeout (in seconds) for Modbus operations
LUXTRONIK_DEFAULT_MODBUS_TIMEOUT: Final = 30

# Default offset for the input or holding indices
LUXTRONIK_DEFAULT_DEFINITION_OFFSET: Final = 10000

# Identifier of holding data-vectors and partial name for unknown holding fields
HOLDINGS_FIELD_NAME: Final = "holding"

Expand Down
20 changes: 8 additions & 12 deletions luxtronik/shi/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from luxtronik.datatypes import Unknown
from luxtronik.shi.constants import (
LUXTRONIK_DEFAULT_DEFINITION_OFFSET,
LUXTRONIK_SHI_REGISTER_BIT_SIZE,
LUXTRONIK_VALUE_FUNCTION_NOT_AVAILABLE
)
Expand Down Expand Up @@ -42,15 +41,14 @@ class LuxtronikDefinition:
"description": "",
}

def __init__(self, data_dict, type_name, offset=LUXTRONIK_DEFAULT_DEFINITION_OFFSET):
def __init__(self, data_dict, type_name, offset):
"""
Initialize a definition from a data-dictionary.

Args:
data_dict (dict): Definition values. Missing keys are filled with defaults.
type_name (str): The type name e.g. 'holding', 'input', ... .
type_name (str): The type name e.g. 'parameter', 'holding', 'input', ... .
offset (str): Offset of the address from the specified index.
(Default: LUXTRONIK_DEFAULT_DEFINITION_OFFSET)

Notes:
- Only 'index' is strictly required within the `data_dict`.
Expand Down Expand Up @@ -89,15 +87,14 @@ def __init__(self, data_dict, type_name, offset=LUXTRONIK_DEFAULT_DEFINITION_OFF
LOGGER.error(f"Failed to create LuxtronikDefinition: '{e}' with {data_dict}")

@classmethod
def unknown(cls, index, type_name, offset=LUXTRONIK_DEFAULT_DEFINITION_OFFSET):
def unknown(cls, index, type_name, offset):
"""
Create an "unknown" definition.

Args:
index (int): The register index of the "unknown" definition.
type_name (str): The type name e.g. 'holding', 'input', ... .
offset (str): Offset of the address from the specified index.
(Default: LUXTRONIK_DEFAULT_DEFINITION_OFFSET)

Returns:
LuxtronikDefinition: A definition marked as unknown.
Expand All @@ -121,7 +118,7 @@ def valid(self):

@property
def type_name(self):
"Returns the type name (e.g. 'holding', 'input', ...)."
"Returns the type name (e.g. 'parameter', 'holding', 'input', ...)."
return self._type_name

@property
Expand All @@ -138,7 +135,7 @@ def addr(self):

@property
def count(self):
"Returns the assigned number of used bytes/words."
"Returns the assigned number of used registers."
return self._count

@property
Expand Down Expand Up @@ -177,7 +174,7 @@ def create_field(self):
Returns:
Base | None: Field instance or None if invalid.
"""
return self.data_type(self.name, self.writeable) if self.valid else None
return self.data_type(self.names, self.writeable) if self.valid else None


###############################################################################
Expand Down Expand Up @@ -395,15 +392,14 @@ def _init_instance(self, name, offset, version):
self._definitions = []
self._lookup = LuxtronikDefinitionsDictionary()

def __init__(self, definitions_list, name, offset=LUXTRONIK_DEFAULT_DEFINITION_OFFSET):
def __init__(self, definitions_list, name, offset):
"""
Initialize the (by index sorted) definitions list.

Args:
definitions_list (list[dict]): Raw definition entries as list of data-dictionaries.
name (str): Name related to this type of definitions (e.g. "holding")
name (str): Name related to this type of definitions (e.g. "calculation", "holding", etc.)
offset (int): Offset applied to register indices.
(Default: LUXTRONIK_DEFAULT_DEFINITION_OFFSET)

Notes on the definitions_list:
- Must be sorted by ascending index
Expand Down
Loading