GithubHelp home page GithubHelp logo

Comments (6)

ttz642 avatar ttz642 commented on September 22, 2024

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.

ttz642 avatar ttz642 commented on September 22, 2024

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.

ttz642 avatar ttz642 commented on September 22, 2024

The definition for getRegion is missing from index.d.ts

Closed #34

from ewelink-api.

ttz642 avatar ttz642 commented on September 22, 2024

Class Instantiation (see #31 for background).

	const atConnection = new ewelink({
		at: login.at,
		apiKey: login.user.apikey,
		region: login.region
	});

from ewelink-api.

peperoca116 avatar peperoca116 commented on September 22, 2024

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.

ttz642 avatar ttz642 commented on September 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.