@kohost/api-client 3.0.0-beta.27 → 3.0.0-beta.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/AMQPClient.js +11 -12
- package/dist/cjs/Client.js +3 -5
- package/dist/cjs/Models.js +459 -44
- package/dist/cjs/SocketIoClient.js +2 -4
- package/dist/cjs/defs.js +3 -5
- package/dist/cjs/utils.js +5 -0
- package/dist/esm/Models.js +432 -1
- package/dist/esm/Models.js.map +4 -4
- package/dist/esm/utils.js +5 -0
- package/dist/esm/utils.js.map +2 -2
- package/package.json +1 -1
package/dist/cjs/Models.js
CHANGED
|
@@ -187,6 +187,11 @@ var require_device = __commonJS({
|
|
|
187
187
|
type: "number",
|
|
188
188
|
minimum: 0,
|
|
189
189
|
maximum: 100
|
|
190
|
+
},
|
|
191
|
+
watts: {
|
|
192
|
+
type: "number",
|
|
193
|
+
minimum: 0,
|
|
194
|
+
default: 0
|
|
190
195
|
}
|
|
191
196
|
}
|
|
192
197
|
};
|
|
@@ -259,6 +264,9 @@ var require_switch = __commonJS({
|
|
|
259
264
|
},
|
|
260
265
|
systemData: {
|
|
261
266
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
267
|
+
},
|
|
268
|
+
watts: {
|
|
269
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
262
270
|
}
|
|
263
271
|
},
|
|
264
272
|
additionalProperties: false,
|
|
@@ -454,7 +462,7 @@ var require_kohost = __commonJS({
|
|
|
454
462
|
if (!this.validator) {
|
|
455
463
|
throw new Error("Validator is not defined");
|
|
456
464
|
}
|
|
457
|
-
const isNew =
|
|
465
|
+
const isNew = data?.id ? false : true;
|
|
458
466
|
this._setId(data);
|
|
459
467
|
this._validate(data);
|
|
460
468
|
this._setProperties(data);
|
|
@@ -501,10 +509,9 @@ var require_kohost = __commonJS({
|
|
|
501
509
|
return id;
|
|
502
510
|
}
|
|
503
511
|
static getActionDelta(old, _new) {
|
|
504
|
-
var _a;
|
|
505
512
|
const delta = {};
|
|
506
513
|
for (const action in _new) {
|
|
507
|
-
if (
|
|
514
|
+
if (this.actionProperties?.includes(action)) {
|
|
508
515
|
if (old[action] !== _new[action]) {
|
|
509
516
|
delta[action] = 1;
|
|
510
517
|
}
|
|
@@ -648,6 +655,9 @@ var require_alarm = __commonJS({
|
|
|
648
655
|
items: {
|
|
649
656
|
$ref: "#/properties/supportedTroubles/items"
|
|
650
657
|
}
|
|
658
|
+
},
|
|
659
|
+
watts: {
|
|
660
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
651
661
|
}
|
|
652
662
|
},
|
|
653
663
|
additionalProperties: false,
|
|
@@ -732,6 +742,9 @@ var require_dimmer = __commonJS({
|
|
|
732
742
|
},
|
|
733
743
|
systemData: {
|
|
734
744
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
745
|
+
},
|
|
746
|
+
watts: {
|
|
747
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
735
748
|
}
|
|
736
749
|
},
|
|
737
750
|
additionalProperties: false,
|
|
@@ -753,10 +766,9 @@ var require_dimmer2 = __commonJS({
|
|
|
753
766
|
super(data);
|
|
754
767
|
}
|
|
755
768
|
static getActionDelta(old, _new) {
|
|
756
|
-
var _a;
|
|
757
769
|
const delta = {};
|
|
758
770
|
for (const action in _new) {
|
|
759
|
-
if (
|
|
771
|
+
if (this.actionProperties?.includes(action)) {
|
|
760
772
|
if (action === "level") {
|
|
761
773
|
const oldLevel = old[action];
|
|
762
774
|
const newLevel = _new[action];
|
|
@@ -825,6 +837,9 @@ var require_lock = __commonJS({
|
|
|
825
837
|
},
|
|
826
838
|
systemData: {
|
|
827
839
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
840
|
+
},
|
|
841
|
+
watts: {
|
|
842
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
828
843
|
}
|
|
829
844
|
},
|
|
830
845
|
additionalProperties: false,
|
|
@@ -972,6 +987,9 @@ var require_thermostat = __commonJS({
|
|
|
972
987
|
systemData: {
|
|
973
988
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData",
|
|
974
989
|
default: {}
|
|
990
|
+
},
|
|
991
|
+
watts: {
|
|
992
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
975
993
|
}
|
|
976
994
|
},
|
|
977
995
|
additionalProperties: false,
|
|
@@ -1131,6 +1149,9 @@ var require_windowCovering = __commonJS({
|
|
|
1131
1149
|
},
|
|
1132
1150
|
systemData: {
|
|
1133
1151
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
1152
|
+
},
|
|
1153
|
+
watts: {
|
|
1154
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
1134
1155
|
}
|
|
1135
1156
|
},
|
|
1136
1157
|
additionalProperties: false,
|
|
@@ -1152,10 +1173,9 @@ var require_windowCovering2 = __commonJS({
|
|
|
1152
1173
|
super(data);
|
|
1153
1174
|
}
|
|
1154
1175
|
static getActionDelta(old, _new) {
|
|
1155
|
-
var _a;
|
|
1156
1176
|
const delta = {};
|
|
1157
1177
|
for (const action in _new) {
|
|
1158
|
-
if (
|
|
1178
|
+
if (this.actionProperties?.includes(action)) {
|
|
1159
1179
|
if (action === "position") {
|
|
1160
1180
|
const oldPos = old[action];
|
|
1161
1181
|
const newPos = _new[action];
|
|
@@ -1713,6 +1733,9 @@ var require_courtesy = __commonJS({
|
|
|
1713
1733
|
},
|
|
1714
1734
|
systemData: {
|
|
1715
1735
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
1736
|
+
},
|
|
1737
|
+
watts: {
|
|
1738
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
1716
1739
|
}
|
|
1717
1740
|
},
|
|
1718
1741
|
additionalProperties: false,
|
|
@@ -1798,6 +1821,9 @@ var require_camera = __commonJS({
|
|
|
1798
1821
|
},
|
|
1799
1822
|
systemData: {
|
|
1800
1823
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
1824
|
+
},
|
|
1825
|
+
watts: {
|
|
1826
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
1801
1827
|
}
|
|
1802
1828
|
},
|
|
1803
1829
|
additionalProperties: false,
|
|
@@ -1862,6 +1888,9 @@ var require_motionSensor = __commonJS({
|
|
|
1862
1888
|
},
|
|
1863
1889
|
notification: {
|
|
1864
1890
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
|
|
1891
|
+
},
|
|
1892
|
+
watts: {
|
|
1893
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
1865
1894
|
}
|
|
1866
1895
|
},
|
|
1867
1896
|
additionalProperties: false,
|
|
@@ -2076,6 +2105,9 @@ var require_mediaSource = __commonJS({
|
|
|
2076
2105
|
},
|
|
2077
2106
|
systemData: {
|
|
2078
2107
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
2108
|
+
},
|
|
2109
|
+
watts: {
|
|
2110
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
2079
2111
|
}
|
|
2080
2112
|
},
|
|
2081
2113
|
additionalProperties: false
|
|
@@ -2476,50 +2508,40 @@ var require_room2 = __commonJS({
|
|
|
2476
2508
|
}
|
|
2477
2509
|
}
|
|
2478
2510
|
get hasDimmer() {
|
|
2479
|
-
|
|
2480
|
-
return ((_a = this.dimmers) == null ? void 0 : _a.length) > 0;
|
|
2511
|
+
return this.dimmers?.length > 0;
|
|
2481
2512
|
}
|
|
2482
2513
|
get hasSwitch() {
|
|
2483
|
-
|
|
2484
|
-
return ((_a = this.switches) == null ? void 0 : _a.length) > 0;
|
|
2514
|
+
return this.switches?.length > 0;
|
|
2485
2515
|
}
|
|
2486
2516
|
get hasWindowCovering() {
|
|
2487
|
-
|
|
2488
|
-
return ((_a = this.windowCoverings) == null ? void 0 : _a.length) > 0;
|
|
2517
|
+
return this.windowCoverings?.length > 0;
|
|
2489
2518
|
}
|
|
2490
2519
|
get hasShade() {
|
|
2491
2520
|
return this.hasWindowCovering;
|
|
2492
2521
|
}
|
|
2493
2522
|
get hasThermostat() {
|
|
2494
|
-
|
|
2495
|
-
return ((_a = this.thermostats) == null ? void 0 : _a.length) > 0;
|
|
2523
|
+
return this.thermostats?.length > 0;
|
|
2496
2524
|
}
|
|
2497
2525
|
get hasClimate() {
|
|
2498
2526
|
return this.hasThermostat;
|
|
2499
2527
|
}
|
|
2500
2528
|
get hasLock() {
|
|
2501
|
-
|
|
2502
|
-
return ((_a = this.locks) == null ? void 0 : _a.length) > 0;
|
|
2529
|
+
return this.locks?.length > 0;
|
|
2503
2530
|
}
|
|
2504
2531
|
get hasCourtesy() {
|
|
2505
|
-
|
|
2506
|
-
return ((_a = this.courtesy) == null ? void 0 : _a.length) > 0;
|
|
2532
|
+
return this.courtesy?.length > 0;
|
|
2507
2533
|
}
|
|
2508
2534
|
get hasCamera() {
|
|
2509
|
-
|
|
2510
|
-
return ((_a = this.cameras) == null ? void 0 : _a.length) > 0;
|
|
2535
|
+
return this.cameras?.length > 0;
|
|
2511
2536
|
}
|
|
2512
2537
|
get hasAlarm() {
|
|
2513
|
-
|
|
2514
|
-
return ((_a = this.alarms) == null ? void 0 : _a.length) > 0;
|
|
2538
|
+
return this.alarms?.length > 0;
|
|
2515
2539
|
}
|
|
2516
2540
|
get hasMedia() {
|
|
2517
|
-
|
|
2518
|
-
return ((_a = this.mediaSources) == null ? void 0 : _a.length) > 0;
|
|
2541
|
+
return this.mediaSources?.length > 0;
|
|
2519
2542
|
}
|
|
2520
2543
|
get hasLight() {
|
|
2521
|
-
|
|
2522
|
-
const hasSubTypeLight = (_a = this.switches) == null ? void 0 : _a.some((sw) => {
|
|
2544
|
+
const hasSubTypeLight = this.switches?.some((sw) => {
|
|
2523
2545
|
return sw.subType === "light" || sw.subType === "fan";
|
|
2524
2546
|
});
|
|
2525
2547
|
return this.hasDimmer || hasSubTypeLight;
|
|
@@ -2544,69 +2566,68 @@ var require_room2 = __commonJS({
|
|
|
2544
2566
|
value: Object.keys(schema.properties)
|
|
2545
2567
|
});
|
|
2546
2568
|
function mapRoomData(data) {
|
|
2547
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2548
2569
|
const roomData = cloneDeep(data);
|
|
2549
|
-
|
|
2570
|
+
roomData.dimmers?.map((dimmer) => {
|
|
2550
2571
|
if (dimmer instanceof Dimmer2)
|
|
2551
2572
|
return dimmer;
|
|
2552
2573
|
else
|
|
2553
2574
|
return new Dimmer2(dimmer);
|
|
2554
2575
|
});
|
|
2555
|
-
|
|
2576
|
+
roomData.switches?.map((switch_) => {
|
|
2556
2577
|
if (switch_ instanceof Switch2)
|
|
2557
2578
|
return switch_;
|
|
2558
2579
|
else
|
|
2559
2580
|
return new Switch2(switch_);
|
|
2560
2581
|
});
|
|
2561
|
-
|
|
2582
|
+
roomData.windowCoverings?.map((windowCovering) => {
|
|
2562
2583
|
if (windowCovering instanceof WindowCovering2)
|
|
2563
2584
|
return windowCovering;
|
|
2564
2585
|
else
|
|
2565
2586
|
return new WindowCovering2(windowCovering);
|
|
2566
2587
|
});
|
|
2567
|
-
|
|
2588
|
+
roomData.thermostats?.map((thermostat) => {
|
|
2568
2589
|
if (thermostat instanceof Thermostat2)
|
|
2569
2590
|
return thermostat;
|
|
2570
2591
|
else
|
|
2571
2592
|
return new Thermostat2(thermostat);
|
|
2572
2593
|
});
|
|
2573
|
-
|
|
2594
|
+
roomData.locks?.map((lock) => {
|
|
2574
2595
|
if (lock instanceof Lock2)
|
|
2575
2596
|
return lock;
|
|
2576
2597
|
else
|
|
2577
2598
|
return new Lock2(lock);
|
|
2578
2599
|
});
|
|
2579
|
-
|
|
2600
|
+
roomData.courtesy?.map((courtesy) => {
|
|
2580
2601
|
if (courtesy instanceof Courtesy2)
|
|
2581
2602
|
return courtesy;
|
|
2582
2603
|
else
|
|
2583
2604
|
return new Courtesy2(courtesy);
|
|
2584
2605
|
});
|
|
2585
|
-
|
|
2606
|
+
roomData.sources?.map((source) => {
|
|
2586
2607
|
if (source instanceof Source)
|
|
2587
2608
|
return source;
|
|
2588
2609
|
else
|
|
2589
2610
|
return new Source(source);
|
|
2590
2611
|
});
|
|
2591
|
-
|
|
2612
|
+
roomData.cameras?.map((camera) => {
|
|
2592
2613
|
if (camera instanceof Camera2)
|
|
2593
2614
|
return camera;
|
|
2594
2615
|
else
|
|
2595
2616
|
return new Camera2(camera);
|
|
2596
2617
|
});
|
|
2597
|
-
|
|
2618
|
+
roomData.alarms?.map((alarm) => {
|
|
2598
2619
|
if (alarm instanceof Alarm2)
|
|
2599
2620
|
return alarm;
|
|
2600
2621
|
else
|
|
2601
2622
|
return new Alarm2(alarm);
|
|
2602
2623
|
});
|
|
2603
|
-
|
|
2624
|
+
roomData.motionSensors?.map((motionSensor) => {
|
|
2604
2625
|
if (motionSensor instanceof MotionSensor2)
|
|
2605
2626
|
return motionSensor;
|
|
2606
2627
|
else
|
|
2607
2628
|
return new MotionSensor2(motionSensor);
|
|
2608
2629
|
});
|
|
2609
|
-
|
|
2630
|
+
roomData.scenes?.map((scene) => {
|
|
2610
2631
|
if (scene instanceof Scene2)
|
|
2611
2632
|
return scene;
|
|
2612
2633
|
else
|
|
@@ -2758,8 +2779,7 @@ var require_reservation2 = __commonJS({
|
|
|
2758
2779
|
return this.adultCount + this.childCount;
|
|
2759
2780
|
}
|
|
2760
2781
|
get hasPayment() {
|
|
2761
|
-
|
|
2762
|
-
return ((_a = this.paymentId) == null ? void 0 : _a.length) > 0;
|
|
2782
|
+
return this.paymentId?.length > 0;
|
|
2763
2783
|
}
|
|
2764
2784
|
range(tz) {
|
|
2765
2785
|
const start = new Date(this.checkInDateTime);
|
|
@@ -3014,9 +3034,8 @@ var require_space2 = __commonJS({
|
|
|
3014
3034
|
value: Object.keys(schema.properties)
|
|
3015
3035
|
});
|
|
3016
3036
|
function mapSpaceData(data) {
|
|
3017
|
-
var _a;
|
|
3018
3037
|
const spaceData = cloneDeep(data);
|
|
3019
|
-
if (
|
|
3038
|
+
if (spaceData.rooms?.length) {
|
|
3020
3039
|
spaceData.rooms.map((room) => {
|
|
3021
3040
|
if (typeof room === "string")
|
|
3022
3041
|
return room;
|
|
@@ -3296,6 +3315,9 @@ var require_gateway = __commonJS({
|
|
|
3296
3315
|
},
|
|
3297
3316
|
driver: {
|
|
3298
3317
|
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
|
|
3318
|
+
},
|
|
3319
|
+
watts: {
|
|
3320
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
3299
3321
|
}
|
|
3300
3322
|
},
|
|
3301
3323
|
additionalProperties: false,
|
|
@@ -3617,6 +3639,393 @@ var require_shortLink2 = __commonJS({
|
|
|
3617
3639
|
}
|
|
3618
3640
|
});
|
|
3619
3641
|
|
|
3642
|
+
// src/schemas/energyReportShard.json
|
|
3643
|
+
var require_energyReportShard = __commonJS({
|
|
3644
|
+
"src/schemas/energyReportShard.json"(exports2, module2) {
|
|
3645
|
+
module2.exports = {
|
|
3646
|
+
$schema: "http://json-schema.org/draft-07/schema",
|
|
3647
|
+
$id: "https://api.kohost.io/schemas/v3/energyReportShard.json",
|
|
3648
|
+
title: "Energy Report Shard",
|
|
3649
|
+
description: "Shard used for Energy Reports",
|
|
3650
|
+
type: "object",
|
|
3651
|
+
required: ["id", "type", "roomId", "first", "last", "data", "ndata", "expires"],
|
|
3652
|
+
properties: {
|
|
3653
|
+
id: {
|
|
3654
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
3655
|
+
},
|
|
3656
|
+
type: {
|
|
3657
|
+
type: "string",
|
|
3658
|
+
enum: [
|
|
3659
|
+
"energyReportShard"
|
|
3660
|
+
],
|
|
3661
|
+
default: "energyReportShard"
|
|
3662
|
+
},
|
|
3663
|
+
roomId: {
|
|
3664
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
3665
|
+
},
|
|
3666
|
+
first: {
|
|
3667
|
+
type: ["string", "object"],
|
|
3668
|
+
format: "date-time"
|
|
3669
|
+
},
|
|
3670
|
+
last: {
|
|
3671
|
+
type: ["string", "object"],
|
|
3672
|
+
format: "date-time"
|
|
3673
|
+
},
|
|
3674
|
+
data: {
|
|
3675
|
+
type: "array",
|
|
3676
|
+
items: {
|
|
3677
|
+
type: "object",
|
|
3678
|
+
required: ["time", "watts", "id", "type", "value"],
|
|
3679
|
+
properties: {
|
|
3680
|
+
time: {
|
|
3681
|
+
type: ["string", "object"],
|
|
3682
|
+
format: "date-time"
|
|
3683
|
+
},
|
|
3684
|
+
watts: {
|
|
3685
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
3686
|
+
},
|
|
3687
|
+
id: {
|
|
3688
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
3689
|
+
},
|
|
3690
|
+
type: {
|
|
3691
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
|
|
3692
|
+
},
|
|
3693
|
+
value: {
|
|
3694
|
+
type: "number",
|
|
3695
|
+
minimum: 0,
|
|
3696
|
+
maximum: 1
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
}
|
|
3700
|
+
},
|
|
3701
|
+
ndata: {
|
|
3702
|
+
type: "integer",
|
|
3703
|
+
minimum: 0,
|
|
3704
|
+
maximum: 1e5,
|
|
3705
|
+
default: 0
|
|
3706
|
+
},
|
|
3707
|
+
expires: {
|
|
3708
|
+
type: ["string", "object"],
|
|
3709
|
+
format: "date-time"
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
};
|
|
3713
|
+
}
|
|
3714
|
+
});
|
|
3715
|
+
|
|
3716
|
+
// src/Models/energyReportShard.js
|
|
3717
|
+
var require_energyReportShard2 = __commonJS({
|
|
3718
|
+
"src/Models/energyReportShard.js"(exports2, module2) {
|
|
3719
|
+
var schemas = require_schema();
|
|
3720
|
+
var schema = require_energyReportShard();
|
|
3721
|
+
var Kohost = require_kohost();
|
|
3722
|
+
schemas.add(schema);
|
|
3723
|
+
var validator = schemas.compile(schema);
|
|
3724
|
+
var EnergyReportShard2 = class extends Kohost {
|
|
3725
|
+
constructor(data) {
|
|
3726
|
+
super(data);
|
|
3727
|
+
}
|
|
3728
|
+
};
|
|
3729
|
+
__name(EnergyReportShard2, "EnergyReportShard");
|
|
3730
|
+
Object.defineProperty(EnergyReportShard2.prototype, "schema", {
|
|
3731
|
+
value: schema
|
|
3732
|
+
});
|
|
3733
|
+
Object.defineProperty(EnergyReportShard2.prototype, "validator", {
|
|
3734
|
+
get: function() {
|
|
3735
|
+
return validator;
|
|
3736
|
+
}
|
|
3737
|
+
});
|
|
3738
|
+
Object.defineProperty(EnergyReportShard2, "validProperties", {
|
|
3739
|
+
value: Object.keys(schema.properties)
|
|
3740
|
+
});
|
|
3741
|
+
Object.defineProperty(EnergyReportShard2, "actionProperties", {
|
|
3742
|
+
value: ["state"]
|
|
3743
|
+
});
|
|
3744
|
+
module2.exports = EnergyReportShard2;
|
|
3745
|
+
var shard = new EnergyReportShard2({
|
|
3746
|
+
"id": "ShardId1",
|
|
3747
|
+
"type": "energyReportShard",
|
|
3748
|
+
"roomId": "TestRoom",
|
|
3749
|
+
"first": /* @__PURE__ */ new Date(),
|
|
3750
|
+
"last": /* @__PURE__ */ new Date(),
|
|
3751
|
+
"data": [{
|
|
3752
|
+
"time": /* @__PURE__ */ new Date(),
|
|
3753
|
+
"watts": 100,
|
|
3754
|
+
"id": "1",
|
|
3755
|
+
"type": "dimmer",
|
|
3756
|
+
"value": 0.121315
|
|
3757
|
+
}],
|
|
3758
|
+
"ndata": 1,
|
|
3759
|
+
"expires": /* @__PURE__ */ new Date()
|
|
3760
|
+
});
|
|
3761
|
+
console.log(shard);
|
|
3762
|
+
}
|
|
3763
|
+
});
|
|
3764
|
+
|
|
3765
|
+
// src/schemas/energyReportHourly.json
|
|
3766
|
+
var require_energyReportHourly = __commonJS({
|
|
3767
|
+
"src/schemas/energyReportHourly.json"(exports2, module2) {
|
|
3768
|
+
module2.exports = {
|
|
3769
|
+
$schema: "http://json-schema.org/draft-07/schema",
|
|
3770
|
+
$id: "https://api.kohost.io/schemas/v3/energyReportHourly.json",
|
|
3771
|
+
title: "Energy Report Hourly",
|
|
3772
|
+
description: "Hourly Report for Energy based on energy report shards",
|
|
3773
|
+
type: "object",
|
|
3774
|
+
required: ["id", "type", "roomId", "first", "last", "consumption", "totals", "costPerKw"],
|
|
3775
|
+
properties: {
|
|
3776
|
+
id: {
|
|
3777
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
3778
|
+
},
|
|
3779
|
+
type: {
|
|
3780
|
+
type: "string",
|
|
3781
|
+
enum: [
|
|
3782
|
+
"energyReportHourly"
|
|
3783
|
+
],
|
|
3784
|
+
default: "energyReportHourly"
|
|
3785
|
+
},
|
|
3786
|
+
roomId: {
|
|
3787
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
3788
|
+
},
|
|
3789
|
+
first: {
|
|
3790
|
+
type: ["string", "object"],
|
|
3791
|
+
format: "date-time"
|
|
3792
|
+
},
|
|
3793
|
+
last: {
|
|
3794
|
+
type: ["string", "object"],
|
|
3795
|
+
format: "date-time"
|
|
3796
|
+
},
|
|
3797
|
+
consumption: {
|
|
3798
|
+
type: "array",
|
|
3799
|
+
items: {
|
|
3800
|
+
type: "object",
|
|
3801
|
+
required: ["id", "type", "kwh"],
|
|
3802
|
+
properties: {
|
|
3803
|
+
id: {
|
|
3804
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
3805
|
+
},
|
|
3806
|
+
type: {
|
|
3807
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
|
|
3808
|
+
},
|
|
3809
|
+
kwh: {
|
|
3810
|
+
type: "number",
|
|
3811
|
+
minimum: 0
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
},
|
|
3816
|
+
totals: {
|
|
3817
|
+
type: "array",
|
|
3818
|
+
items: {
|
|
3819
|
+
type: "object",
|
|
3820
|
+
required: ["lights", "climate", "media"],
|
|
3821
|
+
properties: {
|
|
3822
|
+
lights: {
|
|
3823
|
+
type: "number",
|
|
3824
|
+
minimum: 0
|
|
3825
|
+
},
|
|
3826
|
+
climate: {
|
|
3827
|
+
type: "number",
|
|
3828
|
+
minimum: 0
|
|
3829
|
+
},
|
|
3830
|
+
media: {
|
|
3831
|
+
type: "number",
|
|
3832
|
+
minimum: 0
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
},
|
|
3837
|
+
costPerKw: {
|
|
3838
|
+
type: "number",
|
|
3839
|
+
minimum: 0
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
});
|
|
3845
|
+
|
|
3846
|
+
// src/Models/energyReportHourly.js
|
|
3847
|
+
var require_energyReportHourly2 = __commonJS({
|
|
3848
|
+
"src/Models/energyReportHourly.js"(exports2, module2) {
|
|
3849
|
+
var schemas = require_schema();
|
|
3850
|
+
var schema = require_energyReportHourly();
|
|
3851
|
+
var Kohost = require_kohost();
|
|
3852
|
+
schemas.add(schema);
|
|
3853
|
+
var validator = schemas.compile(schema);
|
|
3854
|
+
var EnergyReportHourly2 = class extends Kohost {
|
|
3855
|
+
constructor(data) {
|
|
3856
|
+
super(data);
|
|
3857
|
+
}
|
|
3858
|
+
};
|
|
3859
|
+
__name(EnergyReportHourly2, "EnergyReportHourly");
|
|
3860
|
+
Object.defineProperty(EnergyReportHourly2.prototype, "schema", {
|
|
3861
|
+
value: schema
|
|
3862
|
+
});
|
|
3863
|
+
Object.defineProperty(EnergyReportHourly2.prototype, "validator", {
|
|
3864
|
+
get: function() {
|
|
3865
|
+
return validator;
|
|
3866
|
+
}
|
|
3867
|
+
});
|
|
3868
|
+
Object.defineProperty(EnergyReportHourly2, "validProperties", {
|
|
3869
|
+
value: Object.keys(schema.properties)
|
|
3870
|
+
});
|
|
3871
|
+
Object.defineProperty(EnergyReportHourly2, "actionProperties", {
|
|
3872
|
+
value: ["state"]
|
|
3873
|
+
});
|
|
3874
|
+
module2.exports = EnergyReportHourly2;
|
|
3875
|
+
var hourlyShardReport = new EnergyReportHourly2({
|
|
3876
|
+
"id": "RepIdHr1",
|
|
3877
|
+
"type": "energyReportHourly",
|
|
3878
|
+
"roomId": "TestRoom",
|
|
3879
|
+
"first": /* @__PURE__ */ new Date(),
|
|
3880
|
+
"last": /* @__PURE__ */ new Date(),
|
|
3881
|
+
"consumption": [{
|
|
3882
|
+
"id": "1",
|
|
3883
|
+
"type": "dimmer",
|
|
3884
|
+
"kwh": 0.121315
|
|
3885
|
+
}],
|
|
3886
|
+
"totals": [{
|
|
3887
|
+
"lights": 10,
|
|
3888
|
+
"climate": 10,
|
|
3889
|
+
"media": 10
|
|
3890
|
+
}],
|
|
3891
|
+
"costPerKw": 0.14
|
|
3892
|
+
});
|
|
3893
|
+
console.log(hourlyShardReport);
|
|
3894
|
+
}
|
|
3895
|
+
});
|
|
3896
|
+
|
|
3897
|
+
// src/schemas/energyReportDaily.json
|
|
3898
|
+
var require_energyReportDaily = __commonJS({
|
|
3899
|
+
"src/schemas/energyReportDaily.json"(exports2, module2) {
|
|
3900
|
+
module2.exports = {
|
|
3901
|
+
$schema: "http://json-schema.org/draft-07/schema",
|
|
3902
|
+
$id: "https://api.kohost.io/schemas/v3/energyReportDaily.json",
|
|
3903
|
+
title: "Energy Report Daily",
|
|
3904
|
+
description: "Daily Report for Energy based on energy report shards",
|
|
3905
|
+
type: "object",
|
|
3906
|
+
required: ["id", "type", "roomId", "first", "last", "consumption", "totals", "costPerKw"],
|
|
3907
|
+
properties: {
|
|
3908
|
+
id: {
|
|
3909
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
|
|
3910
|
+
},
|
|
3911
|
+
type: {
|
|
3912
|
+
type: "string",
|
|
3913
|
+
enum: [
|
|
3914
|
+
"energyReportDaily"
|
|
3915
|
+
],
|
|
3916
|
+
default: "energyReportDaily"
|
|
3917
|
+
},
|
|
3918
|
+
roomId: {
|
|
3919
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
3920
|
+
},
|
|
3921
|
+
first: {
|
|
3922
|
+
type: ["string", "object"],
|
|
3923
|
+
format: "date-time"
|
|
3924
|
+
},
|
|
3925
|
+
last: {
|
|
3926
|
+
type: ["string", "object"],
|
|
3927
|
+
format: "date-time"
|
|
3928
|
+
},
|
|
3929
|
+
consumption: {
|
|
3930
|
+
type: "array",
|
|
3931
|
+
items: {
|
|
3932
|
+
type: "object",
|
|
3933
|
+
required: ["id", "type", "kwh"],
|
|
3934
|
+
properties: {
|
|
3935
|
+
id: {
|
|
3936
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
3937
|
+
},
|
|
3938
|
+
type: {
|
|
3939
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
|
|
3940
|
+
},
|
|
3941
|
+
kwh: {
|
|
3942
|
+
type: "number",
|
|
3943
|
+
minimum: 0
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
},
|
|
3948
|
+
totals: {
|
|
3949
|
+
type: "array",
|
|
3950
|
+
items: {
|
|
3951
|
+
type: "object",
|
|
3952
|
+
required: ["lights", "climate", "media"],
|
|
3953
|
+
properties: {
|
|
3954
|
+
lights: {
|
|
3955
|
+
type: "number",
|
|
3956
|
+
minimum: 0
|
|
3957
|
+
},
|
|
3958
|
+
climate: {
|
|
3959
|
+
type: "number",
|
|
3960
|
+
minimum: 0
|
|
3961
|
+
},
|
|
3962
|
+
media: {
|
|
3963
|
+
type: "number",
|
|
3964
|
+
minimum: 0
|
|
3965
|
+
}
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
},
|
|
3969
|
+
costPerKw: {
|
|
3970
|
+
type: "number",
|
|
3971
|
+
minimum: 0
|
|
3972
|
+
}
|
|
3973
|
+
}
|
|
3974
|
+
};
|
|
3975
|
+
}
|
|
3976
|
+
});
|
|
3977
|
+
|
|
3978
|
+
// src/Models/energyReportDaily.js
|
|
3979
|
+
var require_energyReportDaily2 = __commonJS({
|
|
3980
|
+
"src/Models/energyReportDaily.js"(exports2, module2) {
|
|
3981
|
+
var schemas = require_schema();
|
|
3982
|
+
var schema = require_energyReportDaily();
|
|
3983
|
+
var Kohost = require_kohost();
|
|
3984
|
+
schemas.add(schema);
|
|
3985
|
+
var validator = schemas.compile(schema);
|
|
3986
|
+
var energyReportDaily = class extends Kohost {
|
|
3987
|
+
constructor(data) {
|
|
3988
|
+
super(data);
|
|
3989
|
+
}
|
|
3990
|
+
};
|
|
3991
|
+
__name(energyReportDaily, "energyReportDaily");
|
|
3992
|
+
Object.defineProperty(energyReportDaily.prototype, "schema", {
|
|
3993
|
+
value: schema
|
|
3994
|
+
});
|
|
3995
|
+
Object.defineProperty(energyReportDaily.prototype, "validator", {
|
|
3996
|
+
get: function() {
|
|
3997
|
+
return validator;
|
|
3998
|
+
}
|
|
3999
|
+
});
|
|
4000
|
+
Object.defineProperty(energyReportDaily, "validProperties", {
|
|
4001
|
+
value: Object.keys(schema.properties)
|
|
4002
|
+
});
|
|
4003
|
+
Object.defineProperty(energyReportDaily, "actionProperties", {
|
|
4004
|
+
value: ["state"]
|
|
4005
|
+
});
|
|
4006
|
+
module2.exports = energyReportDaily;
|
|
4007
|
+
var dailyShardReport = new energyReportDaily({
|
|
4008
|
+
"id": "RepIdHr1",
|
|
4009
|
+
"type": "energyReportDaily",
|
|
4010
|
+
"roomId": "TestRoom",
|
|
4011
|
+
"first": /* @__PURE__ */ new Date(),
|
|
4012
|
+
"last": /* @__PURE__ */ new Date(),
|
|
4013
|
+
"consumption": [{
|
|
4014
|
+
"id": "1",
|
|
4015
|
+
"type": "dimmer",
|
|
4016
|
+
"kwh": 0.121315
|
|
4017
|
+
}],
|
|
4018
|
+
"totals": [{
|
|
4019
|
+
"lights": 10,
|
|
4020
|
+
"climate": 10,
|
|
4021
|
+
"media": 10
|
|
4022
|
+
}],
|
|
4023
|
+
"costPerKw": 0.14
|
|
4024
|
+
});
|
|
4025
|
+
console.log(dailyShardReport);
|
|
4026
|
+
}
|
|
4027
|
+
});
|
|
4028
|
+
|
|
3620
4029
|
// src/schemas/property.json
|
|
3621
4030
|
var require_property = __commonJS({
|
|
3622
4031
|
"src/schemas/property.json"(exports2, module2) {
|
|
@@ -3967,6 +4376,9 @@ var Product = require_product2();
|
|
|
3967
4376
|
var DiscoveredDevice = require_discoveredDevice2();
|
|
3968
4377
|
var Credential = require_credential2();
|
|
3969
4378
|
var ShortLink = require_shortLink2();
|
|
4379
|
+
var EnergyReportShard = require_energyReportShard2();
|
|
4380
|
+
var EnergyReportHourly = require_energyReportHourly2();
|
|
4381
|
+
var EnergyReportDaily = require_energyReportDaily2();
|
|
3970
4382
|
var Property = require_property2();
|
|
3971
4383
|
var Organization = require_organization2();
|
|
3972
4384
|
module.exports = {
|
|
@@ -3995,5 +4407,8 @@ module.exports = {
|
|
|
3995
4407
|
DiscoveredDevice,
|
|
3996
4408
|
Reservation,
|
|
3997
4409
|
Credential,
|
|
3998
|
-
ShortLink
|
|
4410
|
+
ShortLink,
|
|
4411
|
+
EnergyReportShard,
|
|
4412
|
+
EnergyReportHourly,
|
|
4413
|
+
EnergyReportDaily
|
|
3999
4414
|
};
|