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 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.log("Too many events!");
101
+ console.error("Too many events!");
97
102
  }
98
103
  } else {
99
- console.log(`Invalid Event: ${eventName}`);
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
- console.log('Connected to Sinric Pro');
41
+ if (callbacks.onConnected) {
42
+ callbacks.onConnected();
43
+ }
42
44
  });
43
45
 
44
46
  client.on("message", (data) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinricpro",
3
- "version": "2.11.4",
3
+ "version": "2.12.1",
4
4
  "description": "Sinric Pro Nodejs SDK",
5
5
  "main": "index.js",
6
6
  "repository": {