Use regex oven filters #9
This commit is contained in:
parent
36079c3c77
commit
2597cbd883
@ -2,9 +2,15 @@ from pyhon.parameter import HonParameterEnum
|
|||||||
|
|
||||||
|
|
||||||
class Appliance:
|
class Appliance:
|
||||||
|
_FILTERS = {
|
||||||
|
"default": "^(?!iot_(?:recipe|guided))\\S+$",
|
||||||
|
"recipe": "iot_recipe_",
|
||||||
|
"guided": "iot_guided_",
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
filters = ["receipt", "standard, special"]
|
filters = list(self._FILTERS.values())
|
||||||
data = {'defaultValue': filters[0], 'enumValues': filters}
|
data = {"defaultValue": filters[0], "enumValues": filters}
|
||||||
self._program_filter = HonParameterEnum("program_filter", data)
|
self._program_filter = HonParameterEnum("program_filter", data)
|
||||||
|
|
||||||
def data(self, data):
|
def data(self, data):
|
||||||
@ -12,5 +18,6 @@ class Appliance:
|
|||||||
|
|
||||||
def settings(self, settings):
|
def settings(self, settings):
|
||||||
settings["program_filter"] = self._program_filter
|
settings["program_filter"] = self._program_filter
|
||||||
settings["startProgram.program"].filter = self._program_filter.value
|
value = self._FILTERS[self._program_filter.value]
|
||||||
|
settings["startProgram.program"].filter = value
|
||||||
return settings
|
return settings
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class HonParameter:
|
class HonParameter:
|
||||||
def __init__(self, key, attributes):
|
def __init__(self, key, attributes):
|
||||||
self._key = key
|
self._key = key
|
||||||
@ -138,4 +141,8 @@ class HonParameterProgram(HonParameterEnum):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def values(self):
|
def values(self):
|
||||||
return sorted([str(value) for value in self._values if not self._filter or self._filter in str(value)])
|
values = []
|
||||||
|
for value in self._values:
|
||||||
|
if not self._filter or re.findall(self._filter, str(value)):
|
||||||
|
values.append(str(value))
|
||||||
|
return sorted(values)
|
||||||
|
Loading…
Reference in New Issue
Block a user