Homebridge plugin to control Sonoff relays with OEM firmware. It uses the same API as the iOS app to communicate with your devices.
The platform will dynamically add/remove devices based on what is configured in your eWeLink account.
It has been tested with the Sonoff basic relays. I have performed testing with up to two relays associated to my account.
The plugin will only support one eWeLink account.
It is possible to continue to use the OEM functionality (eWeLink app, Google Home integration); this plugin requires no modification to the relay's firmware.
This is a fork of homebridge-ewelink, which is not being actively updated. There is another package named homebridge-ewelin-plus which is not updated for 6 months at the time of writing. The name is inspired by Apple's naming convention.
This fork have the following notable changes / improvements:
- Support login with phone number / email and password, which save your time from obtaining the authentication token with Charles once in a while.
- Support sending heartbeat on the WebSocket connection, which greatly reduce the interval of reconnects, hence better stability.
- Support obtaining the correct API / WebSocket API host automatically, so you don't need to obtain these information with Charles.
- Support for groups to simulate accessory. Currrently only blind (WindowCovering) is supported.
The code is of suboptimal quality. It was a quick-and-dirty plugin; feel free to contribute & improve.
Steps to install / configure
Assuming that you've already downloaded the eWeLink app on your iOS device & have configured it:
- Install the plugin
sudo npm -g install homebridge-ewelink-max
- Add to the platforms section of config.json.
countryCode- The country code of your ewelink account without + prefix, see list of country codes on Wikipedia
phoneNumber- The login phone number of your ewelink account, do not include this if you login with email
password- Your ewelink account login password
imei- This can be any valid UUID, get one with an online generator
- Restart Homebridge
If you use email login, the platform section should look like this:
You can group channels of multi-switch model to simulate another accessory instead of having each switch separately. Currently, only blind (WindowCovering) is supported.
(Tested with Sonoff Dual) Simulate dual motors blind, one to move up and other to move down, without start or end detector. The duration of move is calculed from the up/down time. Handle realtime response when setting position other than Open or Close. Also responding to event from API, so you can use Home or eWelink App and have up-to-date state. The device is automatically reconfigured to turn off all options (power-on response, inching, ...) including disable Interlock that is incompatible with the behavior of this group.
To improve: 4 channels models can only use 2 channels, others will be disabled.
- type : blind
- deviceId : Device ID from eWelink app
- relay_up: Relay number for the UP motor
- relay_down: Relay number for the DOWN motor
- time_up: Total time in second from complete closing to full opening.
- time_down: Total time in second from complete opening to full closing.
- handle_api_changes: In case you don't want group respond to eWeLink App changes. Default true.
- Please refer to homebridge-sonoff-stateful-blind project for explanations of the last two options.
A note on login session
An authentication token is generated every time your device's app logs in to the eWeLink service.
You can only have one authentication token per user account.
Therefore if you use the HomeKit app and eWeLink app at the same time, they will fight each other for the login session. They should both work individually. You can leave homebridge running when using the eWeLink app.
Use another login to avoid being logged off from the eWeLink app
- Create another account
- Then log in with the new account on another mobile device (you have to keep both accounts connected and with eWeLink on the screen).
- Go to your eWeLink, select your Sonoff device and share it with the other account.
- A popup should appear on the other mobile device, accept it.
- Use the second account as your plugin login (and never use this account on eWeLink anymore to avoid being logged off)
- Be happy and never get a "session expired" message again.
Each account is suitable for the plug-in, just make sure to use each once (one per mobile device / homebridge).
I've attempted to make the logging as useful as possible. If you have any suggestions, please open an issue on GitHub.
[12/13/2017, 9:39:05 PM] [eWeLink] A total of  accessories were loaded from the local cache[12/13/2017, 9:39:05 PM] [eWeLink] Requesting a list of devices from eWeLink HTTPS API at [https://us-api.coolkit.cc:8080][12/13/2017, 9:39:06 PM] [eWeLink] eWeLink HTTPS API reports that there are a total of  devices registered[12/13/2017, 9:39:06 PM] [eWeLink] Evaluating
Hey Siri, turn on the fan
[12/13/2017, 9:39:09 PM] [eWeLink] Setting power state to [on]
The plugin will also listen for announcements via a persistent web socket. This allows you to control the device from the likes of Google Home & have Homebridge be kept up-to-date
Hey Google, turn on the fan
[12/13/2017, 9:41:50 PM] [eWeLink] Update message received