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

tuya-cloud-api-coupling

v1.0.2

Published

A simple communication wrapper for usage with the tuya cloud api

Downloads

3

Readme

A simple communication wrapper for usage with the tuya cloud api

Install

npm i tuya-cloud-api-coupling

or

yarn add tuya-cloud-api-coupling

Setup

  • Create an account for tuya (from other tutorials I heard US account is best for instant acceptance)
  • Go to Cloud -> Development
  • Press the Upgrade IoT Core Plan
  • Sign up for Trail Package (is free)
  • Create a cloud project with
    • Industry: Smart Home
    • Development Method: Smart home
    • Data center: Look in your Smart Life app under me -> settings (right top button) -> account and security -> region
    • Look up the corresponding data center on https://github.com/tuya/tuya-home-assistant/blob/main/docs/regions_dataCenters.md (Also remember the endpoint for in code later)
  • Then you get a popup where you can authorize api products, here you add Device status notifications and keep the rest also enabled.
  • Your project gets created
  • Go to devices -> Link Tuya App Account
  • Click on add App App Account
  • Go in the Smart Life app on your phone to "me" and then open QR scanner(right top corner square with stripe)
  • Scan the QR code
  • If you have the correct datacenter you should be able to add it
  • Then your devices should show up in Devices -> All devices
  • Copy a Device id to the example
  • Copy the Access ID and Access Secrets from the overview
  • Copy the examples/config.example.js -> examples/config.js
  • Fill in the data in the example below

Example

There are examples in the example directory

Basic usage:

    const TuyaCloudApiCoupling = require("tuya-cloud-api-coupling");
    // import * as TuyaCloudApiCoupling from 'tuya-cloud-api-coupling'

    let connection = new TuyaCloudApiCoupling.Connection({
    // Check readme above for your correct endpoint
        host: 'https://openapi.tuyaeu.com',
        accessId: 'some id from tuya cloud -> developers -> project',
        accessSecret: 'some secret from tuya cloud -> developers -> project'
    })

    const deviceId = 'id of a device'
    const data = await connection.get(`/v1.0/devices/${deviceId}`, {});
    console.log(data);

API documentation.

GET /v1.0/devices/${deviceId} -> Current device state https://developer.tuya.com/en/docs/cloud/device-management?id=K9g6rfntdz78a

POST /v1.0/devices/{device_id}/commands -> to send a command https://developer.tuya.com/en/docs/cloud/device-control?id=K95zu01ksols7#title-36-API%20description