implement form result parsing for q65 matrix

This commit is contained in:
Jakob Ketterl 2021-02-08 16:32:00 +01:00
parent 346f2af2fb
commit b0c7abe362

View File

@ -360,6 +360,20 @@ class Q65ModeMatrix(Input):
def input_classes(self): def input_classes(self):
return " ".join(["form-check", "form-control-sm"]) return " ".join(["form-check", "form-control-sm"])
def parse(self, data):
def in_response(mode, interval):
boxid = self.checkbox_id(mode, interval)
return boxid in data and data[boxid][0] == "on"
return {
self.id: [
"{}{}".format(mode.name, interval.value)
for interval in Q65Interval
for mode in Q65Mode
if in_response(mode, interval)
],
}
class DropdownEnum(Enum): class DropdownEnum(Enum):
def toOption(self): def toOption(self):