Sonoff TH10/TH16
Smart Switch one channel relay with humidity and temperature sensors.
Sonoff TH10/TH16
This Enapter Blueprint enables Sonoff TH10/TH16 Smart Switch support in Enapter Cloud via eWelink REST API.
Installation Guide
View on GithubThis Enapter Device Blueprint integrates Sonoff TH10 or TH16 Smart Switch one channel relay with humidity and temperature sensors via eWelink REST API Server. The Blueprint is running on Enapter Virtual UCM. This Blueprint allow to control relay as well as monitor temperature and humidity.
Requirements
-
eWelink account
You require to have email and password used for login as well as region.
The eWelink account can be created in the eWelink Mobile App.
-
Sonoff Device ID You can find it in the eWelink app:
-
Tap on Device.
-
Click ... in top right corner.
-
Scroll down to Device ID. Write it down for future use.
-
-
Latest version of Enapter Gateway Software
Enapter Gateway Software must support Virtual UCM and Docker containers runtime.
Running eWelink REST API Server
This Blueprint is using eWelink REST API Server. For more details visit it's page at GitHub - https://github.com/DoganM95/Ewelink-Rest-Api-Server and Docker Hub - https://hub.docker.com/r/doganm95/ewelink-rest-api-server
At the moment of writing the instruction the original eWelink REST API server has no suppot for several channel devices. The patch is available at this repository https://github.com/nkrasko/Ewelink-Rest-Api-Server.
The REST API is intermediate service from one sides connects to eWelink client API the same was as your mobile application and on the other side provide HTTP endpoint where you can get data of your devices in JSON format or execute commands for switches.
The beauty of this solution is possibility to use Enapter Energy Management toolkit and exisitng eWelink service.
In this example we will bild own container.
-
Clone repository
git clone https://github.com/nkrasko/Ewelink-Rest-Api-Server cd Ewelink-Rest-Api-Server
-
Build container
docker build -t nkrasko/ewelink-rest-api-server -f ./docker/Dockerfile .
-
Run docker container
docker run -d --restart unless-stopped \ -p LOCAL_TCP_PORT:3000 \ -e 'EWELINK_USERNAME=EMAIL' \ -e 'EWELINK_PASSWORD=PASSWORD' \ -e 'EWELINK_REGION=REGION' \ -e 'SERVER_MODE=dev' \ nkrasko/ewelink-rest-api-server
Put the correct values for:
- EMAIL - your eWelink email, for example, test@test.com
- PASSWORD - your eWelink password
- REGION - your eWelink Region:
- Mainland China: CN
- Asia: AS
- Americas: US
- Europe: EU
- LOCAL_TCP_PORT: any free TCP port on which HTTP server will be listening. This port will be needed for Virtual UCM configurattion in next steps. For example, 8081.
-
Check docker container is running and healthy by running command:
docker ps
You should see something like:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6261c5dd833f nkrasko/ewelink-rest-api-server "docker-entrypoint.s…" 33 minutes ago Up 33 minutes 0.0.0.0:8081->3000/tcp hungry_lewin
In above example, the docker container is running on TCP port 8081.
-
Check your API provides valid response with CURL from host where docker container runs:
curl http://127.0.0.1:8081
You should get valid JSON as response.
If everything is fine you are ready to connect your device to Enapter Cloud!
Connect to Enapter
-
Sign up to the Enapter Cloud using the Web or mobile app (iOS, Android).
-
Use the Enapter Gateway to run the Virtual UCM. If you are running eWelink REST API server on diiferent computer, ensure it is available from the Enapter Gateway.
-
Create the Enapter Virtual UCM.
-
Upload thie Blueprint using Enapter Marketplace on your mobile device. Advanced users can upload using Web IDE or CLI by following Developer Documentation.
-
As soon as Blueprint will start the Module Not Configured event will be triggered.
-
Navigate to Settings ().
-
Click Commands.
-
In the Settings section of the Commands screen click on Main Configuration command in the Enapter mobile or Web app to set main settings for your Virtual UCM:
You need to set the following parameters you got during previous steps:
-
IP Address of eWelink REST API server
-
IP Port
-
Device ID
-
-
Press Run button
The status data should be available on your Sonoff TH10 or TH16 Smart Switch dashboard as well as you can control your relay manually or automatic way with Enapter Rules Engine
References
Runs on