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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rokid-homebase-cli

v2.0.7

Published

rokid-homebase-cli

Downloads

35

Readme

rhome

使用 rhome 工具通过 json schema 来验证 discover|control|report-state 接口的返回值来验证接入 Rokid Homebase 协议。

功能

  • 调用 discover|control|report-state 接口。

  • 使用 jsonschema 对返回的数据格式进行校验,并指出具体错误信息。

  • 使用 jsonschema 对 ChangeReport 事件进行校验,并指出具体错误信息。

安装

Release 页面下载最新的适合你的操作系统的已打包的程序。

使用

$ rhome -h

  Usage: rhome [options] [command]

  Options:

    -V, --version                               output the version number
    -v, --verbose                               show raw response body
    -h, --help                                  output usage information

  Commands:

    add                                         add a session of remote driver
    del <name>                                  delete the session of remote driver
    sessions                                    list all added sessions
    use <name>                                  user an added session

    discover [options]                          list all devices of a driver
    control [options] <endpointId> <directive> [value]  execute the device<id> with target action(e.g `Media.TVChannel.Set '{ "tvChannel": { "code": "123" } }'`)
    report-state [options] <id>                 get current state of a driver

    await-event [options]                       serve an event gateway to await change reports

步骤 1: 添加 Skill 配置

  • rhome 运行后,将在用户目录下新建 rhome.json 文件,保存 sessions、devices、currentSession 信息。如有必要,开发者可以进行修改。
  • add 是交互式命令。 name 必须由 字母数字下划线 组成。例如: demo_1。 其余为命令行模式。
  • sessions 命令显示已添加的所有 session,和显示当前使用的 session。默认使用第一个 session,或通过 use 指定。

如:

$ rhome add

? remote driver's name demo
? remote driver's endpoint http://127.0.0.1:3000
? userId in userAuth. If null, skip
? userToken in userAuth. If null, skip
{
  "name": "demo",
  "endpoint": "http://127.0.0.1:3000",
  "userId": "",
  "userToken": ""
}

步骤 2: 搜索设备

在控制设备之前,我们需要先获取 Skill 能控制的设备

$ rhome discover

id: 0
sessionName: mimic
endpointId: device-1
displayName: 大米台灯
displayType: light
offline: false

步骤 3: 控制设备

使用 control <endpointId> <directive> [payload] 命令来控制设备,其中 payload 为序列化的 JSON 字符串,如 '{"value": 123}'

$ rhome control device-1 Switch.On

id: 0
sessionName: mimic
endpointId: device-1
displayName: 大米台灯
displayType: light
offline: false

数据校验

rhome 将对返回数据进行校验,并显示具体的错误信息。

  • 数据格式正确
$ rhome discover

id: 0
sessionName: demo
deviceId: "e12e2735-5e64-44d3-8ee2-46471f03d182"
name: light1
type: light
offline: false
  • 数据格式错误

如有错误,将会显示具体的错误信息,以供参考。

$ rhome discover

body checked by json schema:
instance does not match allOf schema [subschema 1] with 2 error[s]:
instance.data[0].actions.color[1] is not one of enum values: random,num
instance.data[0] requires property "type"

步骤 4: 发送终端状态变化事件

使用 await-event 命令来启动一个本地接收事件的测试服务器,可以使用如 -p 7001 的选项来指定服务器端口。

$ rhome await-event -p 9999

rhome listening on port 9999
Received a change report: {
  "header": {
    "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
    "namespace": "Rokid",
    "name": "ChangeReport",
    "payloadVersion": "v1",
    "authorization": {
      "type": "BearerToken",
      "token": "a-token-from-rokid"
    }
  },
  "endpoint": {
    "endpointId": "0",
    "states": [
      {
        "interface": "Switch",
        "value": "On",
        "timeOfSample": "2018-03-15T18:00:00.000Z"
      }
    ]
  },
  "payload": {
    "change": {
      "cause": "PHYSICAL_INTERACTION"
    }
  }
}
Caused by: PHYSICAL_INTERACTION
sessionName: mimic
endpointId: 0
displayName: 台灯
displayType: light
offline: false
states:
  Switch: "On"