The ewelink-api library provides a programmatic interface for interacting with eWeLink-compatible smart home devices, such as Sonoff products, from Node.js environments. It supports both cloud-based interaction (requiring internet access) and ZeroConf (LAN mode) for local control without an internet connection. The current stable version is 3.1.1, with releases occurring on a moderate, irregular cadence, focusing on bug fixes, dependency updates, and feature enhancements like improved error handling and new device control methods. Key differentiators include its multi-environment compatibility (Node.js, browsers, serverless), robust device state management, and power consumption monitoring for compatible devices.
npm install ewelink-apiVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing the API, logging in, finding a specific device, and toggling its power state using the recommended WebSocket method.
Update your login credentials to use a phone number and password combination when initializing the `EwelinkApi` class. Refer to the official documentation for specific parameter names.
Upgrade to version 3.1.0 or later and utilize the new feature that allows custom `APP_ID` and `APP_SECRET` to be passed during class initialization, or ensure your local environment uses the current correct values.
Review any custom error handling logic you may have implemented that depends on specific error object properties from previous versions. Standard error handling should remain compatible.
Prioritize `setWSDevicePowerState(deviceId, state)` for controlling device power states. Ensure your eWeLink account and devices support WebSocket communication.
Double-check your `email` (or `phoneNumber`), `password`, and `region` parameters. Ensure the region corresponds to your eWeLink account server (e.g., 'us', 'eu', 'as').
Change your import statement to `import EwelinkApi from 'ewelink-api';` for ES Modules or `const EwelinkApi = require('ewelink-api');` for CommonJS.Verify the `DEVICE_ID` is correct. Ensure the device is powered on and connected to Wi-Fi. If using LAN mode, confirm your network setup allows local communication with the device.
No dependency data recorded yet.