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

@tslfe/tacos-iot

v0.1.2

Published

tacos os

Downloads

17

Readme

@tslfe/tacos-iot

基于@tslfe/tacos-sdk 提供更上层的 IoT 设备 sdk 封装,提供了语义化的指令下发方法,及一些公共属性和方法,适用于明确 IOT 设备类型的设备操作场景

当前仅支持可发送指令的 IoT 设备

已支持的设备

| 序号 | 名称 | 描述 | | ---- | --------------- | -------------- | | 1 | air-condition | 空调 | | 2 | blowing-fan | 送风机 | | 3 | butterfly-valve | 电动蝶阀 | | 4 | chiller-master | 冷水主机 | | 5 | chiller-slave | 冷水从机 | | 6 | curtain | 电动窗帘 | | 7 | door | 电动门 | | 8 | exhaust-fan | 排风机 | | 9 | fan-coil | 风机盘管 | | 10 | fresh-air | 新风主机 | | 11 | hw-pv-inverter | 华为光伏逆变器 | | 12 | light | 可调光照明 | | 13 | pass-valve | 旁通阀 | | 14 | pump | 离心泵 | | 15 | stream-switch | 水流开关 | | 16 | switch | 开关照明 | | 17 | vav | vav 空调 | | 18 | vrv | vrv 空调 | | 19 | window | 电动窗 |

开始


安装

npm install @tslfe/tacos-sdk --save
npm install @tslfe/tacos-iot --save or
yarn add @tslfe/tacos-sdk -S yarn add @tslfe/tacos-iot -S

示例

使用@tslfe/tacos-iot创建 IOT 实例需要三个步骤:

  1. 通过@tslfe/tacos-sdk与 tacos 平台建立连接,具体建立连接方式请参考@tslfe/tacos-sdk 文档
  2. 建立连接后可从@tslfe/tacos-iot导入需要创建的 IOT 设备实例类型,创建实例对象

    须确保创建的实例对象属于导入的 IOT 设备类型

  3. 调用实例对象的 API 方法进行指令下发,或监听事件变更
import Tacos from "@tslfe/tacos-sdk";
import { Light } from "@tslfe/tacos-iot";

// 第一步:通过connect与tacos建立连接
Tacos.connect({ tacosId: "<tacos实例ID>", signature: "<签名>" }).then((tacos) => {
  // 第二步:建立连接后创建具体IOT设备sdk实例对象
  let light = tacos.createInstance(Light, { deviceId: "<设备ID>" });
  // 第三步:调用实例对象的API方法,可直接下发指令
  light.turnOn(); // 下发打开照明指令

  // 也可添加设备状态的监听
  light.addListener("state", (data) => {
    //...其它逻辑
  });
});

API

IOT 设备的 API 方法返回值统一为Promise


通用

instance

当前 IOT 实例的 device 实例,与@tslfe/tacos-sdk的 Device 模块的返回值类型相同

addListener

添加订阅

  • 方法:addListener(type: "event" | "state",callback: (data: any) => void, keys?: string[])
  • 参数:
    • type: 添加订阅的类型
      • event:事件订阅
      • state:状态变更订阅
    • callback:回调函数
    • keys: 需要订阅的具体名称,例如订阅事件时需要订阅的具体事件名,订阅状态时需要订阅的具体状态名,若不传,则默认订阅当前类型的所有变更
  • 返回值:
  • 示例:
// 订阅设备light的switch_status_set状态变更
light.addListener(
  "state",
  (data) => {
    //...其它逻辑
  },
  ["switch_status_set"]
);

removeListener

移除订阅

  • 方法:removeListener(type: "event" | "state",callback: (data: any) => void): void
  • 参数:
    • type: 添加订阅的类型
      • event:事件订阅
      • state:状态变更订阅
    • callback:回调函数
  • 返回值:

air-condition

turnOn()

启动空调

参数:无

turnOff()

关闭空调

参数:无

frequent(value: number)

设置空调送风机频率

参数:

  • value:频率值 0-50

valveDegree(type: string, value: number)

设置不同情形下阀门开度

参数:

  • type:阀门类型
    • valve 冷热水阀开度
    • valve_in 回风阀开度
    • valve_out 送风阀开度
  • value:开度值 0-100

blowing-fan

turnOn()

开启送风机

参数:无

turnOff()

关闭送风机

参数:无

butterfly-valve

turnOn()

开启电动蝶阀

参数:无

turnOff()

关闭电动蝶阀

参数:无

degree(value: number)

设置电动蝶阀开度

参数:

  • value:开度值 0-100

chiller-master

turnOn()

开启冷水主机

参数:无

turnOff()

关闭冷水主机

参数:无

cool()

设置模式为制冷

参数:无

heat()

设置模式为制热

参数:无

pump()

设置模式为水泵

参数:无

temperature(type: string, value: number)

设置不同情形下的回水温度

参数:

  • type:回水类型
    • cool_in 制冷回水
    • cool_out 制冷出水
    • hot_in 制热回水
    • hot_out 制热出水
  • value:温度值
    • 出水温度 -5-50
    • 回水温度 0-80

chiller-slave

turnOnBlowingFan()

开启冷水从机的送风机

参数:无

turnOffBlowingFan()

关闭冷水从机的送风机

参数:无

turnOnExhaustFan()

开启冷水从机的排风机

参数:无

turnOffExhaustFan()

关闭冷水从机的排风机

参数:无

curtain

open()

开启遮阳帘

参数:无

close()

关闭遮阳帘

参数:无

pause()

暂停遮阳帘

参数:无

degree(value: number)

设置遮阳帘开度

参数:

  • value:开度值 0-100

door

open()

开启电动门

参数:无

close()

关闭电动门

参数:无

exhaust-fan

turnOn()

开启排风机

参数:无

turnOff()

关闭排风机

参数:无

fan-coil

turnOn()

开启风机盘管

参数:无

turnOff()

关闭风机盘管

参数:无

cool()

设置温度模式为制冷

参数:无

heat()

设置温度模式为制热

参数:无

auto()

设置风机模式为自动

参数:无

manual()

设置风机模式为手动

参数:无

level(level: string)

设置风机档位

参数:

  • value:档位值
    • "1" 低
    • "2" 中
    • "3" 高

temperature(value: number)

设置风机温度

参数

  • value: 温度值 5-50

fresh-air

turnOn()

开启新风主机

参数:无

turnOff()

关闭新风主机

参数:无

turnOnValve()

开启新风阀

参数:无

turnOffValve()

关闭新风阀

参数:无

frequent(value: number)

设置送风机频率

参数:

  • value:频率 0-50

degree(value: number)

设置新风主机冷热阀开度

参数:

  • value:开度值 0-100

hw-pv-inverter

turnOn()

开启华为光伏逆变器

参数:无

turnOff()

关闭华为光伏逆变器

参数:无

systemTime(time: number)

设置光伏逆变器系统时间

参数:

  • value:int64 纪元秒,本地时间

timezone(value: number)

设置逆变器时区

参数:

  • value:取值范围 720-840

light

可调光的电灯

turnOn()

开启调光灯

参数:无

turnOff()

关闭调光灯

adjust(value: number)

调节照明亮度

参数:

  • value:亮度范围 0-100

pass-valve

旁通阀

degree(value: number)

设置旁通阀开度

参数:

  • value:开度值 0-100

pump

离心泵

turnOn()

开启离心泵

参数:无

turnOff()

关闭离心泵

参数:无

frequent(value: number)

设置离心泵频率

参数:

  • value:频率值 0-50

stream-switch

水流开关

turnOn()

打开水流开关

参数:无

turnOff()

关闭水流开关

参数:无

switch

照明

turnOn()

打开照明开关

参数:无

turnOff()

关闭照明开关

参数:无

vav

vav 空调

turnOn()

开启 vav 空调

参数:无

turnOff()

关闭 vav 空调

参数:无

cool()

设置温度模式为制冷

参数:无

heat()

设置温度模式为制热

参数:无

auto()

设置风机模式为自动

参数:无

manual()

设置风机模式为手动

参数:无

frequent(value: number)

设置 vav 的风机频率

参数:

  • value:频率值 0-50

temperature(type: string, value: number)

设置 vav 制冷和制热的温度

参数

  • type: 模式类型
    • "cool":设置制冷温度
    • "hot":设置制热温度
  • value: 温度值 5-50

vrv

vrv 空调

turnOn()

开启 vrv 空调

参数:无

turnOff()

关闭 vrv 空调

参数:无

level(level: string)

设置风机档位

参数:

  • value:档位值
    • "1" 低
    • "2" 中
    • "3" 高

temperature(value: number)

设置风机温度

参数

  • value: 温度值 5-50

mode(type: string)

设置运行模式

参数:

  • type:模式类型
    • "1" 制冷
    • "2" 制热
    • "3" 除湿
    • "4" 送风