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

broadlink-dna-jssdk

v1.0.4

Published

broadlink dna platform jssdk

Downloads

1

Readme

broadlink-dna-jssdk

broadlink dna platform jssdk supported by ts

Broadlink 平台 H5 JS SDK接口

安装

npm install --save broadlink-dna-jssdk

JS SDK接口说明

ready

ready();

功能说明: 启动函数,当 JSSDK 就绪之后,调用启动函数。

入参项: 无|'device'|'online',默认为'device'(设备控制应用引入),'online'(非设备控制应用引入)。

返回项: Promise,如jssdk初始化成功则resolved,否则rejected。Resolved会传入设备状态.

e.g:

import JSSDK from 'broadlink-dna-jssdk';
var ready=JSSDK.ready();
ready.then(function(data){
    //data的数据格式如下:
    {
        'status':{
            'mark':1,
            'temp':25
            },
    //以下两个字段('online','name')不一定会存在,开发者需要根据平台的不同进行判断
        'online': '0/1/2/3',//设备状态:未知/本地/远程/离线(京东平台对应:在线/离线)
        'name':'refrigerator'
    }
}).catch(function(error){
    // error为一个Error对象,数据格式如下:
    {
        message:‘网络超时’,//错误描述
        code:11,   //错误码
        msg:平台返回的错误信息
    }
})

setDeviceStatus

setDeviceStatus(cmd);

功能说明: 给设备发送命令

输人项:

  • cmd:命令对象。
{
    'mark': 1,
    'temp': 25
}

返回项:

一个 Promise 对象,调用者可以这样使用:

import JSSDK from 'broadlink-dna-jssdk';
var prms = JSSDK.setDeviceStatus(…);
// 显示等待沙漏
prms.then(function(data) {
//受到平台的限制,不一定会传入data参数,如国美
//data是设备最新状态,数据结构为:
{
'status': {
    'mark': 1,
    'temp': 25
    },
//以下两个字段('online','name')不一定会存在,开发者需要根据平台的不同进行判断
'online': '0/1/2/3',//设备状态:未知/本地/远程/离线(京东平台对应:在线/离线)
'name':'refrigerator'
}
}).catch(function(error) {
// error为一个Error对象,数据格式如下:
{
    message:‘网络超时’,//错误描述
    code:11,   //错误码
    msg:平台返回的错误信息
}
});

getDeviceStatus

  /*三种形式*/
  getDeviceStatus()  //查询所有状态
  
  getDeviceStatus(array) //查询指定状态,如[‘pwr’,’temp’]

功能说明: 尝试更新设备状态

输人项:

  • params:接口名称数组,可选。若不选,则获取所有接口状态。

  • array参数数组. 若不选,则获取所有接口状态。

返回项:

一个 Promise 对象,调用者可以这样使用:

import JSSDK from 'broadlink-dna-jssdk';
var prms = JSSDK.getDeviceStatus(…);
// 显示等待沙漏
prms.then(function(data) {
    //data是设备最新状态,数据结构为:
    {
        'status': {
            'mark': 1,
            'temp': 25
            },
    "online":"0/1/2/3",//设备状态:未知/本地/远程/离线(京东平台对应:在线/离线)
    'name':'refrigerator'
    }
}).catch(function(error) {
    // error为一个Error对象,数据格式如下:
    {
    message:'网络超时',//错误描述
    code:11,//错误码
    msg:平台返回的错误信息
    }
);

platformSDK

import JSSDK from 'broadlink-dna-jssdk';
JSSDK.platformSDK;

功能说明: 获取broadlink dna平台提供的sdk对象