homebridge-tuya-energy-monitor
v0.1.4
Published
Homebridge plugin for a Tuya energy monitor.
Maintainers
Readme
homebridge-tuya-energy-monitor
Starter Homebridge plugin scaffold for a Tuya energy monitor.
Quick start
Install dependencies:
npm installBuild:
npm run buildLink globally for Homebridge development:
npm linkAdd this to your Homebridge
config.json:{ "platforms": [ { "platform": "TuyaEnergyPlatform", "name": "Tuya Energy", "deviceName": "Tuya Energy Monitor", "clientId": "YOUR_TUYA_CLIENT_ID", "secret": "YOUR_TUYA_SECRET", "deviceId": "YOUR_TUYA_DEVICE_ID", "region": "us", "pollSeconds": 30 } ] }
Project structure
src/index.ts: Homebridge plugin entrypoint and platform registration.src/platform.ts: Dynamic platform setup and accessory discovery scaffold.src/tuyaEnergyAccessory.ts: Accessory skeleton with placeholder characteristic mapping.config.schema.json: Homebridge UI schema for plugin settings.
Tuya setup notes
- Create or use an existing Tuya IoT Cloud project and link your app account/devices.
- Copy your cloud
Access IDasclientIdandAccess Secretassecret. - Use the Tuya IoT console or API explorer to confirm the target
deviceId. - Pick the correct region for your project:
us,eu,cn, orin.
Current behavior
- The plugin polls Tuya
/v1.0/devices/{deviceId}/statuson an interval. - It attempts to read current power from status codes like
cur_powerand maps this into a simple activity signal. - Next we can map richer telemetry (power, voltage, current, kWh) into custom HomeKit characteristics.
Publish to npm (for Homebridge UI install)
Login to npm from this project directory:
npm loginPublish the package:
npm publishIn Homebridge UI on your remote host:
- Open Plugins
- Search for
homebridge-tuya-energy-monitor - Install and restart Homebridge
For updates:
npm version patch npm publish
