mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-01-19 02:50:44 +00:00
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:
|
||||
_FILTERS = {
|
||||
"default": "^(?!iot_(?:recipe|guided))\\S+$",
|
||||
"recipe": "iot_recipe_",
|
||||
"guided": "iot_guided_",
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
filters = ["receipt", "standard, special"]
|
||||
data = {'defaultValue': filters[0], 'enumValues': filters}
|
||||
filters = list(self._FILTERS.values())
|
||||
data = {"defaultValue": filters[0], "enumValues": filters}
|
||||
self._program_filter = HonParameterEnum("program_filter", data)
|
||||
|
||||
def data(self, data):
|
||||
|
@ -12,5 +18,6 @@ class Appliance:
|
|||
|
||||
def settings(self, settings):
|
||||
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
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
import re
|
||||
|
||||
|
||||
class HonParameter:
|
||||
def __init__(self, key, attributes):
|
||||
self._key = key
|
||||
|
@ -138,4 +141,8 @@ class HonParameterProgram(HonParameterEnum):
|
|||
|
||||
@property
|
||||
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 a new issue