当前位置: 首页 > 软件库 > 其他开源 > 物联网 >

homebridge-button-platform

授权协议 Apache-2.0 License
开发语言 JavaScript
所属分类 其他开源、 物联网
软件类型 开源软件
地区 不详
投 递 者 邵华皓
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Button Platform for Homebridge

This Homebridge platform plugin creates virtual buttons that can be triggeredusing HTTP requests. It was originally created to provide HomeKit support forFlic smart buttons before the Flic Hub LR got native HomeKitsupport but can be leveraged by anything that can send HTTP requests.

Flic Hub LR now supports HomeKit: Flic released a firmware update for theFlic Hub LR on 2 December 2020 which included native HomeKit support.Visit https://flic.io/homekit for instructions on how to configure nativeHomeKit access.

This plugin requires a working home hub.

Before you install, ensure you have setup a HomePod, HomePod mini, Apple TV oriPad as a home hub for HomeKit. Ahome hub is required to run automations triggered by the button events generatedby this plugin.

Install

The simplest method to install and configure this plugin is viahomebridge-config-ui-x.

To install manually, run the following command in your Homebridge directory.Depending on how you installed Homebridge, you may need to add the -g and/orthe --unsafe-perms parameters:

npm install [-g|--unsafe-perms] homebridge-button-platform

The -g option will install the plugin globally and the --unsafe-perms optionis needed for some platforms to install successfully.

Configuration

The plugin can be configured via the homebridge-config-ui-xadmin interface.

To configure the plugin manually, add the following configuration to theplatforms block of your Homebridge config.json file:

"platforms": [
    {
        "platform": "button-platform",
        "port": 3001,
        "buttons": [
            "My Button",
            "Your Button",
            "Their Button"
        ]
    }
  ]

You can add as many buttons to the array as you need. Each button will get itsown URI on which the server will listen for events. You can determine the URIfor each button by checking the Homebridge logs forThe Event URI for <button name> is: /button-button-name strings.

Note: renaming a button in config.json is the same as deleting the oldbutton and adding a new one, i.e. any configuration will be lost.

Sending events

To trigger a button event, send an HTTP GET request with a specific querystring value or an HTTP POST request to your Homebridge hostname or IP addressand the port specified in the configuration of the platform, plus the URI for thebutton.

Using a GET request

The simplest method of triggering an event is to use a simple GET request withthe query string parameter of event set to one of the valid event types:

  • click or single-press
  • double-click or double-press
  • hold or long-press

For example, to send a single click event to a button using curl:

$ curl http://<homebridge>:<port>/uri?event=click
Success

You could also use this URL with a normal web browser.

Example Flic button configuration

Here’s a screenshot of what an Internet Request action should look like in theFlic app if your Homebridge server is homebridge.local and the pluginwas listening on port 3001:

The values are as follows:

Field Value
Hub Action Internet Request
URL http://homebridge.local:3001/button-name?event=click
Type GET

Battery level

The plugin from v1.5 onwards automatically creates abattery service when it detects it's being triggered by a Flic button and willupdate the battery level with the current value from the Flic whenever thebutton is pushed.

Example Stream Deck configuration

You can use the "Website" Stream Deck action to trigger an event. In theStream Deck configuration, drag the "Website" action to a key and configurethe URL to be http://homebridge.local:3001/button-name?event=click which uses thesame parameters as the GET request above:

Top tip: If you enable the GET request in background option, a browser willnot open when you hit the key.

Using a POST request

If you use an HTTP POST request you must set the Content-Type header to eitherapplication/json or application/x-www-form-urlencoded. The body of the requestneeds a field named event with a value of one of the event types defined above.

For example, to send a double press event to a button using curl with a JSONpayload:

$ curl -X POST \
  -H 'Content-Type: application/json' \
  -d '{"event": "double-click"}' \
  http://<homebridge>:<port>/<uri>

You can also POST with an application/x-www-form-urlencoded payload:

$ curl -X POST \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'event=double-click' \
  http://<homebridge>:<port>/<uri>

This is useful when used in with a larger form-based application.

Troubleshooting

Check the Homebridge logs for any warnings as the plugin will log any attemptsto trigger an invalid event or any invalid URIs.

 相关资料
  • homebridge-video-foorbell ffmpeg plugin for Homebridge Installation Install ffmpeg on your Raspberry Install this plugin using: npm install -g npm i homebridge-video-doorbell-button --unsafe-perm Edit

  • Homebridge SwitchBot Button Presser A Homebridge plugin for SwitchBot Button Presser. Requirements Currently only Linux is supported gatttool needs to be installed Installation Install the npm package

  • 按钮在Bootstrap按钮一章中解释。 使用此插件,您可以添加一些交互,例如控制按钮状态,或者为工具栏等更多组件创建按钮组。 如果您想单独包含此插件功能,则需要button.js 。 另外,如Bootstrap插件概述一章所述,您可以包含bootstrap.js或缩小bootstrap.min.js 。 装货状态 要向按钮添加加载状态,只需将data-loading-text = "Loadin

  • Extends Widget A push button. Can contain a text or an image. Import this type with “const {Button} = require('tabris');” Android iOS Properties alignment Type: string, supported values: left, right,

  • 按钮,提供了各种类型、样子、状态以及图标。 示例 按钮类型 默认类型为 button,还可设置为 submit 用于表单中 <cube-button>Button</cube-button> <cube-button type="submit">Submit Button</cube-button> 按钮状态 默认正常,可设置激活、禁用状态 <cube-button :active="true"

  • 按钮,提供几种基础样式和尺寸,可自定义图标。 引入 import { Button } from 'mint-ui'; Vue.component(Button.name, Button); 例子 改变颜色 <mt-button type="default">default</mt-button> <mt-button type="primary">primary</mt-button> <m