-
Notifications
You must be signed in to change notification settings - Fork 0
/
metaobjects.py
60 lines (51 loc) · 1.29 KB
/
metaobjects.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
## Meta objects
## These objects are not valid hue data types, but kind of helpers for defining valid hue object properties
now=0
class AbstractHelper:
pass
class Action(AbstractHelper):
pass
class Condition(AbstractHelper):
def __init__(self, condition):
self.condition=condition
def __str__(self):
return self.condition
pass
class Conditions(AbstractHelper):
def __init__(self, conditions=[]):
self.conditions=dict()
for condition in conditions:
self.conditions[condition['address']]=condition
pass
class ButtonState(object):
def __init__(self, ago=0):
self.ago=ago
def __str__(self):
return("%s(%s)" % (self.__class__.__name__, self.ago))
pass
class Button:
class pressed(ButtonState):
pass
TapButton=Button
class DimmerButton(Button):
class depressed(ButtonState):
pass
class longPressed(ButtonState):
pass
class longDepressed(ButtonState):
pass
if __name__ == "__main__":
conditions=Conditions(
[
{
"address": "/sensors/2/state/buttonevent",
"operator": "eq",
"value": "1000"
},
{
"address": "/sensors/2/state/lastupdated",
"operator": "dx"
},
])
button=DimmerButton()
print(Condition(str(button.pressed(now))))