mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-01-19 02:50:44 +00:00
Add oven and program filter
This commit is contained in:
parent
6d40e73881
commit
36079c3c77
16
pyhon/appliances/ov.py
Normal file
16
pyhon/appliances/ov.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
from pyhon.parameter import HonParameterEnum
|
||||
|
||||
|
||||
class Appliance:
|
||||
def __init__(self):
|
||||
filters = ["receipt", "standard, special"]
|
||||
data = {'defaultValue': filters[0], 'enumValues': filters}
|
||||
self._program_filter = HonParameterEnum("program_filter", data)
|
||||
|
||||
def data(self, data):
|
||||
return data
|
||||
|
||||
def settings(self, settings):
|
||||
settings["program_filter"] = self._program_filter
|
||||
settings["startProgram.program"].filter = self._program_filter.value
|
||||
return settings
|
|
@ -1,10 +1,10 @@
|
|||
class Appliance:
|
||||
def __init__(self, data):
|
||||
self._data = data
|
||||
def data(self, data):
|
||||
if data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
|
||||
data["attributes"]["parameters"]["machMode"] = "0"
|
||||
data["active"] = bool(data.get("attributes", {}).get("activity"))
|
||||
data["pause"] = data["attributes"]["parameters"]["machMode"] == "3"
|
||||
return data
|
||||
|
||||
def get(self):
|
||||
if self._data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
|
||||
self._data["attributes"]["parameters"]["machMode"] = "0"
|
||||
self._data["active"] = bool(self._data.get("attributes", {}).get("activity"))
|
||||
self._data["pause"] = self._data["attributes"]["parameters"]["machMode"] == "3"
|
||||
return self._data
|
||||
def settings(self, settings):
|
||||
return settings
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class Appliance:
|
||||
def __init__(self, data):
|
||||
self._data = data
|
||||
def data(self, data):
|
||||
if data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
|
||||
data["attributes"]["parameters"]["machMode"] = "0"
|
||||
data["active"] = bool(data.get("attributes", {}).get("activity"))
|
||||
data["pause"] = data["attributes"]["parameters"]["machMode"] == "3"
|
||||
return data
|
||||
|
||||
def get(self):
|
||||
if self._data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
|
||||
self._data["attributes"]["parameters"]["machMode"] = "0"
|
||||
self._data["active"] = bool(self._data.get("attributes", {}).get("activity"))
|
||||
self._data["pause"] = self._data["attributes"]["parameters"]["machMode"] == "3"
|
||||
return self._data
|
||||
def settings(self, settings):
|
||||
return settings
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class Appliance:
|
||||
def __init__(self, data):
|
||||
self._data = data
|
||||
def data(self, data):
|
||||
if data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
|
||||
data["attributes"]["parameters"]["machMode"] = "0"
|
||||
data["active"] = bool(data.get("attributes", {}).get("activity"))
|
||||
data["pause"] = data["attributes"]["parameters"]["machMode"] == "3"
|
||||
return data
|
||||
|
||||
def get(self):
|
||||
if self._data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
|
||||
self._data["attributes"]["parameters"]["machMode"] = "0"
|
||||
self._data["active"] = bool(self._data.get("attributes", {}).get("activity"))
|
||||
self._data["pause"] = self._data["attributes"]["parameters"]["machMode"] == "3"
|
||||
return self._data
|
||||
def settings(self, settings):
|
||||
return settings
|
||||
|
|
|
@ -18,7 +18,7 @@ class HonDevice:
|
|||
self._attributes = {}
|
||||
|
||||
try:
|
||||
self._extra = importlib.import_module(f'pyhon.appliances.{self.appliance_type.lower()}')
|
||||
self._extra = importlib.import_module(f'pyhon.appliances.{self.appliance_type.lower()}').Appliance()
|
||||
except ModuleNotFoundError:
|
||||
self._extra = None
|
||||
|
||||
|
@ -124,6 +124,8 @@ class HonDevice:
|
|||
for name, command in self._commands.items():
|
||||
for key, setting in command.settings.items():
|
||||
result[f"{name}.{key}"] = setting
|
||||
if self._extra:
|
||||
return self._extra.settings(result)
|
||||
return result
|
||||
|
||||
@property
|
||||
|
@ -150,5 +152,5 @@ class HonDevice:
|
|||
result = {"attributes": self.attributes, "appliance": self.appliance, "statistics": self.statistics,
|
||||
**self.parameters}
|
||||
if self._extra:
|
||||
return result | self._extra.Appliance(result).get()
|
||||
return self._extra.data(result)
|
||||
return result
|
||||
|
|
|
@ -94,7 +94,7 @@ class HonParameterEnum(HonParameter):
|
|||
|
||||
@property
|
||||
def values(self):
|
||||
return sorted([str(value) for value in self._values])
|
||||
return [str(value) for value in self._values]
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
|
@ -115,6 +115,7 @@ class HonParameterProgram(HonParameterEnum):
|
|||
self._value = command._program
|
||||
self._values = command._multi
|
||||
self._typology = "enum"
|
||||
self._filter = ""
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
|
@ -126,3 +127,15 @@ class HonParameterProgram(HonParameterEnum):
|
|||
self._command.set_program(value)
|
||||
else:
|
||||
raise ValueError(f"Allowed values {self._values}")
|
||||
|
||||
@property
|
||||
def filter(self):
|
||||
return self._filter
|
||||
|
||||
@filter.setter
|
||||
def filter(self, filter):
|
||||
self._filter = filter
|
||||
|
||||
@property
|
||||
def values(self):
|
||||
return sorted([str(value) for value in self._values if not self._filter or self._filter in str(value)])
|
||||
|
|
Loading…
Reference in a new issue