dt-common-device 1.2.10 → 1.2.12
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/device/local/events/EventHandler.js +14 -14
- package/dist/device/local/events/Events.d.ts +53 -20
- package/dist/device/local/events/Events.js +54 -21
- package/dist/device/local/events/index.d.ts +2 -0
- package/dist/device/local/events/index.js +7 -0
- package/dist/device/local/services/Device.service.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
- package/src/device/local/events/EventHandler.ts +19 -17
- package/src/device/local/events/Events.ts +54 -23
- package/src/device/local/events/index.ts +2 -0
- package/src/device/local/services/Device.service.ts +1 -1
- package/src/index.ts +1 -0
|
@@ -9,9 +9,9 @@ class EventHandler {
|
|
|
9
9
|
this.source = "dt-common-device";
|
|
10
10
|
}
|
|
11
11
|
async onDeviceCreate(body) {
|
|
12
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.
|
|
12
|
+
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.CREATED, body, this.source);
|
|
13
13
|
const payload = {
|
|
14
|
-
eventType: Events_1.
|
|
14
|
+
eventType: Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.CREATED,
|
|
15
15
|
properties: {
|
|
16
16
|
...body,
|
|
17
17
|
},
|
|
@@ -19,9 +19,9 @@ class EventHandler {
|
|
|
19
19
|
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
20
20
|
}
|
|
21
21
|
async onDeviceUpdate(deviceId, body) {
|
|
22
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.
|
|
22
|
+
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.UPDATED, { deviceId, body }, this.source);
|
|
23
23
|
const payload = {
|
|
24
|
-
eventType: Events_1.
|
|
24
|
+
eventType: Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.UPDATED,
|
|
25
25
|
properties: {
|
|
26
26
|
...body,
|
|
27
27
|
},
|
|
@@ -29,9 +29,9 @@ class EventHandler {
|
|
|
29
29
|
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
30
30
|
}
|
|
31
31
|
async onDeviceDelete(deviceId) {
|
|
32
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.
|
|
32
|
+
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.DELETED, { deviceId }, this.source);
|
|
33
33
|
const payload = {
|
|
34
|
-
eventType: Events_1.
|
|
34
|
+
eventType: Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.DELETED,
|
|
35
35
|
properties: {
|
|
36
36
|
deviceId,
|
|
37
37
|
},
|
|
@@ -39,9 +39,9 @@ class EventHandler {
|
|
|
39
39
|
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
40
40
|
}
|
|
41
41
|
async onStateChange(deviceId, state) {
|
|
42
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.
|
|
42
|
+
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.STATE.SET, { deviceId, state }, this.source);
|
|
43
43
|
const payload = {
|
|
44
|
-
eventType: Events_1.
|
|
44
|
+
eventType: Events_1.DT_EVENT_TYPES.DEVICE.STATE.SET,
|
|
45
45
|
properties: {
|
|
46
46
|
deviceId,
|
|
47
47
|
state,
|
|
@@ -50,9 +50,9 @@ class EventHandler {
|
|
|
50
50
|
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
51
51
|
}
|
|
52
52
|
async onStatusChange(deviceId, status) {
|
|
53
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.
|
|
53
|
+
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.STATUS.SET, { deviceId, status }, this.source);
|
|
54
54
|
const payload = {
|
|
55
|
-
eventType: Events_1.
|
|
55
|
+
eventType: Events_1.DT_EVENT_TYPES.DEVICE.STATUS.SET,
|
|
56
56
|
properties: {
|
|
57
57
|
deviceId,
|
|
58
58
|
status,
|
|
@@ -61,9 +61,9 @@ class EventHandler {
|
|
|
61
61
|
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
62
62
|
}
|
|
63
63
|
async onBatteryLevelChange(deviceId, batteryLevel) {
|
|
64
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.
|
|
64
|
+
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.BATTERY.SET, { deviceId, batteryLevel }, this.source);
|
|
65
65
|
const payload = {
|
|
66
|
-
eventType: Events_1.
|
|
66
|
+
eventType: Events_1.DT_EVENT_TYPES.DEVICE.BATTERY.SET,
|
|
67
67
|
properties: {
|
|
68
68
|
deviceId,
|
|
69
69
|
batteryLevel,
|
|
@@ -72,9 +72,9 @@ class EventHandler {
|
|
|
72
72
|
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
73
73
|
}
|
|
74
74
|
async onDeviceMetaChange(deviceId, metaData) {
|
|
75
|
-
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.
|
|
75
|
+
await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.META_DATA.SET, { deviceId, metaData }, this.source);
|
|
76
76
|
const payload = {
|
|
77
|
-
eventType: Events_1.
|
|
77
|
+
eventType: Events_1.DT_EVENT_TYPES.DEVICE.META_DATA.SET,
|
|
78
78
|
properties: {
|
|
79
79
|
deviceId,
|
|
80
80
|
metaData,
|
|
@@ -1,21 +1,54 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
export declare const DT_EVENT_TYPES: {
|
|
2
|
+
DEVICE: {
|
|
3
|
+
DEVICE: {
|
|
4
|
+
CREATED: string;
|
|
5
|
+
UPDATED: string;
|
|
6
|
+
DELETED: string;
|
|
7
|
+
};
|
|
8
|
+
STATE: {
|
|
9
|
+
SET: string;
|
|
10
|
+
UNKNOWN: string;
|
|
11
|
+
UPDATED: string;
|
|
12
|
+
CHANGED: string;
|
|
13
|
+
};
|
|
14
|
+
STATUS: {
|
|
15
|
+
SET: string;
|
|
16
|
+
ONLINE: string;
|
|
17
|
+
OFFLINE: string;
|
|
18
|
+
UNKNOWN: string;
|
|
19
|
+
UPDATED: string;
|
|
20
|
+
CHANGED: string;
|
|
21
|
+
};
|
|
22
|
+
BATTERY: {
|
|
23
|
+
SET: string;
|
|
24
|
+
UNKNOWN: string;
|
|
25
|
+
LOW: string;
|
|
26
|
+
CRITICAL: string;
|
|
27
|
+
UPDATED: string;
|
|
28
|
+
CHANGED: string;
|
|
29
|
+
};
|
|
30
|
+
META_DATA: {
|
|
31
|
+
SET: string;
|
|
32
|
+
UPDATED: string;
|
|
33
|
+
CHANGED: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
CONNECTION: {
|
|
37
|
+
CONNECTION: {
|
|
38
|
+
CREATED: string;
|
|
39
|
+
UPDATED: string;
|
|
40
|
+
DELETED: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
PROPERTY: {
|
|
44
|
+
PROPERTY: {
|
|
45
|
+
CREATED: string;
|
|
46
|
+
UPDATED: string;
|
|
47
|
+
DELETED: string;
|
|
48
|
+
};
|
|
49
|
+
PREFERENCES: {
|
|
50
|
+
UPDATED: string;
|
|
51
|
+
CREATED: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
21
54
|
};
|
|
@@ -1,24 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
3
|
+
exports.DT_EVENT_TYPES = void 0;
|
|
4
|
+
exports.DT_EVENT_TYPES = {
|
|
5
|
+
DEVICE: {
|
|
6
|
+
DEVICE: {
|
|
7
|
+
CREATED: "device.device.created",
|
|
8
|
+
UPDATED: "device.device.updated",
|
|
9
|
+
DELETED: "device.device.deleted",
|
|
10
|
+
},
|
|
11
|
+
STATE: {
|
|
12
|
+
SET: "device.state.set",
|
|
13
|
+
UNKNOWN: "device.state.unknown",
|
|
14
|
+
UPDATED: "device.state.updated",
|
|
15
|
+
CHANGED: "device.state.changed",
|
|
16
|
+
},
|
|
17
|
+
STATUS: {
|
|
18
|
+
SET: "device.status.set",
|
|
19
|
+
ONLINE: "device.status.online",
|
|
20
|
+
OFFLINE: "device.status.offline",
|
|
21
|
+
UNKNOWN: "device.status.unknown",
|
|
22
|
+
UPDATED: "device.status.updated",
|
|
23
|
+
CHANGED: "device.status.changed",
|
|
24
|
+
},
|
|
25
|
+
BATTERY: {
|
|
26
|
+
SET: "device.battery.set",
|
|
27
|
+
UNKNOWN: "device.battery.unknown",
|
|
28
|
+
LOW: "device.battery.low",
|
|
29
|
+
CRITICAL: "device.battery.critical",
|
|
30
|
+
UPDATED: "device.battery.updated",
|
|
31
|
+
CHANGED: "device.battery.changed",
|
|
32
|
+
},
|
|
33
|
+
META_DATA: {
|
|
34
|
+
SET: "device.metaData.set",
|
|
35
|
+
UPDATED: "device.metaData.updated",
|
|
36
|
+
CHANGED: "device.metaData.changed",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
CONNECTION: {
|
|
40
|
+
CONNECTION: {
|
|
41
|
+
CREATED: "connection.connection.created",
|
|
42
|
+
UPDATED: "connection.connection.updated",
|
|
43
|
+
DELETED: "connection.connection.deleted",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
PROPERTY: {
|
|
47
|
+
PROPERTY: {
|
|
48
|
+
CREATED: "property.property.created",
|
|
49
|
+
UPDATED: "property.property.updated",
|
|
50
|
+
DELETED: "property.property.deleted",
|
|
51
|
+
},
|
|
52
|
+
PREFERENCES: {
|
|
53
|
+
UPDATED: "property.preferences.updated",
|
|
54
|
+
CREATED: "property.preferences.created",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
24
57
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventHandler = exports.DT_EVENT_TYPES = void 0;
|
|
4
|
+
var Events_1 = require("./Events");
|
|
5
|
+
Object.defineProperty(exports, "DT_EVENT_TYPES", { enumerable: true, get: function () { return Events_1.DT_EVENT_TYPES; } });
|
|
6
|
+
var EventHandler_1 = require("./EventHandler");
|
|
7
|
+
Object.defineProperty(exports, "EventHandler", { enumerable: true, get: function () { return EventHandler_1.EventHandler; } });
|
|
@@ -68,7 +68,7 @@ class LocalDeviceService {
|
|
|
68
68
|
throw new Error("Device ID and new state are required");
|
|
69
69
|
}
|
|
70
70
|
// If old state and new state are different
|
|
71
|
-
const oldState = (await this.getState(deviceId))?.data?.state
|
|
71
|
+
const oldState = (await this.getState(deviceId))?.data?.state ?? {};
|
|
72
72
|
const changedKeys = Object.keys(newState).filter((key) => !(0, lodash_1.isEqual)(oldState[key], newState[key]));
|
|
73
73
|
if (changedKeys.length > 0) {
|
|
74
74
|
return await this.eventHandler.onStateChange(deviceId, newState);
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { CloudDevice, CloudDeviceService, DeviceFactory, } from "./device/cloud/
|
|
|
2
2
|
export { LocalDeviceService, LocalHubService, LocalConnectionService, LocalPropertyService, LocalScheduleService, } from "./device/local/services";
|
|
3
3
|
export * from "./device/cloud/interfaces";
|
|
4
4
|
export * from "./device/local/interfaces";
|
|
5
|
+
export * from "./device/local/events";
|
|
5
6
|
export { initialize, getConfig } from "./config/config";
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ Object.defineProperty(exports, "LocalScheduleService", { enumerable: true, get:
|
|
|
30
30
|
__exportStar(require("./device/cloud/interfaces"), exports);
|
|
31
31
|
// Local exports
|
|
32
32
|
__exportStar(require("./device/local/interfaces"), exports);
|
|
33
|
+
__exportStar(require("./device/local/events"), exports);
|
|
33
34
|
//initialize export
|
|
34
35
|
var config_1 = require("./config/config");
|
|
35
36
|
Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return config_1.initialize; } });
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { eventDispatcher } from "dt-pub-sub";
|
|
2
2
|
import { publishAudit } from "dt-audit-library";
|
|
3
|
-
import {
|
|
3
|
+
import { DT_EVENT_TYPES } from "./Events";
|
|
4
4
|
|
|
5
5
|
export class EventHandler {
|
|
6
|
-
private readonly source
|
|
7
|
-
constructor() {
|
|
6
|
+
private readonly source: string;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.source = "dt-common-device";
|
|
9
|
+
}
|
|
8
10
|
|
|
9
11
|
async onDeviceCreate(body: any) {
|
|
10
12
|
await eventDispatcher.publishEvent(
|
|
11
|
-
|
|
13
|
+
DT_EVENT_TYPES.DEVICE.DEVICE.CREATED,
|
|
12
14
|
body,
|
|
13
15
|
this.source
|
|
14
16
|
);
|
|
15
17
|
const payload = {
|
|
16
|
-
eventType:
|
|
18
|
+
eventType: DT_EVENT_TYPES.DEVICE.DEVICE.CREATED,
|
|
17
19
|
properties: {
|
|
18
20
|
...body,
|
|
19
21
|
},
|
|
@@ -23,12 +25,12 @@ export class EventHandler {
|
|
|
23
25
|
|
|
24
26
|
async onDeviceUpdate(deviceId: string, body: any) {
|
|
25
27
|
await eventDispatcher.publishEvent(
|
|
26
|
-
|
|
28
|
+
DT_EVENT_TYPES.DEVICE.DEVICE.UPDATED,
|
|
27
29
|
{ deviceId, body },
|
|
28
30
|
this.source
|
|
29
31
|
);
|
|
30
32
|
const payload = {
|
|
31
|
-
eventType:
|
|
33
|
+
eventType: DT_EVENT_TYPES.DEVICE.DEVICE.UPDATED,
|
|
32
34
|
properties: {
|
|
33
35
|
...body,
|
|
34
36
|
},
|
|
@@ -38,12 +40,12 @@ export class EventHandler {
|
|
|
38
40
|
|
|
39
41
|
async onDeviceDelete(deviceId: string) {
|
|
40
42
|
await eventDispatcher.publishEvent(
|
|
41
|
-
|
|
43
|
+
DT_EVENT_TYPES.DEVICE.DEVICE.DELETED,
|
|
42
44
|
{ deviceId },
|
|
43
45
|
this.source
|
|
44
46
|
);
|
|
45
47
|
const payload = {
|
|
46
|
-
eventType:
|
|
48
|
+
eventType: DT_EVENT_TYPES.DEVICE.DEVICE.DELETED,
|
|
47
49
|
properties: {
|
|
48
50
|
deviceId,
|
|
49
51
|
},
|
|
@@ -53,12 +55,12 @@ export class EventHandler {
|
|
|
53
55
|
|
|
54
56
|
async onStateChange(deviceId: string, state: any) {
|
|
55
57
|
await eventDispatcher.publishEvent(
|
|
56
|
-
|
|
58
|
+
DT_EVENT_TYPES.DEVICE.STATE.SET,
|
|
57
59
|
{ deviceId, state },
|
|
58
60
|
this.source
|
|
59
61
|
);
|
|
60
62
|
const payload = {
|
|
61
|
-
eventType:
|
|
63
|
+
eventType: DT_EVENT_TYPES.DEVICE.STATE.SET,
|
|
62
64
|
properties: {
|
|
63
65
|
deviceId,
|
|
64
66
|
state,
|
|
@@ -69,12 +71,12 @@ export class EventHandler {
|
|
|
69
71
|
|
|
70
72
|
async onStatusChange(deviceId: string, status: any) {
|
|
71
73
|
await eventDispatcher.publishEvent(
|
|
72
|
-
|
|
74
|
+
DT_EVENT_TYPES.DEVICE.STATUS.SET,
|
|
73
75
|
{ deviceId, status },
|
|
74
76
|
this.source
|
|
75
77
|
);
|
|
76
78
|
const payload = {
|
|
77
|
-
eventType:
|
|
79
|
+
eventType: DT_EVENT_TYPES.DEVICE.STATUS.SET,
|
|
78
80
|
properties: {
|
|
79
81
|
deviceId,
|
|
80
82
|
status,
|
|
@@ -85,12 +87,12 @@ export class EventHandler {
|
|
|
85
87
|
|
|
86
88
|
async onBatteryLevelChange(deviceId: string, batteryLevel: number) {
|
|
87
89
|
await eventDispatcher.publishEvent(
|
|
88
|
-
|
|
90
|
+
DT_EVENT_TYPES.DEVICE.BATTERY.SET,
|
|
89
91
|
{ deviceId, batteryLevel },
|
|
90
92
|
this.source
|
|
91
93
|
);
|
|
92
94
|
const payload = {
|
|
93
|
-
eventType:
|
|
95
|
+
eventType: DT_EVENT_TYPES.DEVICE.BATTERY.SET,
|
|
94
96
|
properties: {
|
|
95
97
|
deviceId,
|
|
96
98
|
batteryLevel,
|
|
@@ -101,12 +103,12 @@ export class EventHandler {
|
|
|
101
103
|
|
|
102
104
|
async onDeviceMetaChange(deviceId: string, metaData: Record<string, any>) {
|
|
103
105
|
await eventDispatcher.publishEvent(
|
|
104
|
-
|
|
106
|
+
DT_EVENT_TYPES.DEVICE.META_DATA.SET,
|
|
105
107
|
{ deviceId, metaData },
|
|
106
108
|
this.source
|
|
107
109
|
);
|
|
108
110
|
const payload = {
|
|
109
|
-
eventType:
|
|
111
|
+
eventType: DT_EVENT_TYPES.DEVICE.META_DATA.SET,
|
|
110
112
|
properties: {
|
|
111
113
|
deviceId,
|
|
112
114
|
metaData,
|
|
@@ -1,23 +1,54 @@
|
|
|
1
|
-
export const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
export const DT_EVENT_TYPES = {
|
|
2
|
+
DEVICE: {
|
|
3
|
+
DEVICE: {
|
|
4
|
+
CREATED: "device.device.created",
|
|
5
|
+
UPDATED: "device.device.updated",
|
|
6
|
+
DELETED: "device.device.deleted",
|
|
7
|
+
},
|
|
8
|
+
STATE: {
|
|
9
|
+
SET: "device.state.set",
|
|
10
|
+
UNKNOWN: "device.state.unknown",
|
|
11
|
+
UPDATED: "device.state.updated",
|
|
12
|
+
CHANGED: "device.state.changed",
|
|
13
|
+
},
|
|
14
|
+
STATUS: {
|
|
15
|
+
SET: "device.status.set",
|
|
16
|
+
ONLINE: "device.status.online",
|
|
17
|
+
OFFLINE: "device.status.offline",
|
|
18
|
+
UNKNOWN: "device.status.unknown",
|
|
19
|
+
UPDATED: "device.status.updated",
|
|
20
|
+
CHANGED: "device.status.changed",
|
|
21
|
+
},
|
|
22
|
+
BATTERY: {
|
|
23
|
+
SET: "device.battery.set",
|
|
24
|
+
UNKNOWN: "device.battery.unknown",
|
|
25
|
+
LOW: "device.battery.low",
|
|
26
|
+
CRITICAL: "device.battery.critical",
|
|
27
|
+
UPDATED: "device.battery.updated",
|
|
28
|
+
CHANGED: "device.battery.changed",
|
|
29
|
+
},
|
|
30
|
+
META_DATA: {
|
|
31
|
+
SET: "device.metaData.set",
|
|
32
|
+
UPDATED: "device.metaData.updated",
|
|
33
|
+
CHANGED: "device.metaData.changed",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
CONNECTION: {
|
|
37
|
+
CONNECTION: {
|
|
38
|
+
CREATED: "connection.connection.created",
|
|
39
|
+
UPDATED: "connection.connection.updated",
|
|
40
|
+
DELETED: "connection.connection.deleted",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
PROPERTY: {
|
|
44
|
+
PROPERTY: {
|
|
45
|
+
CREATED: "property.property.created",
|
|
46
|
+
UPDATED: "property.property.updated",
|
|
47
|
+
DELETED: "property.property.deleted",
|
|
48
|
+
},
|
|
49
|
+
PREFERENCES: {
|
|
50
|
+
UPDATED: "property.preferences.updated",
|
|
51
|
+
CREATED: "property.preferences.created",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
@@ -100,7 +100,7 @@ export class LocalDeviceService {
|
|
|
100
100
|
throw new Error("Device ID and new state are required");
|
|
101
101
|
}
|
|
102
102
|
// If old state and new state are different
|
|
103
|
-
const oldState = (await this.getState(deviceId))?.data?.state
|
|
103
|
+
const oldState = (await this.getState(deviceId))?.data?.state ?? {};
|
|
104
104
|
const changedKeys = Object.keys(newState).filter(
|
|
105
105
|
(key) => !isEqual(oldState[key], newState[key])
|
|
106
106
|
);
|
package/src/index.ts
CHANGED