ThingsPanel DeviceConnector for Xiaomi cloud and Xiaomi LAN access. This is the new connector runtime implementation. This is the standalone repository for the Xiaomi connector.
connectorKey:xiaomi- Standalone repo:
github.com/thingspanel/thingspanel-device-connector-xiaomi - Suggested visibility: public
xiaomi_cloud: Xiaomi OAuth + MIoT cloud HTTP APIxiaomi_lan: LAN IP + token mode- Device discovery through account/device listing
- Internal MQTT downlink bridge for ThingsPanel command delivery
xiaomi-plug is the old direct plugin example and should stay deprecated/private. New Xiaomi publishing should center on this connector.
Required baseline variables:
CONNECTOR_SERVICE_IDENTIFIER=xiaomiCONNECTOR_INSTANCE_ID=<connector-instance-id>THINGSPANEL_BACKEND_URL=http://127.0.0.1:4000XIAOMI_ACCESS_MODE=xiaomi_cloudorxiaomi_lan
MQTT bridge:
TP_MQTT_BROKER=tcp://127.0.0.1:1883XIAOMI_TP_DEVICE_ID=<thingspanel-device-id>XIAOMI_MQTT_USERNAME=<thingspanel-device-number>XIAOMI_MQTT_PASSWORD=<optional>
Cloud mode inputs:
XIAOMI_CLOUD_SERVER=cnXIAOMI_OAUTH_JSON=<oauth-json>orXIAOMI_OAUTH_FILE=/path/to/oauth.json
LAN mode inputs:
XIAOMI_LAN_TOKEN=<device-token>
Generate Xiaomi OAuth material:
cd examples/device-connectors/xiaomi-service
go run ./cmd/oauth-login -cloud-server cn -out /tmp/xiaomi-oauth.jsonList discoverable devices:
go run ./cmd/list-devicesRun the connector:
go run .
curl http://127.0.0.1:9001/health{"method":"switch","params":"on"}{"method":"switch","params":"off"}{"method":"brightness","params":35}{"method":"query","params":"state"}
Local publish helper:
go run ./cmd/publish-command -service xiaomi -method query -params '"state"'go test ./...Live integration test is env-gated:
LIVE_XIAOMI_TEST=1 go test ./...Deploy helper in this monorepo:
cd encore-api
go run ./cmd/deploy-xiaomi-service