Get program name by prcode

This commit is contained in:
Andre Basche 2023-04-23 21:42:44 +02:00
parent d4c6ccdce3
commit 9ee5dbc956
7 changed files with 27 additions and 1 deletions

View file

@ -33,7 +33,7 @@ class HonAppliance:
try:
self._extra = importlib.import_module(
f"pyhon.appliances.{self.appliance_type.lower()}"
).Appliance()
).Appliance(self)
except ModuleNotFoundError:
self._extra = None

View file

@ -1,4 +1,7 @@
class Appliance:
def __init__(self, appliance):
self.parent = appliance
def data(self, data):
if data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
data["attributes"]["parameters"]["machMode"] = "0"

View file

@ -1,4 +1,7 @@
class Appliance:
def __init__(self, appliance):
self.parent = appliance
def data(self, data):
if data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
data["attributes"]["parameters"]["temp"] = "0"

View file

@ -2,11 +2,16 @@ from pyhon.parameter.fixed import HonParameterFixed
class Appliance:
def __init__(self, appliance):
self.parent = appliance
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"
program = int(data["attributes"]["parameters"]["prCode"])
data["programName"] = self.parent.settings["startProgram.program"].ids[program]
return data
def settings(self, settings):

View file

@ -1,4 +1,7 @@
class Appliance:
def __init__(self, appliance):
self.parent = appliance
def data(self, data):
if data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
data["attributes"]["parameters"]["machMode"] = "0"

View file

@ -1,4 +1,7 @@
class Appliance:
def __init__(self, appliance):
self.parent = appliance
def data(self, data):
if data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
data["attributes"]["parameters"]["machMode"] = "0"

View file

@ -31,3 +31,12 @@ class HonParameterProgram(HonParameterEnum):
def values(self) -> List[str]:
values = [v for v in self._programs if all(f not in v for f in self._FILTER)]
return sorted(values)
@property
def ids(self):
values = {
int(p.parameters["prCode"].value): n
for i, (n, p) in enumerate(self._programs.items())
if "iot_" not in n and p.parameters.get("prCode")
}
return dict(sorted(values.items()))