sinricpro 2.11.2 → 2.11.4

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.
@@ -58,14 +58,17 @@ const eventNames = {
58
58
  targetTemperature: "targetTemperature"
59
59
  };
60
60
 
61
+ function isValidEventAction(action) {
62
+ return Object.entries(eventNames).find(i => i[1] === action);
63
+ }
61
64
 
62
- const getJson = (client, eventName, deviceId, value) => {
65
+ const getEvent = (client, action, deviceId, value) => {
63
66
  const header = {
64
67
  payloadVersion: 2,
65
68
  signatureVersion: 1,
66
69
  };
67
70
  const payload = {
68
- action: eventName,
71
+ action,
69
72
  cause: {
70
73
  type: "PHYSICAL_INTERACTION",
71
74
  },
@@ -82,11 +85,11 @@ const getJson = (client, eventName, deviceId, value) => {
82
85
  return { header, payload, signature };
83
86
  };
84
87
 
85
- const raiseEvent = async (client, eventName, deviceId, value) => {
86
- if (Object.hasOwn(eventNames, eventName)) {
88
+ const raiseEvent = async (client, action, deviceId, value) => {
89
+ if (isValidEventAction(action)) {
87
90
  try {
88
91
  await burstyLimiter.consume("queue");
89
- const request = JSON.stringify(getJson(client, eventName, deviceId, value));
92
+ const request = JSON.stringify(getEvent(client, action, deviceId, value));
90
93
  if (process.env.SR_DEBUG) console.log(">> %s", request);
91
94
  client.send(request);
92
95
  } catch (rlRejected) {
package/lib/sinrcpro.js CHANGED
@@ -15,7 +15,7 @@ const sdkVersion = require('./../package.json').version;
15
15
 
16
16
  class SinricPro extends Websocket {
17
17
  constructor(appkey, deviceids, secretKey, restoreStates) {
18
- super("wss://testws.sinric.pro", {
18
+ super("wss://ws.sinric.pro", {
19
19
  headers: {
20
20
  appkey,
21
21
  deviceids: deviceids.join(';'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinricpro",
3
- "version": "2.11.2",
3
+ "version": "2.11.4",
4
4
  "description": "Sinric Pro Nodejs SDK",
5
5
  "main": "index.js",
6
6
  "repository": {