@kohost/api-client 3.0.0-beta.26 → 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 +461 -45
- package/dist/cjs/SocketIoClient.js +2 -4
- package/dist/cjs/defs.js +3 -5
- package/dist/cjs/utils.js +7 -1
- package/dist/esm/Models.js +434 -2
- package/dist/esm/Models.js.map +4 -4
- package/dist/esm/utils.js +7 -1
- 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
|
@@ -134,7 +134,8 @@ var require_common = __commonJS({
|
|
|
134
134
|
"ecobee",
|
|
135
135
|
"igor",
|
|
136
136
|
"kohost-k7",
|
|
137
|
-
"kohost
|
|
137
|
+
"kohost",
|
|
138
|
+
"lg",
|
|
138
139
|
"lirc",
|
|
139
140
|
"mews",
|
|
140
141
|
"pelican-wireless",
|
|
@@ -228,6 +229,11 @@ var require_device = __commonJS({
|
|
|
228
229
|
type: "number",
|
|
229
230
|
minimum: 0,
|
|
230
231
|
maximum: 100
|
|
232
|
+
},
|
|
233
|
+
watts: {
|
|
234
|
+
type: "number",
|
|
235
|
+
minimum: 0,
|
|
236
|
+
default: 0
|
|
231
237
|
}
|
|
232
238
|
}
|
|
233
239
|
};
|
package/dist/esm/Models.js
CHANGED
|
@@ -7469,7 +7469,8 @@ var require_common = __commonJS({
|
|
|
7469
7469
|
"ecobee",
|
|
7470
7470
|
"igor",
|
|
7471
7471
|
"kohost-k7",
|
|
7472
|
-
"kohost
|
|
7472
|
+
"kohost",
|
|
7473
|
+
"lg",
|
|
7473
7474
|
"lirc",
|
|
7474
7475
|
"mews",
|
|
7475
7476
|
"pelican-wireless",
|
|
@@ -7563,6 +7564,11 @@ var require_device = __commonJS({
|
|
|
7563
7564
|
type: "number",
|
|
7564
7565
|
minimum: 0,
|
|
7565
7566
|
maximum: 100
|
|
7567
|
+
},
|
|
7568
|
+
watts: {
|
|
7569
|
+
type: "number",
|
|
7570
|
+
minimum: 0,
|
|
7571
|
+
default: 0
|
|
7566
7572
|
}
|
|
7567
7573
|
}
|
|
7568
7574
|
};
|
|
@@ -7635,6 +7641,9 @@ var require_switch = __commonJS({
|
|
|
7635
7641
|
},
|
|
7636
7642
|
systemData: {
|
|
7637
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"
|
|
7638
7647
|
}
|
|
7639
7648
|
},
|
|
7640
7649
|
additionalProperties: false,
|
|
@@ -8078,6 +8087,9 @@ var require_alarm = __commonJS({
|
|
|
8078
8087
|
items: {
|
|
8079
8088
|
$ref: "#/properties/supportedTroubles/items"
|
|
8080
8089
|
}
|
|
8090
|
+
},
|
|
8091
|
+
watts: {
|
|
8092
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
8081
8093
|
}
|
|
8082
8094
|
},
|
|
8083
8095
|
additionalProperties: false,
|
|
@@ -8162,6 +8174,9 @@ var require_dimmer = __commonJS({
|
|
|
8162
8174
|
},
|
|
8163
8175
|
systemData: {
|
|
8164
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"
|
|
8165
8180
|
}
|
|
8166
8181
|
},
|
|
8167
8182
|
additionalProperties: false,
|
|
@@ -8254,6 +8269,9 @@ var require_lock = __commonJS({
|
|
|
8254
8269
|
},
|
|
8255
8270
|
systemData: {
|
|
8256
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"
|
|
8257
8275
|
}
|
|
8258
8276
|
},
|
|
8259
8277
|
additionalProperties: false,
|
|
@@ -8401,6 +8419,9 @@ var require_thermostat = __commonJS({
|
|
|
8401
8419
|
systemData: {
|
|
8402
8420
|
$ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData",
|
|
8403
8421
|
default: {}
|
|
8422
|
+
},
|
|
8423
|
+
watts: {
|
|
8424
|
+
"#ref": "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/watts"
|
|
8404
8425
|
}
|
|
8405
8426
|
},
|
|
8406
8427
|
additionalProperties: false,
|
|
@@ -8560,6 +8581,9 @@ var require_windowCovering = __commonJS({
|
|
|
8560
8581
|
},
|
|
8561
8582
|
systemData: {
|
|
8562
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"
|
|
8563
8587
|
}
|
|
8564
8588
|
},
|
|
8565
8589
|
additionalProperties: false,
|
|
@@ -9188,6 +9212,9 @@ var require_courtesy = __commonJS({
|
|
|
9188
9212
|
},
|
|
9189
9213
|
systemData: {
|
|
9190
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"
|
|
9191
9218
|
}
|
|
9192
9219
|
},
|
|
9193
9220
|
additionalProperties: false,
|
|
@@ -9273,6 +9300,9 @@ var require_camera = __commonJS({
|
|
|
9273
9300
|
},
|
|
9274
9301
|
systemData: {
|
|
9275
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"
|
|
9276
9306
|
}
|
|
9277
9307
|
},
|
|
9278
9308
|
additionalProperties: false,
|
|
@@ -9337,6 +9367,9 @@ var require_motionSensor = __commonJS({
|
|
|
9337
9367
|
},
|
|
9338
9368
|
notification: {
|
|
9339
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"
|
|
9340
9373
|
}
|
|
9341
9374
|
},
|
|
9342
9375
|
additionalProperties: false,
|
|
@@ -9551,6 +9584,9 @@ var require_mediaSource = __commonJS({
|
|
|
9551
9584
|
},
|
|
9552
9585
|
systemData: {
|
|
9553
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"
|
|
9554
9590
|
}
|
|
9555
9591
|
},
|
|
9556
9592
|
additionalProperties: false
|
|
@@ -13523,6 +13559,9 @@ var require_gateway = __commonJS({
|
|
|
13523
13559
|
},
|
|
13524
13560
|
driver: {
|
|
13525
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"
|
|
13526
13565
|
}
|
|
13527
13566
|
},
|
|
13528
13567
|
additionalProperties: false,
|
|
@@ -13844,6 +13883,393 @@ var require_shortLink2 = __commonJS({
|
|
|
13844
13883
|
}
|
|
13845
13884
|
});
|
|
13846
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
|
+
|
|
13847
14273
|
// src/schemas/property.json
|
|
13848
14274
|
var require_property = __commonJS({
|
|
13849
14275
|
"src/schemas/property.json"(exports, module) {
|
|
@@ -14196,6 +14622,9 @@ var require_Models = __commonJS({
|
|
|
14196
14622
|
var DiscoveredDevice = require_discoveredDevice2();
|
|
14197
14623
|
var Credential = require_credential2();
|
|
14198
14624
|
var ShortLink = require_shortLink2();
|
|
14625
|
+
var EnergyReportShard = require_energyReportShard2();
|
|
14626
|
+
var EnergyReportHourly = require_energyReportHourly2();
|
|
14627
|
+
var EnergyReportDaily = require_energyReportDaily2();
|
|
14199
14628
|
var Property = require_property2();
|
|
14200
14629
|
var Organization = require_organization2();
|
|
14201
14630
|
module.exports = {
|
|
@@ -14224,7 +14653,10 @@ var require_Models = __commonJS({
|
|
|
14224
14653
|
DiscoveredDevice,
|
|
14225
14654
|
Reservation,
|
|
14226
14655
|
Credential,
|
|
14227
|
-
ShortLink
|
|
14656
|
+
ShortLink,
|
|
14657
|
+
EnergyReportShard,
|
|
14658
|
+
EnergyReportHourly,
|
|
14659
|
+
EnergyReportDaily
|
|
14228
14660
|
};
|
|
14229
14661
|
}
|
|
14230
14662
|
});
|