NOTICE: All information contained herein is, and remains
the property of TechnoCore Automate.
Updated : 2026-03-19
ObjServiceEwelink integrates with eWeLink / Sonoff
smart home devices. It uses a dual control path:
The cloud API is used with the Home Assistant App ID
which has read-only access. Device control falls back
to LAN automatically when the cloud API returns a
permission error.
ObjServiceEwelink
├── Cloud (CoolKit API v2)
│ ├── Login (HMAC-signed)
│ ├── GET /v2/device/thing → list devices
│ ├── GET /v2/device/thing/status → read status
│ └── POST /v2/device/thing/status → control (restricted)
│
└── LAN (sonofflan / mDNS)
├── Zeroconf discovery on _ewelink._tcp
├── Encrypted communication using DeviceKey
├── /zeroconf/switch → on/off
└── /zeroconf/switches → multi-gang control
set_switch(device_id, "on")
→ Try cloud API POST
→ If 407 (restricted): fall back to LAN
→ Read DeviceKey from data_ewelink (cached)
→ mDNS discover device on local network
→ Send encrypted on/off command
# config.yaml
ewelink:
app_id: "4s1FXKC9FaGfoqXhmXSJneb3qcm1gOak"
app_secret: "oKvCM06gvwkRbfetd6qWRrbC3rFrbIpV"
email: "user@example.com"
password: "password"
region: "eu"
| Region | API URL |
|---|---|
eu |
https://eu-apia.coolkit.cc |
us |
https://us-apia.coolkit.cc |
as |
https://as-apia.coolkit.cc |
cn |
https://cn-apia.coolkit.cn |
Device registry with cached state and keys.
| Column | Type | Description |
|---|---|---|
| DeviceId | VARCHAR(20) | PK — eWeLink device ID |
| Package | VARCHAR(255) | PK — Axion package |
| Name | VARCHAR(255) | Device name |
| Model | VARCHAR(64) | Product model (TX1C, POWR320D, etc.) |
| Brand | VARCHAR(255) | Manufacturer |
| UIID | INT | eWeLink UI ID |
| Online | TINYINT | 1=online, 0=offline |
| SwitchState | VARCHAR(16) | on/off or comma-separated per outlet |
| Voltage | DECIMAL(10,2) | Volts (POWR devices) |
| Current | DECIMAL(10,2) | Amps (POWR devices) |
| Power | DECIMAL(10,2) | Watts (POWR devices) |
| FirmwareVersion | VARCHAR(32) | Device firmware |
| SSID | VARCHAR(64) | Connected WiFi |
| RSSI | INT | Signal strength |
| LastSeen | DATETIME | Last sync time |
| DeviceKey | VARCHAR(64) | Encryption key for LAN control |
| RawParams | JSON | Full device params |
| Module | VARCHAR(255) | ObjServiceEwelink |
Power consumption history for POWR devices.
| Column | Type | Description |
|---|---|---|
| Guid | VARCHAR(64) | PK |
| DeviceId | VARCHAR(20) | Device ID |
| Package | VARCHAR(255) | Package |
| Voltage | DECIMAL(10,2) | Volts |
| Current | DECIMAL(10,2) | Amps |
| Power | DECIMAL(10,2) | Watts |
| RecordedAt | DATETIME | Timestamp |
| Model | Type | UIID | Features |
|---|---|---|---|
| TX1C | 1-gang switch | 6 | on/off |
| TX2C | 2-gang switch | 7 | per-outlet on/off |
| TX3C | 3-gang switch | 8 | per-outlet on/off |
| POWR320D | Power monitor | 190 | on/off + V/A/W |
Fetches all devices from the cloud API and stores
them in data_ewelink with DeviceKey. Records power
readings for POWR devices.
Turn a device on or off. Tries cloud first, falls
back to LAN. For multi-gang switches, specify the
outlet index (0-based).
Toggle device state. Uses cloud status to determine
current state, or LAN toggle if cloud is restricted.
Returns {voltage, current, power} for POWR devices.
Standard Axion service entry point. Actions:
| Action | Params | Description |
|---|---|---|
sync |
Sync all devices to DB | |
on |
device_id, outlet | Turn on |
off |
device_id, outlet | Turn off |
toggle |
device_id | Toggle |
status |
device_id | Get raw status |
power |
device_id | Get power reading |
# List all devices
python ObjServiceEwelink.py devices
# Sync to database
python ObjServiceEwelink.py sync
# Turn on/off
python ObjServiceEwelink.py on 10024a9268
python ObjServiceEwelink.py off 10024a9268
# Multi-gang (outlet 1)
python ObjServiceEwelink.py on 10014d903b --outlet 1
# Toggle
python ObjServiceEwelink.py toggle-cmd 10011a5747
# Device status
python ObjServiceEwelink.py status 10024a9268
# Power reading (POWR devices)
python ObjServiceEwelink.py power 10024a9268
LAN control uses the sonofflan package which
discovers devices via mDNS/Zeroconf on the local
network. Communication is encrypted using the
device's DeviceKey (obtained from the cloud API
during sync and cached in data_ewelink).
Requirements:
sync must succeed to cache DeviceKeysDiscovery takes 5-20 seconds depending on network
conditions. If a device is not found within the
scan window, the command returns FAIL.
requests — cloud API callssonofflan — LAN device controlzeroconf — mDNS discovery (via sonofflan)ObjServiceSolarman.py — solar inverter APIObjServiceOpenWeather.py — weather APIObjServiceLoadshedding.py — EskomSePush APIUpdated : 2026-03-19