npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vitramir/homebridge-tuya-web

v0.1.12

Published

Homebrigde plugin for use with Tuya devices (uses Home Assistant Tuya Web API)

Downloads

9

Readme

!! THIS REPOSITORY IS NOT ACTIVELY MAINTAINED ANYMORE, PLEASE FEEL FREE TO CREATE FORK !!

homebridge-tuya-web

Homebridge plugin for Tuya devices using a cloud Tuya Web Api.

This Homebridge plugin is based on the Home Assistent Tuya integration that implements a special Tuya Home Assistant API.

See Home Assistant Tuya integration and Tuyaha python library.

Features

This Homebridge Plugin implements the following features:

  • Controlling Tuya WIFI enabled devices form within HomeKit enabled iOS Apps.
  • Uses simple and lightweight Cloud Web API to control and get state update from Tuya devices. You will need a stable internet connection to control the devices and get frequent state updates.
  • Device State Caching. State of devices is cached in memory, every time a HomeKit app request status updates from the devices this results in a very fast and responsive response. State cache is updated every 10 seconds and when controled from a HomeKit app. There can be a latancy in updates when a device is controled form an App/Hub/Controller other than HomeKit, e.g. from the Tuya Android/iOS App.

Installation

npm i homebridge-tuya-web -g

Basic config.json

{
  "platform": "TuyaWebPlatform",
  "name": "TuyaWebPlatform",
  "options":
    {
      "username": "[email protected]",
      "password": "xxxxxxxxxx",
      "countryCode": "xx",
      "platform": "smart_life",
      "pollingInterval": 10
    }
}

The options has these properties:

  • username: Required. The username for the account that is registered in the Android/iOS App.
  • password: Required. The password for the account that is registered in the Android/iOS App.
  • countryCode: Required. Your account country code, e.g., 1 for USA or 86 for China.
  • plaform: The App where your account is registered. tuya for Tuya Smart, smart_life for Smart Life, jinvoo_smart for Jinvoo Smart. Defaults to tuya.
  • pollingInterval: Optional. The frequency in seconds that the plugin polls the cloud to get device updates. When the devices are only controlled through Homebridge, you can set this to a low frequency (high interval nummer, e.g. 180 = 3 minutes). Defaults to 10.

Overrule / default values

As of version 0.1.6 it is possible to override or set values to default. As of now only overruling device type is posible. See configuration below.

{
  "platform": "TuyaWebPlatform"
  "name": "TuyaWebPlatform",
  "options":
    {
      ...
    },
  "defaults": [
    {
      "id": "<id>",
      "device_type": "<device_type>"
    }
  ]
}

The defaults has these properties:

  • id: Required. The id for the device that is registered in the Android/iOS App.
  • device_type: Optional. The device_type to be overruled. For now only device type dimmer is supported. This can be usefull for dimmers that are reported as light by the Tuya API and don't support hue and saturation.

Supported device types

There is currently support for the following device types within this Homebridge plugin:

  • Switch/Outlet - The platform supports switch and outlets/sockets.
  • Light/Dimmer - The platform supports most kinds of Tuya light. Partly implemented, now only supports controlling on/off and brightness. This can be used with a dimmer.

The used Web API also supports these devices, but are not implemented yet in the plugin.

  • Climate - Not yet supported.
  • Cover - Not yet supported.
  • Fan - Not yet supported.
  • Scene - Not supported, don't see the use of this as scenes are configured in HomeKit. Will probably never implement this.

TODO

These features are on my wishlist and need to be implemented:

  • Implement devices that are not supported yet.
  • Add option to enable/disable state caching.
  • Add option to change polling frequency to user defined value (default is now 10 seconds).

Unit tests

The source code also has some unit tests to test API calls. Run the following command to run the unit tests.

 mocha test/tuyawebapi_test.js

Version history

Version 0.1.7 - 2019-08-18
  • Fixed not correct updating after reboot of Homebridge.
Version 0.1.6 - 2019-08-18
  • Added light accessory (made by niksauer, thanks!!)
  • Added overruling device type in config. Some dimmers are reported by Tuya API as lights. Dimmers don't have hue and saturation and therfor the device type has to be overruled to dimmer.
Version 0.1.5 - 2019-08-18
  • Fixed issue #17 - Outlets and switches not turning off in Home app when turned off with other app.
Version 0.1.4 - 2019-08-09
  • Switch to regional Tuya Web API server after authentication was successful (EU / China / USA).