Skip to content

Commit

Permalink
Store even a single name as a list.
Browse files Browse the repository at this point in the history
Now `_names` within `Base` is always a list.
  • Loading branch information
Guzz-T committed Nov 2, 2024
1 parent 6dab5d6 commit bb1d635
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions luxtronik/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def __init__(self, name, writeable=False):
# save the raw value only since the user value
# could be build at any time
self._raw = None
self._name = name
if isinstance(name, list):
self._names = name
else:
self._names = [name]
assert self._names.len() > 0 , "At least one name is required"
self.writeable = writeable

@classmethod
Expand All @@ -35,17 +39,11 @@ def from_heatpump(cls, value):
@property
def name(self):
"""Return the (most common) name of the entry."""
if isinstance(self._name, list):
return self._name[0]
else:
return self._name
return self._names[0]

def get_supported_names(self):
"""Return a list of all supported entry names."""
if isinstance(self._name, list):
return self._name
else:
return [self._name]
return self._names

def check_name(self, name):
"""
Expand Down

0 comments on commit bb1d635

Please sign in to comment.