@kohost/api-client 3.0.0-beta.27 → 3.0.0-beta.29
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 +462 -47
- 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 +436 -5
- 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
|
@@ -39,12 +39,10 @@ module.exports = /* @__PURE__ */ __name(class SocketIoClient extends EventEmitte
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
get connected() {
|
|
42
|
-
|
|
43
|
-
return ((_a = this.socket) == null ? void 0 : _a.connected) || false;
|
|
42
|
+
return this.socket?.connected || false;
|
|
44
43
|
}
|
|
45
44
|
get disconnected() {
|
|
46
|
-
|
|
47
|
-
return ((_a = this.socket) == null ? void 0 : _a.disconnected) || false;
|
|
45
|
+
return this.socket?.disconnected || false;
|
|
48
46
|
}
|
|
49
47
|
connect() {
|
|
50
48
|
this.socket.connect();
|
package/dist/cjs/defs.js
CHANGED
|
@@ -90,9 +90,8 @@ var require_Client = __commonJS({
|
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
_handleResponse(response) {
|
|
93
|
-
var _a;
|
|
94
93
|
try {
|
|
95
|
-
if (
|
|
94
|
+
if (response?.data?.data) {
|
|
96
95
|
response.query = response.data.query;
|
|
97
96
|
response.pagination = response.data.pagination;
|
|
98
97
|
response.data = response.data.data;
|
|
@@ -103,13 +102,12 @@ var require_Client = __commonJS({
|
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
104
|
_handleResponseError(error) {
|
|
106
|
-
var _a, _b;
|
|
107
105
|
const { config: originalReq } = error;
|
|
108
106
|
if (!error.response)
|
|
109
107
|
return Promise.reject(error);
|
|
110
108
|
const { status, data } = error.response;
|
|
111
|
-
const errorType =
|
|
112
|
-
const errorMessage =
|
|
109
|
+
const errorType = data?.error?.type;
|
|
110
|
+
const errorMessage = data?.error?.message;
|
|
113
111
|
try {
|
|
114
112
|
const expectedError = status >= 400 && status < 500;
|
|
115
113
|
const newTokensNeeded = expectedError && errorType === "TokenExpiredError";
|
package/dist/cjs/utils.js
CHANGED
package/dist/esm/Models.js
CHANGED
|
@@ -7564,6 +7564,11 @@ var require_device = __commonJS({
|
|
|
7564
7564
|
type: "number",
|
|
7565
7565
|
minimum: 0,
|
|
7566
7566
|
maximum: 100
|
|
7567
|
+
},
|
|
7568
|
+
watts: {
|
|
7569
|
+
type: "number",
|
|
7570
|
+
minimum: 0,
|
|
7571
|
+
default: 0
|
|
7567
7572
|
}
|
|
7568
7573
|
}
|
|
7569
7574
|
};
|
|
@@ -7636,6 +7641,9 @@ var require_switch = __commonJS({
|
|
|
7636
7641
|
},
|
|
7637
7642
|
systemData: {
|
|
7638
7643
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
7644
|
+
},
|
|
7645
|
+
watts: {
|
|
7646
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
7639
7647
|
}
|
|
7640
7648
|
},
|
|
7641
7649
|
additionalProperties: false,
|
|
@@ -8079,6 +8087,9 @@ var require_alarm = __commonJS({
|
|
|
8079
8087
|
items: {
|
|
8080
8088
|
$ref: "#/properties/supportedTroubles/items"
|
|
8081
8089
|
}
|
|
8090
|
+
},
|
|
8091
|
+
watts: {
|
|
8092
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
8082
8093
|
}
|
|
8083
8094
|
},
|
|
8084
8095
|
additionalProperties: false,
|
|
@@ -8163,6 +8174,9 @@ var require_dimmer = __commonJS({
|
|
|
8163
8174
|
},
|
|
8164
8175
|
systemData: {
|
|
8165
8176
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
8177
|
+
},
|
|
8178
|
+
watts: {
|
|
8179
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
8166
8180
|
}
|
|
8167
8181
|
},
|
|
8168
8182
|
additionalProperties: false,
|
|
@@ -8255,6 +8269,9 @@ var require_lock = __commonJS({
|
|
|
8255
8269
|
},
|
|
8256
8270
|
systemData: {
|
|
8257
8271
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
8272
|
+
},
|
|
8273
|
+
watts: {
|
|
8274
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
8258
8275
|
}
|
|
8259
8276
|
},
|
|
8260
8277
|
additionalProperties: false,
|
|
@@ -8402,6 +8419,9 @@ var require_thermostat = __commonJS({
|
|
|
8402
8419
|
systemData: {
|
|
8403
8420
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData",
|
|
8404
8421
|
default: {}
|
|
8422
|
+
},
|
|
8423
|
+
watts: {
|
|
8424
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
8405
8425
|
}
|
|
8406
8426
|
},
|
|
8407
8427
|
additionalProperties: false,
|
|
@@ -8561,6 +8581,9 @@ var require_windowCovering = __commonJS({
|
|
|
8561
8581
|
},
|
|
8562
8582
|
systemData: {
|
|
8563
8583
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
8584
|
+
},
|
|
8585
|
+
watts: {
|
|
8586
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
8564
8587
|
}
|
|
8565
8588
|
},
|
|
8566
8589
|
additionalProperties: false,
|
|
@@ -9189,6 +9212,9 @@ var require_courtesy = __commonJS({
|
|
|
9189
9212
|
},
|
|
9190
9213
|
systemData: {
|
|
9191
9214
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
9215
|
+
},
|
|
9216
|
+
watts: {
|
|
9217
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
9192
9218
|
}
|
|
9193
9219
|
},
|
|
9194
9220
|
additionalProperties: false,
|
|
@@ -9274,6 +9300,9 @@ var require_camera = __commonJS({
|
|
|
9274
9300
|
},
|
|
9275
9301
|
systemData: {
|
|
9276
9302
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
9303
|
+
},
|
|
9304
|
+
watts: {
|
|
9305
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
9277
9306
|
}
|
|
9278
9307
|
},
|
|
9279
9308
|
additionalProperties: false,
|
|
@@ -9338,6 +9367,9 @@ var require_motionSensor = __commonJS({
|
|
|
9338
9367
|
},
|
|
9339
9368
|
notification: {
|
|
9340
9369
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
|
|
9370
|
+
},
|
|
9371
|
+
watts: {
|
|
9372
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
9341
9373
|
}
|
|
9342
9374
|
},
|
|
9343
9375
|
additionalProperties: false,
|
|
@@ -9552,6 +9584,9 @@ var require_mediaSource = __commonJS({
|
|
|
9552
9584
|
},
|
|
9553
9585
|
systemData: {
|
|
9554
9586
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
9587
|
+
},
|
|
9588
|
+
watts: {
|
|
9589
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
9555
9590
|
}
|
|
9556
9591
|
},
|
|
9557
9592
|
additionalProperties: false
|
|
@@ -10594,7 +10629,7 @@ var require_room2 = __commonJS({
|
|
|
10594
10629
|
var Courtesy = require_courtesy2();
|
|
10595
10630
|
var Camera = require_camera2();
|
|
10596
10631
|
var Alarm = require_alarm2();
|
|
10597
|
-
var
|
|
10632
|
+
var MediaSource = require_mediaSource2();
|
|
10598
10633
|
var MotionSensor = require_motionSensor2();
|
|
10599
10634
|
var Scene = require_scene2();
|
|
10600
10635
|
schemas.add(schema);
|
|
@@ -10748,11 +10783,11 @@ var require_room2 = __commonJS({
|
|
|
10748
10783
|
else
|
|
10749
10784
|
return new Courtesy(courtesy);
|
|
10750
10785
|
});
|
|
10751
|
-
roomData.
|
|
10752
|
-
if (source instanceof
|
|
10786
|
+
roomData.mediaSources?.map((source) => {
|
|
10787
|
+
if (source instanceof MediaSource)
|
|
10753
10788
|
return source;
|
|
10754
10789
|
else
|
|
10755
|
-
return new
|
|
10790
|
+
return new MediaSource(source);
|
|
10756
10791
|
});
|
|
10757
10792
|
roomData.cameras?.map((camera) => {
|
|
10758
10793
|
if (camera instanceof Camera)
|
|
@@ -13524,6 +13559,9 @@ var require_gateway = __commonJS({
|
|
|
13524
13559
|
},
|
|
13525
13560
|
driver: {
|
|
13526
13561
|
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
|
|
13562
|
+
},
|
|
13563
|
+
watts: {
|
|
13564
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
13527
13565
|
}
|
|
13528
13566
|
},
|
|
13529
13567
|
additionalProperties: false,
|
|
@@ -13845,6 +13883,393 @@ var require_shortLink2 = __commonJS({
|
|
|
13845
13883
|
}
|
|
13846
13884
|
});
|
|
13847
13885
|
|
|
13886
|
+
// src/schemas/energyReportShard.json
|
|
13887
|
+
var require_energyReportShard = __commonJS({
|
|
13888
|
+
"src/schemas/energyReportShard.json"(exports, module) {
|
|
13889
|
+
module.exports = {
|
|
13890
|
+
$schema: "http://json-schema.org/draft-07/schema",
|
|
13891
|
+
$id: "https://api.kohost.io/schemas/v3/energyReportShard.json",
|
|
13892
|
+
title: "Energy Report Shard",
|
|
13893
|
+
description: "Shard used for Energy Reports",
|
|
13894
|
+
type: "object",
|
|
13895
|
+
required: ["id", "type", "roomId", "first", "last", "data", "ndata", "expires"],
|
|
13896
|
+
properties: {
|
|
13897
|
+
id: {
|
|
13898
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
13899
|
+
},
|
|
13900
|
+
type: {
|
|
13901
|
+
type: "string",
|
|
13902
|
+
enum: [
|
|
13903
|
+
"energyReportShard"
|
|
13904
|
+
],
|
|
13905
|
+
default: "energyReportShard"
|
|
13906
|
+
},
|
|
13907
|
+
roomId: {
|
|
13908
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
13909
|
+
},
|
|
13910
|
+
first: {
|
|
13911
|
+
type: ["string", "object"],
|
|
13912
|
+
format: "date-time"
|
|
13913
|
+
},
|
|
13914
|
+
last: {
|
|
13915
|
+
type: ["string", "object"],
|
|
13916
|
+
format: "date-time"
|
|
13917
|
+
},
|
|
13918
|
+
data: {
|
|
13919
|
+
type: "array",
|
|
13920
|
+
items: {
|
|
13921
|
+
type: "object",
|
|
13922
|
+
required: ["time", "watts", "id", "type", "value"],
|
|
13923
|
+
properties: {
|
|
13924
|
+
time: {
|
|
13925
|
+
type: ["string", "object"],
|
|
13926
|
+
format: "date-time"
|
|
13927
|
+
},
|
|
13928
|
+
watts: {
|
|
13929
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
13930
|
+
},
|
|
13931
|
+
id: {
|
|
13932
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
13933
|
+
},
|
|
13934
|
+
type: {
|
|
13935
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
|
|
13936
|
+
},
|
|
13937
|
+
value: {
|
|
13938
|
+
type: "number",
|
|
13939
|
+
minimum: 0,
|
|
13940
|
+
maximum: 1
|
|
13941
|
+
}
|
|
13942
|
+
}
|
|
13943
|
+
}
|
|
13944
|
+
},
|
|
13945
|
+
ndata: {
|
|
13946
|
+
type: "integer",
|
|
13947
|
+
minimum: 0,
|
|
13948
|
+
maximum: 1e5,
|
|
13949
|
+
default: 0
|
|
13950
|
+
},
|
|
13951
|
+
expires: {
|
|
13952
|
+
type: ["string", "object"],
|
|
13953
|
+
format: "date-time"
|
|
13954
|
+
}
|
|
13955
|
+
}
|
|
13956
|
+
};
|
|
13957
|
+
}
|
|
13958
|
+
});
|
|
13959
|
+
|
|
13960
|
+
// src/Models/energyReportShard.js
|
|
13961
|
+
var require_energyReportShard2 = __commonJS({
|
|
13962
|
+
"src/Models/energyReportShard.js"(exports, module) {
|
|
13963
|
+
var schemas = require_schema();
|
|
13964
|
+
var schema = require_energyReportShard();
|
|
13965
|
+
var Kohost = require_kohost();
|
|
13966
|
+
schemas.add(schema);
|
|
13967
|
+
var validator = schemas.compile(schema);
|
|
13968
|
+
var EnergyReportShard = class extends Kohost {
|
|
13969
|
+
constructor(data) {
|
|
13970
|
+
super(data);
|
|
13971
|
+
}
|
|
13972
|
+
};
|
|
13973
|
+
__name(EnergyReportShard, "EnergyReportShard");
|
|
13974
|
+
Object.defineProperty(EnergyReportShard.prototype, "schema", {
|
|
13975
|
+
value: schema
|
|
13976
|
+
});
|
|
13977
|
+
Object.defineProperty(EnergyReportShard.prototype, "validator", {
|
|
13978
|
+
get: function() {
|
|
13979
|
+
return validator;
|
|
13980
|
+
}
|
|
13981
|
+
});
|
|
13982
|
+
Object.defineProperty(EnergyReportShard, "validProperties", {
|
|
13983
|
+
value: Object.keys(schema.properties)
|
|
13984
|
+
});
|
|
13985
|
+
Object.defineProperty(EnergyReportShard, "actionProperties", {
|
|
13986
|
+
value: ["state"]
|
|
13987
|
+
});
|
|
13988
|
+
module.exports = EnergyReportShard;
|
|
13989
|
+
var shard = new EnergyReportShard({
|
|
13990
|
+
"id": "ShardId1",
|
|
13991
|
+
"type": "energyReportShard",
|
|
13992
|
+
"roomId": "TestRoom",
|
|
13993
|
+
"first": /* @__PURE__ */ new Date(),
|
|
13994
|
+
"last": /* @__PURE__ */ new Date(),
|
|
13995
|
+
"data": [{
|
|
13996
|
+
"time": /* @__PURE__ */ new Date(),
|
|
13997
|
+
"watts": 100,
|
|
13998
|
+
"id": "1",
|
|
13999
|
+
"type": "dimmer",
|
|
14000
|
+
"value": 0.121315
|
|
14001
|
+
}],
|
|
14002
|
+
"ndata": 1,
|
|
14003
|
+
"expires": /* @__PURE__ */ new Date()
|
|
14004
|
+
});
|
|
14005
|
+
console.log(shard);
|
|
14006
|
+
}
|
|
14007
|
+
});
|
|
14008
|
+
|
|
14009
|
+
// src/schemas/energyReportHourly.json
|
|
14010
|
+
var require_energyReportHourly = __commonJS({
|
|
14011
|
+
"src/schemas/energyReportHourly.json"(exports, module) {
|
|
14012
|
+
module.exports = {
|
|
14013
|
+
$schema: "http://json-schema.org/draft-07/schema",
|
|
14014
|
+
$id: "https://api.kohost.io/schemas/v3/energyReportHourly.json",
|
|
14015
|
+
title: "Energy Report Hourly",
|
|
14016
|
+
description: "Hourly Report for Energy based on energy report shards",
|
|
14017
|
+
type: "object",
|
|
14018
|
+
required: ["id", "type", "roomId", "first", "last", "consumption", "totals", "costPerKw"],
|
|
14019
|
+
properties: {
|
|
14020
|
+
id: {
|
|
14021
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
14022
|
+
},
|
|
14023
|
+
type: {
|
|
14024
|
+
type: "string",
|
|
14025
|
+
enum: [
|
|
14026
|
+
"energyReportHourly"
|
|
14027
|
+
],
|
|
14028
|
+
default: "energyReportHourly"
|
|
14029
|
+
},
|
|
14030
|
+
roomId: {
|
|
14031
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
14032
|
+
},
|
|
14033
|
+
first: {
|
|
14034
|
+
type: ["string", "object"],
|
|
14035
|
+
format: "date-time"
|
|
14036
|
+
},
|
|
14037
|
+
last: {
|
|
14038
|
+
type: ["string", "object"],
|
|
14039
|
+
format: "date-time"
|
|
14040
|
+
},
|
|
14041
|
+
consumption: {
|
|
14042
|
+
type: "array",
|
|
14043
|
+
items: {
|
|
14044
|
+
type: "object",
|
|
14045
|
+
required: ["id", "type", "kwh"],
|
|
14046
|
+
properties: {
|
|
14047
|
+
id: {
|
|
14048
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
14049
|
+
},
|
|
14050
|
+
type: {
|
|
14051
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
|
|
14052
|
+
},
|
|
14053
|
+
kwh: {
|
|
14054
|
+
type: "number",
|
|
14055
|
+
minimum: 0
|
|
14056
|
+
}
|
|
14057
|
+
}
|
|
14058
|
+
}
|
|
14059
|
+
},
|
|
14060
|
+
totals: {
|
|
14061
|
+
type: "array",
|
|
14062
|
+
items: {
|
|
14063
|
+
type: "object",
|
|
14064
|
+
required: ["lights", "climate", "media"],
|
|
14065
|
+
properties: {
|
|
14066
|
+
lights: {
|
|
14067
|
+
type: "number",
|
|
14068
|
+
minimum: 0
|
|
14069
|
+
},
|
|
14070
|
+
climate: {
|
|
14071
|
+
type: "number",
|
|
14072
|
+
minimum: 0
|
|
14073
|
+
},
|
|
14074
|
+
media: {
|
|
14075
|
+
type: "number",
|
|
14076
|
+
minimum: 0
|
|
14077
|
+
}
|
|
14078
|
+
}
|
|
14079
|
+
}
|
|
14080
|
+
},
|
|
14081
|
+
costPerKw: {
|
|
14082
|
+
type: "number",
|
|
14083
|
+
minimum: 0
|
|
14084
|
+
}
|
|
14085
|
+
}
|
|
14086
|
+
};
|
|
14087
|
+
}
|
|
14088
|
+
});
|
|
14089
|
+
|
|
14090
|
+
// src/Models/energyReportHourly.js
|
|
14091
|
+
var require_energyReportHourly2 = __commonJS({
|
|
14092
|
+
"src/Models/energyReportHourly.js"(exports, module) {
|
|
14093
|
+
var schemas = require_schema();
|
|
14094
|
+
var schema = require_energyReportHourly();
|
|
14095
|
+
var Kohost = require_kohost();
|
|
14096
|
+
schemas.add(schema);
|
|
14097
|
+
var validator = schemas.compile(schema);
|
|
14098
|
+
var EnergyReportHourly = class extends Kohost {
|
|
14099
|
+
constructor(data) {
|
|
14100
|
+
super(data);
|
|
14101
|
+
}
|
|
14102
|
+
};
|
|
14103
|
+
__name(EnergyReportHourly, "EnergyReportHourly");
|
|
14104
|
+
Object.defineProperty(EnergyReportHourly.prototype, "schema", {
|
|
14105
|
+
value: schema
|
|
14106
|
+
});
|
|
14107
|
+
Object.defineProperty(EnergyReportHourly.prototype, "validator", {
|
|
14108
|
+
get: function() {
|
|
14109
|
+
return validator;
|
|
14110
|
+
}
|
|
14111
|
+
});
|
|
14112
|
+
Object.defineProperty(EnergyReportHourly, "validProperties", {
|
|
14113
|
+
value: Object.keys(schema.properties)
|
|
14114
|
+
});
|
|
14115
|
+
Object.defineProperty(EnergyReportHourly, "actionProperties", {
|
|
14116
|
+
value: ["state"]
|
|
14117
|
+
});
|
|
14118
|
+
module.exports = EnergyReportHourly;
|
|
14119
|
+
var hourlyShardReport = new EnergyReportHourly({
|
|
14120
|
+
"id": "RepIdHr1",
|
|
14121
|
+
"type": "energyReportHourly",
|
|
14122
|
+
"roomId": "TestRoom",
|
|
14123
|
+
"first": /* @__PURE__ */ new Date(),
|
|
14124
|
+
"last": /* @__PURE__ */ new Date(),
|
|
14125
|
+
"consumption": [{
|
|
14126
|
+
"id": "1",
|
|
14127
|
+
"type": "dimmer",
|
|
14128
|
+
"kwh": 0.121315
|
|
14129
|
+
}],
|
|
14130
|
+
"totals": [{
|
|
14131
|
+
"lights": 10,
|
|
14132
|
+
"climate": 10,
|
|
14133
|
+
"media": 10
|
|
14134
|
+
}],
|
|
14135
|
+
"costPerKw": 0.14
|
|
14136
|
+
});
|
|
14137
|
+
console.log(hourlyShardReport);
|
|
14138
|
+
}
|
|
14139
|
+
});
|
|
14140
|
+
|
|
14141
|
+
// src/schemas/energyReportDaily.json
|
|
14142
|
+
var require_energyReportDaily = __commonJS({
|
|
14143
|
+
"src/schemas/energyReportDaily.json"(exports, module) {
|
|
14144
|
+
module.exports = {
|
|
14145
|
+
$schema: "http://json-schema.org/draft-07/schema",
|
|
14146
|
+
$id: "https://api.kohost.io/schemas/v3/energyReportDaily.json",
|
|
14147
|
+
title: "Energy Report Daily",
|
|
14148
|
+
description: "Daily Report for Energy based on energy report shards",
|
|
14149
|
+
type: "object",
|
|
14150
|
+
required: ["id", "type", "roomId", "first", "last", "consumption", "totals", "costPerKw"],
|
|
14151
|
+
properties: {
|
|
14152
|
+
id: {
|
|
14153
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
|
|
14154
|
+
},
|
|
14155
|
+
type: {
|
|
14156
|
+
type: "string",
|
|
14157
|
+
enum: [
|
|
14158
|
+
"energyReportDaily"
|
|
14159
|
+
],
|
|
14160
|
+
default: "energyReportDaily"
|
|
14161
|
+
},
|
|
14162
|
+
roomId: {
|
|
14163
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
14164
|
+
},
|
|
14165
|
+
first: {
|
|
14166
|
+
type: ["string", "object"],
|
|
14167
|
+
format: "date-time"
|
|
14168
|
+
},
|
|
14169
|
+
last: {
|
|
14170
|
+
type: ["string", "object"],
|
|
14171
|
+
format: "date-time"
|
|
14172
|
+
},
|
|
14173
|
+
consumption: {
|
|
14174
|
+
type: "array",
|
|
14175
|
+
items: {
|
|
14176
|
+
type: "object",
|
|
14177
|
+
required: ["id", "type", "kwh"],
|
|
14178
|
+
properties: {
|
|
14179
|
+
id: {
|
|
14180
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
14181
|
+
},
|
|
14182
|
+
type: {
|
|
14183
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
|
|
14184
|
+
},
|
|
14185
|
+
kwh: {
|
|
14186
|
+
type: "number",
|
|
14187
|
+
minimum: 0
|
|
14188
|
+
}
|
|
14189
|
+
}
|
|
14190
|
+
}
|
|
14191
|
+
},
|
|
14192
|
+
totals: {
|
|
14193
|
+
type: "array",
|
|
14194
|
+
items: {
|
|
14195
|
+
type: "object",
|
|
14196
|
+
required: ["lights", "climate", "media"],
|
|
14197
|
+
properties: {
|
|
14198
|
+
lights: {
|
|
14199
|
+
type: "number",
|
|
14200
|
+
minimum: 0
|
|
14201
|
+
},
|
|
14202
|
+
climate: {
|
|
14203
|
+
type: "number",
|
|
14204
|
+
minimum: 0
|
|
14205
|
+
},
|
|
14206
|
+
media: {
|
|
14207
|
+
type: "number",
|
|
14208
|
+
minimum: 0
|
|
14209
|
+
}
|
|
14210
|
+
}
|
|
14211
|
+
}
|
|
14212
|
+
},
|
|
14213
|
+
costPerKw: {
|
|
14214
|
+
type: "number",
|
|
14215
|
+
minimum: 0
|
|
14216
|
+
}
|
|
14217
|
+
}
|
|
14218
|
+
};
|
|
14219
|
+
}
|
|
14220
|
+
});
|
|
14221
|
+
|
|
14222
|
+
// src/Models/energyReportDaily.js
|
|
14223
|
+
var require_energyReportDaily2 = __commonJS({
|
|
14224
|
+
"src/Models/energyReportDaily.js"(exports, module) {
|
|
14225
|
+
var schemas = require_schema();
|
|
14226
|
+
var schema = require_energyReportDaily();
|
|
14227
|
+
var Kohost = require_kohost();
|
|
14228
|
+
schemas.add(schema);
|
|
14229
|
+
var validator = schemas.compile(schema);
|
|
14230
|
+
var energyReportDaily = class extends Kohost {
|
|
14231
|
+
constructor(data) {
|
|
14232
|
+
super(data);
|
|
14233
|
+
}
|
|
14234
|
+
};
|
|
14235
|
+
__name(energyReportDaily, "energyReportDaily");
|
|
14236
|
+
Object.defineProperty(energyReportDaily.prototype, "schema", {
|
|
14237
|
+
value: schema
|
|
14238
|
+
});
|
|
14239
|
+
Object.defineProperty(energyReportDaily.prototype, "validator", {
|
|
14240
|
+
get: function() {
|
|
14241
|
+
return validator;
|
|
14242
|
+
}
|
|
14243
|
+
});
|
|
14244
|
+
Object.defineProperty(energyReportDaily, "validProperties", {
|
|
14245
|
+
value: Object.keys(schema.properties)
|
|
14246
|
+
});
|
|
14247
|
+
Object.defineProperty(energyReportDaily, "actionProperties", {
|
|
14248
|
+
value: ["state"]
|
|
14249
|
+
});
|
|
14250
|
+
module.exports = energyReportDaily;
|
|
14251
|
+
var dailyShardReport = new energyReportDaily({
|
|
14252
|
+
"id": "RepIdHr1",
|
|
14253
|
+
"type": "energyReportDaily",
|
|
14254
|
+
"roomId": "TestRoom",
|
|
14255
|
+
"first": /* @__PURE__ */ new Date(),
|
|
14256
|
+
"last": /* @__PURE__ */ new Date(),
|
|
14257
|
+
"consumption": [{
|
|
14258
|
+
"id": "1",
|
|
14259
|
+
"type": "dimmer",
|
|
14260
|
+
"kwh": 0.121315
|
|
14261
|
+
}],
|
|
14262
|
+
"totals": [{
|
|
14263
|
+
"lights": 10,
|
|
14264
|
+
"climate": 10,
|
|
14265
|
+
"media": 10
|
|
14266
|
+
}],
|
|
14267
|
+
"costPerKw": 0.14
|
|
14268
|
+
});
|
|
14269
|
+
console.log(dailyShardReport);
|
|
14270
|
+
}
|
|
14271
|
+
});
|
|
14272
|
+
|
|
13848
14273
|
// src/schemas/property.json
|
|
13849
14274
|
var require_property = __commonJS({
|
|
13850
14275
|
"src/schemas/property.json"(exports, module) {
|
|
@@ -14197,6 +14622,9 @@ var require_Models = __commonJS({
|
|
|
14197
14622
|
var DiscoveredDevice = require_discoveredDevice2();
|
|
14198
14623
|
var Credential = require_credential2();
|
|
14199
14624
|
var ShortLink = require_shortLink2();
|
|
14625
|
+
var EnergyReportShard = require_energyReportShard2();
|
|
14626
|
+
var EnergyReportHourly = require_energyReportHourly2();
|
|
14627
|
+
var EnergyReportDaily = require_energyReportDaily2();
|
|
14200
14628
|
var Property = require_property2();
|
|
14201
14629
|
var Organization = require_organization2();
|
|
14202
14630
|
module.exports = {
|
|
@@ -14225,7 +14653,10 @@ var require_Models = __commonJS({
|
|
|
14225
14653
|
DiscoveredDevice,
|
|
14226
14654
|
Reservation,
|
|
14227
14655
|
Credential,
|
|
14228
|
-
ShortLink
|
|
14656
|
+
ShortLink,
|
|
14657
|
+
EnergyReportShard,
|
|
14658
|
+
EnergyReportHourly,
|
|
14659
|
+
EnergyReportDaily
|
|
14229
14660
|
};
|
|
14230
14661
|
}
|
|
14231
14662
|
});
|