Fix for fridge program names
This commit is contained in:
parent
ecbf438889
commit
eea79e28b9
@ -71,7 +71,7 @@ class HonCommand:
|
|||||||
def parameter_groups(self) -> Dict[str, Dict[str, Union[str, float]]]:
|
def parameter_groups(self) -> Dict[str, Dict[str, Union[str, float]]]:
|
||||||
result: Dict[str, Dict[str, Union[str, float]]] = {}
|
result: Dict[str, Dict[str, Union[str, float]]] = {}
|
||||||
for name, parameter in self._parameters.items():
|
for name, parameter in self._parameters.items():
|
||||||
result.setdefault(parameter.group, {})[name] = parameter.value
|
result.setdefault(parameter.group, {})[name] = parameter.intern_value
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -22,6 +22,10 @@ class HonParameter:
|
|||||||
def value(self) -> str | float:
|
def value(self) -> str | float:
|
||||||
return self._value if self._value is not None else "0"
|
return self._value if self._value is not None else "0"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def intern_value(self) -> str | float:
|
||||||
|
return str(self._value) if self._value is not None else ""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def values(self) -> List[str]:
|
def values(self) -> List[str]:
|
||||||
return [str(self.value)]
|
return [str(self.value)]
|
||||||
|
@ -3,13 +3,17 @@ from typing import Dict, Any, List
|
|||||||
from pyhon.parameter.base import HonParameter
|
from pyhon.parameter.base import HonParameter
|
||||||
|
|
||||||
|
|
||||||
|
def clean_value(value):
|
||||||
|
return str(value).strip("[]").replace("|", "_").lower()
|
||||||
|
|
||||||
|
|
||||||
class HonParameterEnum(HonParameter):
|
class HonParameterEnum(HonParameter):
|
||||||
def __init__(self, key: str, attributes: Dict[str, Any], group: str) -> None:
|
def __init__(self, key: str, attributes: Dict[str, Any], group: str) -> None:
|
||||||
super().__init__(key, attributes, group)
|
super().__init__(key, attributes, group)
|
||||||
self._default = attributes.get("defaultValue")
|
self._default = attributes.get("defaultValue")
|
||||||
self._value = self._default or "0"
|
self._value = self._default or "0"
|
||||||
self._values: List[str] = attributes.get("enumValues", [])
|
self._values: List[str] = attributes.get("enumValues", [])
|
||||||
if self._default and str(self._default.strip("[]")) not in self.values:
|
if self._default and clean_value(self._default.strip("[]")) not in self.values:
|
||||||
self._values.append(self._default)
|
self._values.append(self._default)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
@ -17,7 +21,7 @@ class HonParameterEnum(HonParameter):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def values(self) -> List[str]:
|
def values(self) -> List[str]:
|
||||||
return [str(value) for value in self._values]
|
return [clean_value(value) for value in self._values]
|
||||||
|
|
||||||
@values.setter
|
@values.setter
|
||||||
def values(self, values) -> None:
|
def values(self, values) -> None:
|
||||||
@ -25,7 +29,7 @@ class HonParameterEnum(HonParameter):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def value(self) -> str | float:
|
def value(self) -> str | float:
|
||||||
return self._value if self._value is not None else self.values[0]
|
return clean_value(self._value) if self._value is not None else self.values[0]
|
||||||
|
|
||||||
@value.setter
|
@value.setter
|
||||||
def value(self, value: str) -> None:
|
def value(self, value: str) -> None:
|
||||||
|
2
setup.py
2
setup.py
@ -7,7 +7,7 @@ with open("README.md", "r") as f:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="pyhOn",
|
name="pyhOn",
|
||||||
version="0.11.0",
|
version="0.11.1",
|
||||||
author="Andre Basche",
|
author="Andre Basche",
|
||||||
description="Control hOn devices with python",
|
description="Control hOn devices with python",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
|
Loading…
Reference in New Issue
Block a user