Comments (6)
openWebSocket
Make sure .close()
is called before application terminates otherwise restarting application may not connect 1st time.
In main application I have:
var socket; //define outside of async function to allow access as required
process.on("SIGINT", () => {
console.log(" - Caught SIGINT. Exiting in 3 seconds.");
console.log("Closing WebSocket...");
var cls = socket.close();
setTimeout(() => {
process.exit(0);
}, 3000);
});
So if the process is terminated it will close the web socket. Since adding this the app has gracefully closed the socket every time and always restarts 1st time.
var date = new Date();
(async () {
// login credentials required BEFORE using openWebSocket()
if(vers < "1.10.0"){//pseudo code !
const login = await connection.login();
}else{
const login = await connection.getCredentials(); //.login() DEPRECATED
}
socket = await connection.openWebSocket(async data => {
if(data == "pong"){//can just ignore of for debug print date & time to console
date = new Date();
console.log("keepalive received at:",date.toUTCString());
}else{//process event...
console.log("openWebSocket data::",JSON.stringify(data,null,4)); //if(DEBUG) when coded !
}
});
})();
Perhaps in release 1.10.0 the pong will be eaten in openWebSocketMixin.js ?
from ewelink-api.
QUESTION on documentation strategy
Can documentation from external site be placed in the README.md file so documentation can be updated as part of new release / branch?
I've included a PR in Release_1.10.0 to update README.md with the text from your documentation site.
from ewelink-api.
The definition for getRegion is missing from index.d.ts
Closed #34
from ewelink-api.
Class Instantiation (see #31 for background).
const atConnection = new ewelink({
at: login.at,
apiKey: login.user.apikey,
region: login.region
});
from ewelink-api.
Hi, the api works great! No issues found!
I will like to know if there is an "easy" way to get the following parameters from the power measuring devices: 1. Voltage, 2. Current, 3. Power
I have a turn around where i open a socket, ask for the device status and after that the socket starts receiving data (V / C / P) when the sonoff sends information. This is ok. I was just wondering if there is an easy way to get this data with a special request/command. E.g.
Awesome work. Thanks in advance for your response.
from ewelink-api.
Need to include more details about the region in the class instantiation, see issues #53, #27, #47
It is causing many issues and would be best dealt with by more details in the class instantiation.
from ewelink-api.
Related Issues (20)
- { error: 500, msg: 'SyntaxError: Unexpected token < in JSON at position 0' } HOT 1
- New and Simple REST API with Ready Scripts
- Error 401: Wrong account or password HOT 21
- ewelink
- Unable to install on Raspberry Pi
- THR316 doesn't update
- Unable to use power consumption with sonoff POW Elite HOT 6
- Get Voltage and current on POWR2 device HOT 2
- CoolkIt: Announcement regarding the expiration of the APPID referenced in this project and the cessation of maintenance of the v1 interface, suggesting migration HOT 7
- Error 401: Wrong account or password -- again HOT 54
- Error: 406 { error: 406, msg: 'Authentication failed' } HOT 21
- Support for changing the network indicator led?
- Is There Any PHP Version HOT 1
- error: 401, msg: 'Wrong account or password'
- Sonoff Dual R3 - Power Consumption Issue HOT 1
- Retrieve Room Names
- Reading the list of shared devices
- Switch to manual or automatic mode
- websocket closes unexpectedly, causing Node Red to crash
- { error: 406, msg: 'Authentication failed' } I am using right email and password HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ewelink-api.