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

yoyoapi

v0.7.8

Published

API Wrapper for YoLink Devices

Downloads

11

Readme

yoyoAPI

API Wrapper for Individual Product Users of Yolink / Yosmart Devices

Description

yoyoAPI is an open source wrapper that facilitates the use of the YoSmart API to manage YoLink devices. Specifically, yoyoAPI supports individual product users (UAC) API, also known as Open API V2.

Note that the documentation on the YoSmart website is not always up-to-date with the current responses. Only devices that could be tested have been included here. More to follow as additional Yosmart items are purchased. Here are the versions of supported devices:

Supported Devices and Versions

| Device Name | Model Name | Tested Version | | ------------- | ---------- | -------------- | | Hub | YS1603-UC | 0361 | | Outlet | YS6604-UC | 040e | | MotionSensor | YS7804-UC | 0471 | | DoorSensor* | YS7707-UC | 0704 | | GarageSensor* | YS7706-UC | 060f | | GarageDoor | YS4906-UC | 060b |

*GarageSensor uses the same interface as DoorSensor.

Features

  • Automated Authentication and Token Refresh - yoyoAPI will automatically authenticate on the first API request, and then continually refresh as JWT tokens expire.
  • Fully typesafe and intellisense for requests.
  • Generate and Interact with Outlet, MotionSensor, and DoorSensor devices.
  • Custom error response to resolve when inputs or responses from Open API V2 do not conform to current standards.
    • Any error code with 700XXX is custom and returned from yoyoApi. See list of custom error codes below.
    • Official error codes are listed on the documentation site, but this list is not comprehensive.
  • Unit tests of basic functions and rudimentary integrated tests of API using Jest with ~74% coverage.

Custom Error Codes

| Code | Description | | ------ | ----------------------- | | 700101 | Invalid Server Response | | 700102 | Invalid Request Body | | 700103 | Authentication Error | | 700999 | Unknown yoyoApi Error |

yoyoApi Usage

const getYo = async () => {
    const yo = new yoyoApi(
        'ua_11111111111111111111111111111111',
        'sec_v1_xxxxxxxxxxxxxxxxxxxxxxxx'
    );

    // Create a Home class
    const home = yo.Home();

    // Get a full list of devices
    const deviceList = await home.getDeviceList();

    // Selecting a MotionSensor
    const motionDetails = deviceList.data.devices[1];
    const motionsensor = yo.MotionSensor(motionDetails);

    const result = await motionsensor.getState();

    if (result.code !== '000000') throw new Error('Errors Happen');

    console.log('Result: ' + JSON.stringify(result));
};

Technology

Every effort has been made to minimize the number of external packages used, and instead, favor native JavaScript methods (such as fetch()). Other packages and tools are listed below:

Default URLs

The default URL for Open API V2 is: https://api.yosmart.com/open/yolink/v2/api

The default URL for obtaining a authorization token is: https://api.yosmart.com/open/yolink/token

Accounts and Credentials

To use the yoyoAPI wrapper you will need:

  • An account within the YoLink system using the YoLink application on an Android or Apple device.
  • Create Access Credentials for the API, including a UAID and a Secret Key.
    • From within the app: [Account] => [Advanced Settings] => [Personal Access Credentials] => [+]

ChangeLog

  • v0.7.6 - Initial Publish
  • v0.7.7 - Added Garage Door Control and Garage Door Sensor
  • v0.7.8 - Minor name change to match product

Disclaimer

yoyoAPI, and any associated websites or works, are not affiliated with or in anyway endorsed by YoSmart Inc., or their division, YoLink.

Any product names, logos, brands, and other trademarks or images featured or referred to within are the property of their respective trademark holders. These trademark holders are not affiliated with yoyoAPI. These trademark holders do not sponsor or endorse yoyoAPI or any of it's software, comments, or services. yoyoAPI declares no affiliation, sponsorship, nor any partnerships with any registered trademarks unless otherwise stated.

Further, this software is provided "as-is," without any express or implied warranty of any kind. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. Use this software at your own risk. The authors and copyright holders disclaim all warranties, express or implied, including but not limited to any implied warranties of merchantability and fitness for a particular purpose. By using this software, you agree to bear all risks and responsibilities for any damages or losses that may result from its use.