forked from pimatic/pimatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-schema.coffee
456 lines (451 loc) · 14.3 KB
/
config-schema.coffee
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# #Configuration options
# Lists all configuration options for the pimatic framework itself.
# For an example `config.json` file see the `config_default.json` file.
module.exports = {
title: "pimatic config"
type: "object"
properties:
settings:
type: "object"
properties:
locale:
description: "The default language"
type: "string"
enum: ['en', 'de', "es", "nl"]
default: "en"
debug:
description: "Turn on debug checks. Set the logLevel to debug to additional outputs"
type: "boolean"
default: false
authentication:
type: "object"
properties:
enabled:
description: "Disable http-basic-authentication"
type: "boolean"
default: true
secret:
description: """Secret string used for cookie signing. Should be kept secret. If it
is not set, then a secret will be generate for you, at first start. The secret must
be at least 32 characters long.
"""
secret: yes
loginTime:
description: """The time in milliseconds to keep the session cookie if rememberMe is
checked. If 0 then delete the cookie on browser close. """
type: "integer"
default: 10 * 365 * 24 * 60 * 60 * 1000 #ten years
logLevel:
description: "The log level: debug, info, warn, error"
type: "string"
default: "info"
httpServer:
type: "object"
properties:
enabled:
description: "Should the http-server be started"
type: "boolean"
default: true
port:
description: "The port of the http-server"
type: "integer"
format: "port"
default: 80
minimum: 0
hostname:
description: "The hostname of the http-server"
type: "string"
default: "" # If is empty then listen to all ip4Adresses
httpsServer:
type: "object"
properties:
enabled:
description: "Should the https-server be started"
type: "boolean"
default: false
port:
description: "The port of the https-server"
type: "integer"
format: "port"
default: 443
minimum: 0
hostname:
description: "The hostname of the https-server"
type: "string"
default: "" # If is empty then listen to all ip4Adresses
###
Download https://raw.githubusercontent.com/pimatic/pimatic/master/install/ssl-setup
and run ssl-setup in you pimatic-app dir to generate the necessary key and certificate
files:
wget https://raw.githubusercontent.com/pimatic/pimatic/master/install/ssl-setup
chmod +x ssl-setup
./ssl-setup
###
keyFile:
description: "Privatekey file"
type: "string"
default: "ca/pimatic-ssl/private/privkey.pem"
certFile:
description: "Public certification file in pem-format"
type: "string"
default: "ca/pimatic-ssl/public/cert.pem"
rootCertFile:
description: """The public root certificate file of your own CA if you using a self
signed certificate. This option is optional. Its just for the frontent, so that it
can provide a link to the the root certificate for easy importing in mobile devices.
"""
type: "string"
default: "ca/certs/cacert.crt"
database:
type: "object"
properties:
client:
description: "the databse client to use"
type: "string"
enum: ["sqlite3", "mysql", "pg"]
default: "sqlite3"
###
The connection setting is database client dependent. Some examples:
__sqlite3:__
{
filename: "pimatic-database.sqlite"
}
__mysql:__
{
host : '127.0.0.1',
user : 'your_database_user',
password : 'your_database_password',
database : 'myapp_test'
}
###
connection:
description: "the connection settings for the database client"
type: "object"
default: {
filename: "pimatic-database.sqlite"
}
deviceAttributeLogging:
description: "time to keep logged device attributes values in database"
type: "array"
default: [
{
deviceId: '*', attributeName: '*', type: "*",
interval: "0", expire: '7d'
}
{
deviceId: '*', attributeName: '*', type: "continuous",
interval: "5min", expire: '7d'
}
{
deviceId: '*', attributeName: 'temperature', type: "number",
expire: '1y'
}
{
deviceId: '*', attributeName: 'humidity', type: "number",
expire: '1y'
}
]
messageLogging:
description: "time to keep logged messages in database"
type: "array"
default: [
{ level: '*', tags: [], expire: '7d' }
{ level: 'debug', tags: [], expire: '0' }
]
deleteExpiredInterval:
description: "interval for deleting expired entries from the database"
type: "string"
default: "2h"
diskSyncInterval:
description: "
interval for writing logged entries to disk. If this value is smaller then
the deleteExpiredInterval setting then the value of it is used
instead. Should be a multiple of deleteExpiredInterval.
"
type: "string"
default: "4h"
debug:
description: "Enable to show database queries and some additional outputs"
type: "boolean"
default: false
gui:
type: "object"
properties:
hideRuleName:
description: "Dont show the name of rules on the rules page"
type: "boolean"
default: false
hideRuleText:
description: "Dont show the text of rules on the rules page"
type: "boolean"
default: false
demo:
doc: """show edit pages also if the user has no permissions,
like at demo.pimatic.org:8080
"""
type: "boolean"
default: false
pages:
description: "Array of gui pages"
type: "array"
default: []
items:
type: "object"
properties:
id:
type: "string"
name:
type: "string"
devices:
type: "array"
default: []
items:
type: "object"
properties:
deviceId:
type: "string"
groups:
description: "Array of groups"
type: "array"
default: []
items:
type: "object"
properties:
id:
type: "string"
name:
type: "string"
devices:
type: "array"
default: []
items:
type: "string"
rules:
type: "array"
default: []
items:
type: "string"
variables:
type: "array"
default: []
items:
type: "string"
plugins:
description: "Array of plugins to load"
type: "array"
default: []
devices:
description: "Array of device definations"
type: "array"
default: []
items:
type: "object"
properties:
id:
type: "string"
name:
type: "string"
class:
type: "string"
rules:
description: "Array of rules"
type: "array"
default: []
items:
type: "object"
properties:
id:
type: "string"
name:
type: "string"
rule:
type: "string"
active:
type: "boolean"
logging:
type: "boolean"
variables:
description: "Array of variables"
type: "array"
default: []
items:
anyOf: [
{
type: "object"
properties:
name:
type: "string"
value:
type: "string"
unit:
type: "string"
},
{
type: "object"
properties:
name:
type: "string"
expression:
type: "string"
unit:
type: "string"
}
]
users:
description: "Array of users"
type: "array"
default: [
{
username: "admin"
password: ""
role: "admin"
}
]
items:
type: "object"
properties:
username:
description: "The loginname of the user"
type: "string"
password:
description: "The password of the user"
type: "string"
secret: yes
role:
description: "The role of the user"
type: "string"
roles:
description: "Array of user roles"
type: "array"
default: [
{
name: "admin"
permissions:
pages: "write"
rules: "write"
variables: "write"
messages: "write"
events: "write"
devices: "write"
groups: "write"
plugins: "write"
updates: "write"
config: "write"
controlDevices: true
restart: true
},
{
name: "resident"
permissions:
pages: "read"
rules: "read"
variables: "read"
messages: "read"
events: "read"
devices: "none"
groups: "none"
plugins: "none"
updates: "none"
config: "none"
controlDevices: true
restart: false
}
]
items:
type: "object"
properties:
name:
type: "string"
permissions:
type: "object"
properties:
pages:
description: """Allow to list all pages with its devices (read) or additional
edit the pages (write)
"""
type: "string"
default: "none"
enum: ["none", "read", "write"]
rules:
description: """
Allow to list all rules (read) or additional edit the rules (write)
"""
type: "string"
default: "none"
enum: ["none", "read", "write"]
variables:
description: """
Allow to list all variables (read) or additional edit the variables (write)
"""
type: "string"
default: "none"
enum: ["none", "read", "write"]
messages:
description: """
Allow to list all messages (read) or additional edit the messages (write)
"""
type: "string"
default: "none"
enum: ["none", "read", "write"]
events:
description: """
Allow to list all events (read) or additional edit the events (write)
"""
type: "string"
default: "none"
enum: ["none", "read", "write"]
devices:
description: """
Allow to list all devices (read) or additional edit the devices (write)
"""
type: "string"
default: "none"
enum: ["none", "read", "write"]
groups:
description: """
Allow to list all groups (read) or additional edit the groups (write)
"""
type: "string"
default: "none"
enum: ["none", "read", "write"]
users:
description: """
Allow to list all users (read) or additional edit the users (write)
"""
type: "string"
default: "none"
enum: ["none", "read", "write"]
plugins:
description: """
Allow to list all plugins (read) or additional edit the plugins (write)
"""
type: "string"
default: "none"
enum: ["none", "read", "write"]
updates:
description: """
Allow to show update or additional do updating
"""
type: "string"
default: "none"
enum: ["none", "read", "write"]
config:
description: """
Allow show the config (read) or additional edit the config (write)
"""
type: "string"
default: "none"
enum: ["none", "read", "write"]
controlDevices:
description: """
Allow to control devices (switches, buttons, ...)
"""
type: "boolean"
default: false
restart:
description: """
Allow to restart pimatic
"""
type: "boolean"
default: false
}