Here's the problem, I have an event monitor listening for switch changes and it keeps the connection open using the stay alive pings. If I use getWSDevicePowerState() or setWSDevicePowerState() this cause the ping to fail and no longer receive any device updates.
So if I have the event logger running, eg:
// call openWebSocket method with a callback as argument
const socket = await connection.openWebSocket(async data => {
// data is the message from eWeLink
console.log(data)
});
And use getWSDevicePowerState() or setWSDevicePowerState() it will close the event logger websocket and there's no error handling to detect / reconnect.
3|events | Error: Can't send data because WebSocket is not opened.
3|events | at exports.throwIf (/home/sonoff/node_modules/websocket-as-promised/src/utils.js:4:11)
3|events | at WebSocketAsPromised.send (/home/sonoff/node_modules/websocket-as-promised/src/index.js:248:5)
3|events | at Timeout.setInterval [as _onTimeout] (/home/sonoff/node_modules/ewelink-api/src/mixins/openWebSocket.js:39:17)
3|events | at ontimeout (timers.js:436:11)
3|events | at tryOnTimeout (timers.js:300:5)
3|events | at listOnTimeout (timers.js:263:5)
3|events | at Timer.processTimers (timers.js:223:10)
Idea, can we somehow use the open connection and just send the getWSDevicePowerState() or setWSDevicePowerState() over it?
Here's the problem, I have an event monitor listening for switch changes and it keeps the connection open using the stay alive pings. If I use getWSDevicePowerState() or setWSDevicePowerState() this cause the ping to fail and no longer receive any device updates.
So if I have the event logger running, eg:
And use getWSDevicePowerState() or setWSDevicePowerState() it will close the event logger websocket and there's no error handling to detect / reconnect.
Idea, can we somehow use the open connection and just send the getWSDevicePowerState() or setWSDevicePowerState() over it?