/
sample.txt
270 lines (242 loc) · 15.2 KB
/
sample.txt
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
================
Json sample file
================
Here is a sample of the json file. There are some comments in the sample. Please refer also to the dedicated documentation pages for all the json parts for more information.
Sample
======
Part of the json sample
-----------------------
::
# Here part of json declaration
"device_types": { # device type declaration who appears in user interface list to create device
"fooplugin.device_name": {
"id": "fooplugin.device_name", # device id for internal reference (no Xpl)
"description": "A short description",
"name": "The device type name",
"commands": ["cmd_one", "cmd_two"], # link to list of commands
"sensors": ["sensor_one", "sensor_two"], # link to list of sensors
"params": [ # parameters that are common to ALL xpl messages for this device type
{
"key": "key1_devicetype", # key copied to the xpl messages, this a static key like device address
"description": "A short description",
"type": "string" # key appears in the xpl as : {key1_devicetype : this a string type}
"xpl": True # if the params is in the xpl messages : True. For example, an interval will not be in a xpl message
"default": "A default value" # optionally a default value for this parameter
},
{
"key": "key2_devicetype",
"description": "A short description",
"type": "integer",
"max_value": 255, # depending on the type the are other possibilities
"min_value": 0,
"xpl": True # if the params is in the xpl messages : True. For example, an interval will not be in a xpl message
"default": "A default value" # optionally a default value for this parameter
}
]
}
},
"commands": { # commands who are call by device_types, A command can be call by many device_types
"cmd_one": {
"name": "The cmd name",
"return_confirmation": true, # at true a confirmation xpl message should be send at command return. It is strongly recommended to use confirmation
"parameters": [ # parameters that are common to ALL xpl messages for this command
{
"key": "key1_cmd_one", # key copied to the xpl messages, this a dynamic key that can be set in each Xpl message (dynamic)
# key appears in the xpl as : {key1_cmd_two : dynamic value}
"data_type": "DT_Switch", # link to Domogik Type of Data used by widgets in UI.
"conversion": "from_DT_Switch_to_level" # if needed define proper conversion function in file <plugindirectory>/conversion/<fooplugin>.py
# conversion have utility when hard device receive a particular scale or data type who are not directly compatible with Domogik Types
}
],
"xpl_command": "xpl_cmd_one" # link to xpl_command format to use
},
"cmd_two": {
"name": "The cmd name",
"return_confirmation": false,
"parameters": [
{
"key": "key1_cmd_two",
"data_type": "DT_Scale",
"conversion": "from_DT_Scale_to_level"
}
],
"xpl_command": "xpl_cmd_two"
}
},
sensors": { # sensors who are used by device_types, A sensors can be use by many device_types
"sensor_one": {
"name": "The sensor name",
"data_type": "DT_Switch",
"conversion": "from_level_to_DT_Switch", # if needed define proper conversion fuction in file <plugindirectory>/conversion/<fooplugin>.py
# conversion have utility when hard device send a particular scale or data type who are not directly compatible with Domogik Types
"incremental" : false, # does the sensor is about incremental values
"timeout" : 120, # value in seconds to indicate when a value is too old and so the device may be offline/broken/...
"history": { # how is managed the sensor history.
"store": true,
"duplicate": false,
"max": 0,
"expire": 0,
"round_value": 0
}
},
"sensor_two": {
"name": "The sensor name",
"data_type": "DT_Scaling",
"conversion": "from_level_to_DT_Scaling",
"incremental" : false,
"timeout" : 0,
"history": {
"store": true,
"duplicate": false,
"max": 0,
"expire": 0,
"round_value": 0
}
},
"xpl_commands": { # declaration for linking commands to xpl schema and keys
"xpl_cmd_one": {
"name": "The xplCmd name",
"schema": "fooplugin.basic", # schema that must respect the xpl-protocol
"xplstat_name": "xplstat_name_one",
"parameters": { # parameters that are common to ALL xpl messages for this xpl_command
"static": [ # key copied to the xPL message. Static keys will always be the same, whatever the device is
{
"key": "static_key1_xpl_cmd_one", # key appears in the xpl as : {static_key1_xpl_cmd_one : static value}
"value" : "value_static_key1_xpl_cmd_one"
},
{
"key": "static_key2_xpl_cmd_one",
"value" : "value_static_key2_xpl_cmd_one"
}
],
"device": # key copied to the xPL message. Satic value defined on a per device basis (input is requested) in the user interface.
# The device key is used for parameters that depend on a device, that require an input by the user,
# but that do not change once the device is created, once the device is cerated these parameters
# are static, but the value is requested during the device creation process.
# an example of a device parameter is the datatype in knx, this can be different for xplstat and xplcommand,
# but it will stay the same once the device is created
{
"key": "device_key1_xpl_cmd_one", # key appears in the xpl as : {device_key1_xpl_cmd_one}
"description": "A description", # A description that will be displayed in the admin interface
"type": "string" # The type of the field (used for the userinterface)
"default": "A default value" # optionally a default value for this parameter
},
{
"key": "device_key2_xpl_cmd_one", # key appears in the xpl as : {device_key1_xpl_cmd_one}
"description": "A description", # A description that will be displayed in the admin interface
"type": "string" # The type of the field (used for the userinterface)
"default": "A default value" # optionally a default value for this parameter
}
]
}
},
"xpl_cmd_two": {
"name": "The xplCmd name",
"schema": "fooplugin.basic",
"xplstat_name": "",
"parameters": {
"static": [
{
"key": "static_key1_xpl_cmd_two",
"value" : "value_static_key1_xpl_cmd_two"
}
],
"device": [
{
"key": "device_key1_xpl_cmd_two", # key appears in the xpl as : {device_key1_xpl_cmd_one : static value}
"description": "A description", # A description that will be displayed in the admin interface
"type": "string" # The type of the field (used for the userinterface)
"default": "A default value" # optionally a default value for this parameter
}
]
}
}
},
"xpl_stats": { # declaration for linking stats to xpl schema and keys.
"xplstat_name_one": {
"name": "The xplstat name",
"schema": "sensor.basic", # schema that must respect the xpl-protocol
"parameters": { # parameters that are common to ALL xpl messages for this xpl_stats
"static": [ # key copied to the xPL message. Static keys will always be the same, whatever the device is
{
"key": "static_key1_xplstat_one", # key appears in the xpl as : {static_key1_xplstat_one : static value}
"value" : "value_static_key1_xplstat_one"
}],
"device": [
{
"key": "device_key1_xpl_cmd_two", # key appears in the xpl as : {device_key1_xpl_cmd_one}
"description": "A description", # A description that will be displayed in the admin interface
"type": "string" # The type of the field (used for the userinterface)
"default": "A default value" # optionally a default value for this parameter
}
],
"dynamic": [ # key copied to the xPL message. keys which are values for the sensors. They are stored in the sensor history table.
{
"key": "dynamic_key1_xpl_xplstat_one", # key appears in the xpl as : {dynamic_key1_xpl_xplstat_one : dynamic value}
"ignore_values": "",
"sensor": "sensor_one" # link to sensor type to set Domogik Data Type and optimal conversion
},
{
"key": "dynamic_key2_xpl_xplstat_one",
"ignore_values": "",
"sensor": "sensor_two"
}
]
}
}
}
An xpl command for cmd_one with confirmation
--------------------------------------------
Command: ::
xpl-cmnd
{
hop1 = 1
source = xpl-rest.domogik
target = *
}
fooplugin.basic
{
key1_devicetype_one = static-value_string # ex : {"deviceaddr" : "x0103"}
key2_devicetype_one = static-value-integer # ex : {"channel" : "a1"}
key1_cmd_one = dynamic-value-DT_Switch # ex : {"command" : "on"}
static_key1_xpl_cmd_one = value_static_key1_xpl_cmd_one # ex : {"zone" : "bedroom"}
static_key2_xpl_cmd_one = value_static_key2_xpl_cmd_one # ex : {"timer" : 15}
device_key1_xpl_cmd_one = value_device_key1_xpl_cmd_one # ex : {"bauds" : 40000}
device_key2_xpl_cmd_one = value_device_key2_xpl_cmd_one # ex : {"sleep" : 2}
}
The confirmation message: ::
xpl-trig
{
hop = 1
source = domogik-fooplugin.foomachine
target = *
}
sensor.basic
{
key1_devicetype = static-value_string # ex : {"deviceaddr" : "x0103"}
key2_devicetype = static-value-integer # ex : {"channel" : "a1"}
static_key1_xplstat_one = value_static_key1_xplstat_one # ex : {"zone" : "bedroom"}}
device_key1_xpl_xplstat_one = value_device_key1_xpl_xplstat_one # ex : {"bauds": 40000
dynamic_key1_xpl_xplstat_one = dynamic-value-sensor-one-DT_Switch # ex : {"state" : "on"}
dynamic_key2_xpl_xplstat_one = dynamic-value-sensor-two-DT_Scaling # ex : {"battery" : 80}
}
An xpl command for cmd_two without confirmation
-----------------------------------------------
.. note::
This case should not happen! xPL protocol tell us that a trigger (xpl-trig) message should be sent after each successfully processed command (xpl-cmnd) received!
Command: ::
xpl-cmnd
{
hop1 = 1
source = xpl-rest.domogik
target = *
}
fooplugin.basic
{
key1_devicetype_one = static-value_string
key2_devicetype_one = static-value-integer
key1_cmd_two = dynamic-value-DT_Scale
static_key1_xpl_cmd_two = value_static_key1_xpl_cmd_two
device_key1_xpl_cmd_two = value_device_key1_xpl_cmd_two
}
There is no confirmation message