-
-
Notifications
You must be signed in to change notification settings - Fork 70
/
update_metadata.py.example
165 lines (152 loc) · 5.92 KB
/
update_metadata.py.example
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
from core.metadata import set_metadata
'''
# Which Items have an `area_triggers_and_actions` namespace?
from core.metadata import get_metadata
from core.log import logging, LOG_PREFIX
LOG = logging.getLogger("{}.area_triggers_and_actions.update_metadata".format(LOG_PREFIX))
for item in ir.getAll():
metadata = get_metadata(item.name, "area_triggers_and_actions")
if metadata:
LOG.warn(u"{}: {}".format(item.name, metadata))
'''
'''
# remove all metadata with a specific namespace
from core.metadata import remove_metadata
for item in ir.getAll():
remove_metadata(item.name, "Area_Triggers_and_Actions")
'''
'''
# This is the general Item metadata structure that could be used for a specific
# Item. Every option is listed but they are seldom all used. Custom actions can
# make use of custom metadata structures, as is done in the notification_action
# example.
"Area_Triggers_and_Actions": {
"modes": {
"Morning": {"low_lux_trigger":5, "hue":100, "saturation":100, "brightness":10},
"Day": {"low_lux_trigger":55, "hue":255, "saturation":100, "brightness":10},
"Evening": {"low_lux_trigger":90, "hue":255, "saturation":100, "brightness":10},
"Night": {"low_lux_trigger":90, "hue":240, "saturation":100, "brightness":10},
"Late": {"low_lux_trigger":5, "hue":0, "saturation":100, "brightness":10},
"Party": {"low_lux_trigger":25, "hue":0, "saturation":100, "brightness":10}
},
"actions": {
"light_action": {
"lux_item_name": "DS_FamilyRoom_Lux",
"ON": {
"delay": 0,
},
"OFF": {
"delay": 60,
"recurring": False
}
},
"notification_action": {
"limited": True,
"ON": {
"delay": 3600,
"message": "The outside doors are unlocked",
"types": {
"audio": True,
"kodi": True,
"mobile": True
},
"priority": 0,
"recurring": True
},
"OFF": {
"delay": 5,
}
}
}
}
'''
'''
# Examples
# set_metadata("gOutside_Door_Trigger", "area_triggers_and_actions", {
# "notification_action": {
# "limited": True,
# "active": {
# "delay": 3600,
# "types": {
# "audio": True,
# "mobile": True
# },
# "Priority": 0,
# "recurring": True
# }
# }
# }, overwrite=True)
# set_metadata("US_GarageAttached_Dimmer", "area_triggers_and_actions", {
# "light_action": {
# "inactive": {
# "delay": 180
# }
# }
# }, overwrite=True)
# set_metadata("US_MasterBathroom_Speaker_Player", "area_triggers_and_actions", {
# "speaker_action": {
# "inactive": {
# "delay": 30
# }
# }
# }, overwrite=True)
# set_metadata("gDS_Office_Bulb", "area_triggers_and_actions", {
# "light_action": {
# "lux_item_name": "ESP12E_01_Luminance",
# "active": {
# "modes": {
# "Morning": {"lux_trigger": 0, "low_lux": {"brightness":1}},
# "Day": {"lux_trigger": 0, "low_lux": {"brightness":98}},
# "Evening": {"lux_trigger": 0, "low_lux": {"brightness":98}},
# "Night": {"lux_trigger": 0, "low_lux": {"brightness":25}},
# "Late": {"lux_trigger": 0, "low_lux": {"brightness":1}},
# "Party": {"lux_trigger": 0, "low_lux": {"brightness":98}}
# }
# }
# }
# }, overwrite=True)
# set_metadata("gOutsideLight", "area_triggers_and_actions", {
# "light_action": {
# "lux_item_name": "ESP12E_01_Luminance",
# "active": {
# "modes": {
# "Morning": {"lux_trigger": 25, "low_lux": {"brightness":98}},
# "Day": {"lux_trigger": 25, "low_lux": {"brightness":98}},
# "Evening": {"lux_trigger": 25, "low_lux": {"brightness":98}},
# "Night": {"lux_trigger": 25, "low_lux": {"brightness":98}},
# "Late": {"lux_trigger": 25, "low_lux": {"brightness":98}},
# "Party": {"lux_trigger": 25, "low_lux": {"brightness":98}}
# }
# }
# }
# }, overwrite=True)
# set_metadata("US_DiningRoom_Dimmer", "area_triggers_and_actions", {
# "light_action": {
# "lux_item_name": "ESP12E_02_Luminance",
# "active": {
# "modes": {
# "Morning": {"lux_trigger": 55, "low_lux": {"brightness":30}},
# "Day": {"lux_trigger": 200, "low_lux": {"brightness":30}},
# "Evening": {"lux_trigger": 200, "low_lux": {"brightness":30}},
# "Night": {"lux_trigger": 200, "low_lux": {"brightness":30}},
# "Late": {"lux_trigger": 55, "low_lux": {"brightness":1}},
# "Party": {"lux_trigger": 0, "low_lux": {"brightness":30}}
# }
# }
# }
# }, overwrite=True)
# set_metadata("DS_FamilyRoom_TV_LED_Color", "area_triggers_and_actions", {
# "light_action": {
# "lux_item_name": "ESP12E_01_Luminance",
# "active": {
# "modes": {
# "Morning": {"lux_trigger": 55, "low_lux": {"brightness": 10, "hue": 100, "saturation":100}},
# "Day": {"lux_trigger": 250, "low_lux": {"brightness": 0, "hue": 0, "saturation":0}},
# "Evening": {"lux_trigger": 250, "low_lux": {"brightness": 10, "hue": 255, "saturation":100}},
# "Night": {"lux_trigger": 250, "low_lux": {"brightness": 10, "hue": 240, "saturation":100}},
# "Late": {"lux_trigger": 55, "low_lux": {"brightness": 10, "hue": 0, "saturation":100}},
# "Party": {"lux_trigger": 0, "low_lux": {"brightness": 10, "hue": 0, "saturation":100}}
# }
# }
# }
# }, overwrite=True)