forked from Z-Wave-Me/home-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apib
3725 lines (3234 loc) · 80.6 KB
/
apiary.apib
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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
emFORMAT: 1A
HOST: http://r3bfish.ddns.net:8083/ZAutomation/api
# Z-Way API
+ Allowed HTTPs requests:
+ POST To create resource
+ PUT To update resource
+ GET Get a resource or list of resources
+ DELETE To delete resource
+ Allow get parameters
+ suppress_response_codes (optional, boolean) ... If this parameter is present, all responses will be returned with a 200 OK status code - even errors. This parameter exists to accommodate Flash and JavaScript applications running in browsers that intercept all non-200 responses. If used, it’s then the job of the client to determine error states by parsing the response body. Use with caution, as those error messages may change.
+ pagination (optional, boolean) ... If this parameter is present, all response of the lists (Devices, Notifications) will be included pagination
+ limit (optional, number) ... If this parameter is present, then set limit models per page, else set default 10 models per page
+ offset (options, number) ... If this parameter is present, then set start point models in page, else set default offset 0.
+ fields (options, string) ... example: nameField1,nameField2,...
+ Status codes,
+ 200: "200 OK",
+ 201: "201 Created",
+ 204: "204 No Content",
+ 304: "304 Not Modified",
+ 400: "400 Bad Request",
+ 401: "401 Unauthorized",
+ 403: "403 Forbidden",
+ 404: "404 Not Found",
+ 405: "405 Method Not Allowed",
+ 500: "500 Internal server error",
+ 501: "501 Not Implemented"
+ 503: "503 Service Unavailable"
# Group Platform Availability
<a id="available" ></a>
It will return 503 with Error message (see the details below). You can also use **/v1/status** resource to check the Platform availability.
## /v1/status
### GET
Resource for checking the Platform availability.
+ Request
+ Headers
Accept: application/json
+ Response 200
+ Headers
Content-Type: application/json
+ Body
{
error: null,
data: "OK",
code: 200
}
+ Schema
{
"type": "object",
"required": false,
"properties": {
"error": {
"type": ["string", "null"],
"required": true
},
"data": {
"type": ["string", "null"],
"required": true
},
"code": {
"type": "integer",
"required": true
},
"message": {
"type": ["string", "null"],
"required": true
}
}
}
+ Response 503
+ Headers
Content-Type: application/json
+ Body
{
error: "Internal server error. Please fill in bug report with request_id='" + this.error + "'",
data: null,
code: 503,
message: "Service Unavailable"
}
+ Schema
{
"type": "object",
"required": true,
"properties": {
"error": {
"type": ["string", "null"],
"required": true
},
"data": {
"type": ["string", "null"],
"required": true
},
"code": {
"type": "integer",
"required": true
},
"message": {
"type": ["string", "null"],
"required": true
}
}
}
# Group Platform Restart
<a id="available" ></a>
You can use **/v1/restart** to restart the controller. This will reload all notifications, ZAutomation API and reinitialize (not reload) all apps.
## /v1/restart
### GET
Platform Restart
+ Request
+ Headers
Accept: application/json
+ Response 200
+ Headers
Content-Type: application/json
+ Body
{
error: null,
data: "OK",
code: 200
}
+ Schema
{
"type": "object",
"required": true,
"properties": {
"error": {
"type": ["string", "null"],
"required": true
},
"data": {
"type": ["string", "null"],
"required": true
},
"code": {
"type": "integer",
"required": true
},
"message": {
"type": ["string", "null"],
"required": true
}
}
}
# Group Namespaces
<a id="available" ></a>
Namespaces is a collection of internal registered names and ids - e.g. for zway or virtual devices.
This API is mostly used in apps to create custom filters for virtual device selection. The data is build during z-way controller start up. Virtual device namespaces are influenced by the following listener emits:
* **created** ... added to devices collection
* **removed** ... removed from devices collection
* **change:metrics:title** ... change name of virtual dev
* **change:permanently_hide** ... deactivate virtual device - not hidden and usable
The namespace structure of virtual devices depends on their device types an probe types. Please check chapter **[Devices](anchor-devices)** for more information.
###Methods
- **/v1/namespaces** - read all namespaces.
- **/v1/namespaces/zways** - zway namespaces.
- **/v1/namespaces/devices_all** - array of all registered virtual devices that includes deviceId and deviceName.
- **/v1/namespaces/{devices_DEVICETYPE}** - read namespaces of specific **device type** and show their **probe type** children.
- **/v1/namespaces/{devices_DEVICETYPE}.{PATH}** - use path to read namespaces of child probe types from a specific device type.
- **/v1/namespaces/{devices_DEVICETYPE}.{PATH}.deviceId** - get an array of all deviceId's that lies under path endpoint.
- **/v1/namespaces/{devices_DEVICETYPE}.{PATH}.deviceName** - get an array of all deviceNames's lies under path endpoint.
## Namespaces Collection [/v1/namespaces]
### List all Namespaces [GET]
+ Response 200 (application/json)
+ Body
{
error: null,
data: [
{
id: "zways",
params: [
{
zwayName: "zway"
}
]
},
{
id: "devices_battery",
params: [
{
deviceId: "ZWayVDev_zway_7-0-128",
deviceName: "Fibar Group Battery (7.0)"
}
]
},
{
id: "devices_all",
params: [
{
deviceId: "DummyDevice_12",
deviceName: "Switch All On"
},
{
deviceId: "DummyDevice_13",
deviceName: "Tischlampe"
},
{
deviceId: "DummyDevice_18",
deviceName: "Deckenlampe"
},
{
deviceId: "ZWayVDev_zway_7-0-37",
deviceName: "Smoke Sirene Switch"
},
{
deviceId: "ZWayVDev_zway_7-0-48-2",
deviceName: "Smoke Sensor"
},
{
deviceId: "ZWayVDev_zway_7-0-48-8",
deviceName: "Smoke Tamper Sensor"
},
{
deviceId: "ZWayVDev_zway_7-0-113-1-2-A",
deviceName: "Smoke Alarm"
},
{
deviceId: "ZWayVDev_zway_7-0-113-7-3-A",
deviceName: "Smoke Burglar Alarm"
},
{
deviceId: "ZWayVDev_zway_7-0-113-9-1-A",
deviceName: "Smoke System Alarm"
},
{
deviceId: "ZWayVDev_zway_7-0-128",
deviceName: "Fibar Group Battery (7.0)"
},
{
deviceId: "Sonos_Device_Play_192.168.10.205_21",
deviceName: "Sonos Play Wohnzimmer"
},
{
deviceId: "Sonos_Device_Volume_192.168.10.205_21",
deviceName: "Sonos Volume Wohnzimmer"
}
]
},
{
id: "devices_switchBinary",
params: [
{
deviceId: "DummyDevice_12",
deviceName: "Switch All On"
},
{
deviceId: "ZWayVDev_zway_7-0-37",
deviceName: "Smoke Sirene Switch"
},
{
deviceId: "Sonos_Device_Play_192.168.10.205_21",
deviceName: "Sonos Play Wohnzimmer"
}
]
},
{
id: "devices_switchMultilevel",
params: [
{
deviceId: "DummyDevice_13",
deviceName: "Tischlampe"
},
{
deviceId: "DummyDevice_18",
deviceName: "Deckenlampe"
},
{
deviceId: "Sonos_Device_Volume_192.168.10.205_21",
deviceName: "Sonos Volume Wohnzimmer"
}
]
},
{
id: "devices_sensorBinary",
params: {
smoke: [
{
deviceId: "ZWayVDev_zway_7-0-48-2",
deviceName: "Smoke Sensor"
}
],
tamper: [
{
deviceId: "ZWayVDev_zway_7-0-48-8",
deviceName: "Smoke Tamper Sensor"
}
],
alarm: {
smoke: [
{
deviceId: "ZWayVDev_zway_7-0-113-1-2-A",
deviceName: "Smoke Alarm"
}
],
burglar: [
{
deviceId: "ZWayVDev_zway_7-0-113-7-3-A",
deviceName: "Smoke Burglar Alarm"
}
],
system: [
{
deviceId: "ZWayVDev_zway_7-0-113-9-1-A",
deviceName: "Smoke System Alarm"
}
]
}
}
}
],
code: 200,
message: "200 OK"
}
+ Schema
{
"type": "object",
"required": true,
"properties": {
"error": {
"type": ["string", "null"],
"required": true
},
"data": {
"type": "array",
"required": true
},
"code": {
"type": "integer",
"required": true
},
"message": {
"type": ["string", "null"],
"required": true
}
}
}
+ Response 404
+ Headers
Content-Type: application/json
+ Body
{
data: null,
code: 404,
message: "404 Not Found",
error: "Namespaces array is null"
}
+ Schema
{
"type": "object",
"required": true,
"properties": {
"error": {
"type": ["string"],
"required": true
},
"data": {
"type": ["string", "null"],
"required": true
},
"code": {
"type": "integer",
"required": true
},
"message": {
"type": ["string"],
"required": true
}
}
}
## Z-Way Namespaces Collection [/v1/namespaces/zways]
### List all Z-Way Namespaces [GET]
+ Response 200 (application/json)
+ Body
{
data: [
{
"zwayName": "zway"
},
{
"zwayName": "zway_remote_1"
},
{
"zwayName": "zway_remote_2"
}
],
code: 200,
message: "200 OK",
error: null
}
+ Schema
{
"type": "object",
"required": true,
"properties": {
"data": {
"type": "array",
"required": true
},
"code": {
"type": "integer",
"required": true
},
"message": {
"type": "string",
"required": true
},
"error": {
"type": ["string", "null"],
"required": true
}
}
}
## Virtual Device Namespace Model [/v1/namespaces/{devices_DEVICETYPE}.{PATH}.{deviceId,deviceName}]
### List specific namespaces [GET]
+ Parameters
+ `devices_DEVICETYPE` (optional, string, `devices_sensorBinary`) ... get namespaces of all devices `devices_all` or by device type - e.g. `devices_switchBinary`, `devices_sensorBinary`, `devices_switchControl` ...
+ PATH (optional, string, `alarm.smoke`) ... get namespaces of devices depending on their probe type - e.g. `smoke`, `alarm`, `alarm.smoke`
+ deviceId (optional, string, `deviceId`) ... get an array with device ID's of all virtual child devices.
+ deviceName (optional, string, `deviceName`) ... get an array with device names's of all virtual child devices.
+ Response 200 (application/json)
+ Body
{
data: {
smoke: [
{
deviceId: "ZWayVDev_zway_7-0-48-2",
deviceName: "Smoke Sensor"
}
],
tamper: [
{
deviceId: "ZWayVDev_zway_7-0-48-8",
deviceName: "Smoke Tamper Sensor"
}
],
alarm: {
smoke: [
{
deviceId: "ZWayVDev_zway_7-0-113-1-2-A",
deviceName: "Smoke Alarm"
}
],
burglar: [
{
deviceId: "ZWayVDev_zway_7-0-113-7-3-A",
deviceName: "Smoke Burglar Alarm"
}
],
system: [
{
deviceId: "ZWayVDev_zway_7-0-113-9-1-A",
deviceName: "Smoke System Alarm"
}
]
}
},
code: 200,
message: "200 OK",
error: null
}
+ Schema
{
"type": "object",
"required": true,
"properties": {
"error": {
"type": ["string", "null"],
"required": true
},
"data": {
"type": "object",
"properties": {
"smoke": {
"type": "array",
"required": true
},
"tamper"
"type": "array",
"required": true
},
"alarm": {
"type": "object",
"properties": {
"smoke": {
"type": "array",
"required": true
},
"burglar"
"type": "array",
"required": true
},
"system": {
"type": "integer",
"required": true
}
}
},
"code": {
"type": "integer",
"required": true
},
"message": {
"type": ["string", "null"],
"required": true
}
}
}
+ Response 404
+ Headers
Content-Type: application/json
+ Body
{
data: null,
code: 404,
message: "404 Not Found",
error: "No namespaces found with this path: foobar"
}
+ Schema
{
"type": "object",
"required": true,
"properties": {
"error": {
"type": ["string"],
"required": true
},
"data": {
"type": ["string", "null"],
"required": true
},
"code": {
"type": "integer",
"required": true
},
"message": {
"type": ["string"],
"required": true
}
}
}
# Group Modules
<a id="available" ></a>
This API prepares the whole meta data of all registered modules and their instances.
###Methods for:
#### Module Meta Data
- **/v1/modules** - read all module meta data.
- **/v1/modules/{module-id}** - get meta data of specific module
#### Module Handling
- **/v1/modules/install** - download and install module (.tar.gz/ .zip) from the given address.
- **/v1/modules/update** - download and overwrite module (.tar.gz/ .zip) from the given address. Reload JS and meta data of updated module.
- **/v1/modules/reset/{module-id}** - resets an updated module back to its preinstalled version. Module needs to be preinstalled by on current firmware.
- **/v1/modules/delete/{module-id}** - deletes a **non preinstalled** module and removes all its instances. Cannot be undone without doing backup before.
- **/v1/modules/reinitialize/{module-id}** - stops all instances of module, reloads JS and meta data and starts instances again - useful for module development.
#### Module Categories
- **/v1/modules/categories** - show all module categories
- **/v1/modules/categories/{category-id}** - list modules by category
#### Access to Online Store Groups
- **/v1/modules/tokens** - create/read/update/delete tokens for online store group access.
## Module attributes
This is a list of all module attributes hand out by the api. Some of them are predefined by module.json and the rest is added by the controller after initialisation.
| Module Attributes| Type | Comment |
|---------------|-----------------------------|----------------------------------------------------|
| `id` | _immutable_ (string, uniq) | class name as unique identifier |
| `location` | _immutable_ (string) | path to file directory: /modules or /userModules |
| `className` | _immutable_ (string) | reference to class name from index.js |
| `hasReset` | (boolean, false) | indicator if module could be reseted |
| `created` | (boolean, false) | indicator if an instance of a singleton module already exists |
| `dependencies`| (array, []) | id's of modules that are necessary to initiate this module |
| `singleton` | (boolean, false) | indicates if a module could have only one (singleton) or more running instances |
| `category` | (string) | assign module to special category |
| `author` | (string) | name of author |
| `homepage` | (string, uri) | homepage (of author) |
| `icon` | (string, uri) | custom icon field: looks in folder _/LOCATION/MODULENAME/htdocs/ICON-NAME.png_ |
| `version` | (string or number) | current version of module, format MAJOR.FEATURES.PATCHES ``0.0.0`` |
| `maturity` | (string) | shows maturity of a modules: _alpha, beta, gamma, ... or stable_ |
| `repository` | (object) | information about the repository where to find the module e.g. ``{"type": "git","source": "https://github.com/Z-Wave-Me/home-automation"}`` |
| `defaults` | (object) | defines default attributes (basic skeleton) of the module, also includes module title and description e.g. ``{"title": "AutoLock","description": "Electronic Doors typically move the dead bold of the door. [...]"``
} |
| `schema` | (object) | defines formatting schema for UI transformation with Alpaca Forms |
| `options` | (object) | defines view attributes of objects for UI transformation with Alpaca Forms |
More information about 'How to build a module?' you will find [here in this tutorial on developer.z-wave.me](http://developer.z-wave.me/?uri=help). Please check out [http://www.alpacajs.org/](http://www.alpacajs.org/) to learn more about Alpaca Forms and how you could use it to make your own modules for home automation.
## Modules Collection [/v1/modules]
### List all Modules [GET]
+ Response 200 (application/json)
+ Body
{
error: null,
data: [
{
id: 'module-id',
}
],
code: 200,
message: null
}
+ Schema
{
"type": "object",
"required": true,
"properties": {
"error": {
"type": ["string", "null"],
"required": true
},
"data": {
"type": ["array"],
"required": true
},
"code": {
"type": "integer",
"required": true
},
"message": {
"type": ["string", "null"],
"required": true
}
}
}
## Module Model [/v1/modules/{module-id}]
### List Module Meta Data [GET]
+ Parameters
+ module-id (required, string, `BatteryPolling`) ... class name of module from which meta data should be requested
+ Response 200 (application/json)
+ Body
{
error: null,
data: {
"singleton": true,
"dependencies": [
"Cron"
],
"category": "basic_gateway_modules",
"author": "Z-Wave.Me",
"homepage": "http://razberry.z-wave.me",
"icon": "icon.png",
"moduleName": "BatteryPolling",
"version": "2.0.1",
"maturity": "stable",
"repository": {
"type": "git",
"source": "https://github.com/Z-Wave-Me/home-automation"
},
"defaults": {
"title": "Battery Polling",
"description": "The battery polling will update the battery status by asking all battery-operated device once a week for a battery status update.. You can pick the day of the week and a warning level, when this module will send you a warning note.",
"launchWeekDay": 0,
"warningLevel": 20
},
"schema": {
"type": "object",
"properties": {
"launchWeekDay": {
"type": "number",
"required": true,
"enum": [
-1,
1,
2,
3,
4,
5,
6,
0
]
},
"warningLevel": {
"type": "select",
"required": true,
"enum": [
5,
10,
15,
20
]
}
},
"required": false
},
"options": {
"fields": {
"launchWeekDay": {
"label": "Do battery polling on",
"optionLabels": [
"Every Day",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
]
},
"warningLevel": {
"label": "Warning Level",
"helper": "Warn if device's battery is below this level",
"optionLabels": [
"5%",
"10%",
"15%",
"20%"
]
}
}
},
"id": "BatteryPolling",
"location": "modules/BatteryPolling",
"hasReset": false
},
code: 200,
message: null
}
+ Schema
{
"type": "object",
"required": true,
"properties": {
"error": {
"type": ["string", "null"],
"required": true
},
"data": {
"type": ["array"],
"required": true
},
"code": {
"type": "integer",
"required": true
},
"message": {
"type": ["string", "null"],
"required": true
}
}
}
+ Response 404
+ Headers
Content-Type: application/json
+ Body
{
data: null,
code: 404,
message: "404 Not Found",
error: "Instance 'module-id' not found"
}
+ Schema
{
"type": "object",
"required": true,
"properties": {
"error": {
"type": ["string"],
"required": true
},
"data": {
"type": ["string", "null"],
"required": true
},
"code": {
"type": "integer",
"required": true
},
"message": {
"type": ["string"],
"required": true
}
}
}
## Install Module [/v1/modules/install{?moduleUrl}]
### INSTALL [POST]
+ Parameters
+ moduleUrl (required, string, `http://developer.z-wave.me/modules/ScheduledScene.tar.gz`) ... target download url
+ Request (application/json)
+ Body
{
error: null,
data: {
moduleUrl: "http://developer.z-wave.me/modules/ScheduledScene.tar.gz"
},
code: 200,
message: null
}
+ Schema
{
"type": "object",
"required": true,
"properties": {
"error": {
"type": ["string", "null"],
"required": true
},
"data": {
"type": "object",
"required": true,
"properties": {
"moduleUrl": {
"type": "string",
"required": true
},
}
},
"code": {
"type": ["integer", "null"],
"required": true
},
"message": {
"type": ["string", "null"],
"required": true
}
}
}
+ Response 201 (application/json)
+ Body
{
error: null,
data: {
key: "The app was successfully installed.",
appendix: null
},
code: 201,
message: null
}
+ Schema
{
"type": "object",
"required": true,
"properties": {
"error": {
"type": ["string", "null"],
"required": true
},
"data"; {
"type": "object",
"required": true,
"properties": {
"key": {
"type": "string",
"required": true
},
"appendix"
"type": ["string", "null"],
"required": true
}
}
},
"code": {
"type": "integer",
"required": true
},
"message": {
"type": ["string", "null"],
"required": true
}
}
}
+ Response 409
+ Headers
Content-Type: application/json
+ Body
{
data: null,
code: 409,
message: "409 conflict",
error: {
key: "The app is already installed.",
errorMsg: null
}
}
+ Schema
{