sinricpro 2.11.4 → 2.12.1
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/CHANGELOG.md +11 -0
- package/lib/events/event_handler.js +7 -2
- package/lib/sinrcpro.js +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -32,3 +32,14 @@
|
|
|
32
32
|
|
|
33
33
|
### Features
|
|
34
34
|
* fix: adjustTargetTemperature response format.
|
|
35
|
+
|
|
36
|
+
## [2.11.4]
|
|
37
|
+
|
|
38
|
+
### Features
|
|
39
|
+
* fix: power on, off event
|
|
40
|
+
|
|
41
|
+
## [2.12.1]
|
|
42
|
+
|
|
43
|
+
### Features
|
|
44
|
+
* fix: error message when sending an event while connection not established yet
|
|
45
|
+
* feat: add onConnected callback
|
|
@@ -86,6 +86,11 @@ const getEvent = (client, action, deviceId, value) => {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
const raiseEvent = async (client, action, deviceId, value) => {
|
|
89
|
+
if(client.readyState !== 1) {
|
|
90
|
+
console.error("Sending aborted! The connection has not been established yet. Try again later!");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
89
94
|
if (isValidEventAction(action)) {
|
|
90
95
|
try {
|
|
91
96
|
await burstyLimiter.consume("queue");
|
|
@@ -93,10 +98,10 @@ const raiseEvent = async (client, action, deviceId, value) => {
|
|
|
93
98
|
if (process.env.SR_DEBUG) console.log(">> %s", request);
|
|
94
99
|
client.send(request);
|
|
95
100
|
} catch (rlRejected) {
|
|
96
|
-
console.
|
|
101
|
+
console.error("Too many events!");
|
|
97
102
|
}
|
|
98
103
|
} else {
|
|
99
|
-
console.
|
|
104
|
+
console.error(`Invalid Event: ${eventName}`);
|
|
100
105
|
}
|
|
101
106
|
};
|
|
102
107
|
|
package/lib/sinrcpro.js
CHANGED
|
@@ -38,7 +38,9 @@ class SinricPro extends Websocket {
|
|
|
38
38
|
|
|
39
39
|
const startSinricPro = (client, callbacks) => {
|
|
40
40
|
client.on('open', () => {
|
|
41
|
-
|
|
41
|
+
if (callbacks.onConnected) {
|
|
42
|
+
callbacks.onConnected();
|
|
43
|
+
}
|
|
42
44
|
});
|
|
43
45
|
|
|
44
46
|
client.on("message", (data) => {
|