First, the installation of the npm module “ewelink-api” crashed with errors, after contacting support, I was asked to install the “ewelink-api-next” module instead - this went on fine.
Now I am trying to use the example code for JS API using npm and vs code - but none of the example code works - getting errors - is there an update for the example code with reference to the “ewelink-api-next” module?
Or has anyone written an API for these modules that works?
// If your APPID was obtained when creating an application from the eWeLink developer center
// Create Authorization Login Page URL
import eWeLink from "ewelink-api-next";
const client = new eWeLink.WebAPI({
appId: "xxx",
appSecret: "xxx",
region: "eu",
requestRecord: false,
});
console.info(
client.oauth.createLoginUrl({
redirectUrl: "xxx",
grantType: "authorization_code",
state: "1",
})
);
// If your APPID is available, you can request a login interface
import eWeLink from "ewelink-api-next";
const client = new eWeLink.WebAPI({
appId: "xxx",
appSecret: "xxx",
region: "eu",
logObj: eWeLink.createLogger("eu")
});
let response = await client.user.login({ account: "xxxx", password: "xxxx", areaCode: "+33" });
console.info(JSON.stringify(response));
response = await client.device.setThingStatus({
type: 1,
id: "1000xxxxxx",
params: {
switch: "on"
}
});
console.info(JSON.stringify(response));
So is the web api functionality only available for those that pay for the Developer access?
If so $2000 is way too much for me to be involved with api’s.
I want access to the temperature every 30 seconds – so that our entire team can see the temp of the room.
You can register as a eWeLink developer, and then create a free app that can receive an app (APPID) that allows up to 50000 requests per month. It uses OAuth 2.0 to obtain login authorization, which is sufficient for individuals or initial teams.
For obtaining temperature and humidity, it is recommended to use WebSocket to passively obtain device reports, which can save requests and implement your own business logic.