Skip to content

Commit

Permalink
Get program name by prcode
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed Apr 23, 2023
1 parent d4c6ccd commit 9ee5dbc
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyhon/appliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(
try:
self._extra = importlib.import_module(
f"pyhon.appliances.{self.appliance_type.lower()}"
).Appliance()
).Appliance(self)
except ModuleNotFoundError:
self._extra = None

Expand Down
3 changes: 3 additions & 0 deletions pyhon/appliances/dw.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 3 additions & 0 deletions pyhon/appliances/ov.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 5 additions & 0 deletions pyhon/appliances/td.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@


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):
Expand Down
3 changes: 3 additions & 0 deletions pyhon/appliances/wd.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 3 additions & 0 deletions pyhon/appliances/wm.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
9 changes: 9 additions & 0 deletions pyhon/parameter/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ def value(self, value: str) -> None:
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()))

0 comments on commit 9ee5dbc

Please sign in to comment.