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

homebridge-http-rgb-push

授权协议 View license
开发语言 JavaScript
所属分类 其他开源、 物联网
软件类型 开源软件
地区 不详
投 递 者 蒋高超
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Lint, Test and Release

homebridge-http-rgb-push

Homebridge plugin to control a HTTP-based RGB device.

Supports RGB HTTP(S) devices on the HomeBridge Platform and provides a readablecallback for getting and setting the following characteristics to Homekit:

  • Characteristic.On
  • Characteristic.Brightness
  • Characteristic.Hue
  • Characteristic.Saturation

What is this fork?

This fork differs from the original jnovack/homebridge-better-http-rgb in the following ways:

  • Supports homebridge-http-notifiation-server to allow the device to push it's status changes instead of poll based pull. E.g. if you have one device thatallows for multiple different effects while only one can be active at the same time. HomeKit can then show multiple switches representing one device. The group of switches will function as a radio button since the device will push the off status for the other switches. Or when you manually reboot the device to notify HomeKit of itsupdated state after reboot.
  • Supports regular expression pattern matching for on/off switches to determine whether the body reflects an on or off status.
  • Fixes a bug which causes the original plugin to not report the correct manufacturer, make and model towards HomeKit.
  • Briefly turn off/on or on/off the light/switch to locate the device's physicallocation when HomeKit requests 'identify'.
  • Added timeout parameter to prevent HomeBridge from getting stuck on a single unresponsive device. Credits: Tommrodrigues/homebridge-better-http-rgb.
  • Added error handling for non HTTP 200 status code replies.
  • README rewrite and corrections.
  • Allow GET requests with body matching for colour and status. Credits: Michael Mezger

Installation

  1. Install homebridge using: npm install -g homebridge
  2. Install homebridge-http-rgb-push using: sudo npm install -g homebridge-http-rgb-push
  3. Update your configuration file. See below for examples.

Note: See Installing packages globally when you experiencepermission problems.

Uninstall

To uninstall homebridge-better-http-rgb, simply run:

sudo npm uninstall -g homebridge-http-rgb-push

Configuration

Examples

Full RGB Device

"accessories": [
     {
         "accessory": "HttpPushRgb",
         "name": "RGB Led Strip",
         "service": "Light",
         "timeout": 3000,

         "switch": {
             "status": "http://localhost/api/v1/status",
             "powerOn": "http://localhost/api/v1/on",
             "powerOff": "http://localhost/api/v1/off"
         },

         "brightness": {
             "status": "http://localhost/api/v1/brightness",
             "url": "http://localhost/api/v1/brightness/%s"
         },

         "color": {
             "status": "http://localhost/api/v1/set",
             "url": "http://localhost/api/v1/set/%s",
             "brightness": true
         }
     }
 ]

Single Color Light that only turns "off" and "on"

"accessories": [
     {
         "accessory": "HttpPushRgb",
         "name": "Single Color Light",
         "service": "Light",

         "switch": {
             "status": "http://localhost/api/v1/status",
             "powerOn": "http://localhost/api/v1/on",
             "powerOff": "http://localhost/api/v1/off"
         }
     }
 ]

Single Color Light with Brightness

"accessories": [
     {
         "accessory": "HttpPushRgb",
         "name": "Single Color Light",
         "service": "Light",

         "switch": {
             "status": "http://localhost/api/v1/status",
             "powerOn": "http://localhost/api/v1/on",
             "powerOff": "http://localhost/api/v1/off"
         },

         "brightness": {
             "status": "http://localhost/api/v1/brightness",
             "url": "http://localhost/api/v1/brightness/%s"
         }
     }
 ]

RGB Light without Brightness

"accessories": [
     {
         "accessory": "HttpPushRgb",
         "name": "Single Color Light",
         "service": "Light",

         "switch": {
             "status": "http://localhost/api/v1/status",
             "powerOn": "http://localhost/api/v1/on",
             "powerOff": "http://localhost/api/v1/off"
         },

         "color": {
             "status": "http://localhost/api/v1/set",
             "url": "http://localhost/api/v1/set/%s"
         }
     }
 ]

This normally will not occur, however, you may not want your application todisplay a "brightness" slider to the user. In this case, you will want toremove the brightness component from the config.

Full RGB Device with advanced SET / GET Handling

Following configuration is a real world example for a accessory that combines a shelly switch / relay with a hue light bulb. ON/OFF-Signals will be sent to the shelly switch. On the other hand, changes to brightness / color are going to the hue bulb.

"accessories": [
    {
        "accessory": "HttpPushRgb",
        "name": "Full RGB Device with advanced SET / GET Handling",
        "service": "Light",
        "timeout": 3000,
        "switch": {
            "notificationID": "47110815",
            "status": {
                "url": "http://192.168.0.110/status",
                "bodyRegEx": "\"ison\":true"
             },
             "powerOn": "http://192.168.0.110/relay/0?turn=on",
             "powerOff": "http://192.168.0.110/relay/0?turn=off"
        },
        "brightness": {
            "status": {
                "url": "http://192.168.0.120/api/<apikey>/lights/6/",
                "bodyRegEx": "\"bri\":([0-9]+)"
            },
            "url": {
                "url":"http://192.168.0.120/api/<apikey>/lights/6/state",
                "body": "{\"bri\": %s}"
            },
            "http_method": "PUT",
            "max": 254
        },
        "color": {
            "status": {
                "url": "http://192.168.0.120/api/<apikey>/lights/6/",
                "bodyRegEx": "\"bri\":([0-9]+)"
            },
            "url": {
                "url":"http://192.168.0.120/api/<apikey>/lights/6/state",
                "body": "{\"xy\": [%xy-x,%xy-y]}"
            },
            "brightness": false,
            "http_method": "PUT"
        }
    }
]

Regular expression on-body matching

"accessories": [
    {
        "accessory": "HttpPushRgb",
        "name": "JSON body matching",
        "service": "Light",

        "switch": {
            "status": {
                "url": "http://localhost/api/v1/status",
                "bodyRegEx": "\"switch\":\s*\"on\""
            }
            "powerOn": "http://localhost/api/v1/on",
            "powerOff": "http://localhost/api/v1/off"
        }
        }
    }
]

Structure

Key Description Default
accessory Must be "HttpPushRgb"
name The name of your RGB accessory. It will appear in the Home app "RGB Light"
service "Light" or "Switch"
timeout (optional) Time (in milli seconds) until the accessory will be marked as "Not Responding" if it is unreachable. 10000
http_method (optional) The HTTP method used for set requests only. Get HTTP requests are fixed to 'GET' for now. "GET"
username (optional) Username if http authentication is enabled on the RGB device.
password (optional) Password if http authentication is enabled on the RGB device.
notificationID (optional) Identifier to use when device sends push notifications. See Push notifications
notificationPassword (optional) Password to use when device sends push notifications.
switch A switch object -
brightness A brightness object -
color A color object -

Switch object

Key Description
status URL to get RGB current state (1 or 0) or a status object.
powerOn URL to set the on state of the RGB device
powerOff URL to set the off state of the RGB device

Switch status object

Key Description
url URL to retrieve switch status
bodyRegEx Regular expression. When matched switch is considered "on".

Brightness object

Key Description
status URL to get RGB current brightness or a brightness status object.
url URL to set the current brightness of the RGB device or a brightness url object.
http_method (optional) The brightness specific HTTP method for set requests. If omitted defaults to http_method as specified in the root structure
max (optional) This value specifies the maximum Integer for brightness. For example, Philips Hue returns 254 when brightness is at 100 % (default: 100)

Brightness status object

Key Description
url URL to retrieve brightness status
bodyRegEx (optional) Regular expression to extract the brightness out of a response body. Example: "bri":([0-9]+)

Brightness url object

Key Description
url URL to set brightness status
body relevant, if the http_method is PUT/POST. this body is sent to the url. you can use a placeholder (%s) within the body. example: {"bri": %s}

Color object

Key Description
status URL to get RGB current colour (HEX value) or a color status object.
url URL to set the RGB colour value (HEX value) or a color url object.
brightness Whether or not the plugin should include brightness data in color HEX data (true or false). When true brightness will be controllable in HomeKit but will be changed through changing RGB values.
http_method (optional) The brightness specific HTTP method for set requests. If omitted defaults to http_method as specified in the root structure

Color status object

Key Description
url URL to retrieve color status
bodyRegEx (optional) Not yet supported

Color url object

Key Description
url URL to set color status
body relevant, if the http_method is PUT/POST. this body will be sent to the url. you can use following placeholders: %s (hex-rgb), %xy-x, %xy-y. Example: {"xy": [%xy-x,%xy-y]} or {"rgb": "%s"}

Device responses

Pull method: HomeBridge polls

All .status urls expect a 200 HTTP status code.

switch.status Can be configured to parse the body to determine the switchstatus. When the specified switch.status.bodyRegEx matches the body theswitch is considered to be in the on status. If this parameter is left outswitch.status expects 0 for Off, and 1 for On.

All other .status urls expect a body of a singlestring with no HTML markup.

  • brightness.status expects a number from 0 to 100.
  • color.status expects a 6-digit hexidemial number.

Push responses: Device pushes updates

This accessory supports push notification from the physical device viahomebridge-http-notification-server. This allows the device to modify theswitch's status by pushing the new status instead of Homebridge pulling it.This can be realized by supplying the notificationID as part of this accesory's configuration.Your device should then push the On characteristic towards the notification server.E.g. a POST request towards http://<homebridge-host>:<notification-server-port>/<notificationID> with the followingbody:

{
   "characteristic": "On",
   "value": true
}

To get more details about the push configuration have a look at the notification server'sREADME.

  • 英文原方: https://pushmodule.slact.net/protocol.html 简单的HTTP推协议 1 介绍    1.1目的       本协议的初衷是提供一种HTTP客户端透明长连接的支持,在服务端连接大部分时间都是空闲的,也不会被中继传递。         1.2 一般性的说明        略      1.3 术语    本规范使用一系列的名词来指代协议中的碰到的对象

 相关资料
  • homebridge-http-rgb-bulb Supports HTTP/HTTPS devices on Homebridge Platform. This plugin requires/uses a simple interface with the enpoint (only a set color URI and a get color URI). I decided to crea

  • ESP32 RGB LED for homebridge This is a project made for homebridge-better-http-rgb on HomeBridge. HTTP server implemented from lwip-allnetworks. Sample HomeBridge config: { "bridge": { "name

  • homebridge-fake-rgb An homebridge plugin that create an Fake RGB Bulb HomeKit accessory Installation Follow the instruction in homebridge for the homebridge server installation. The plugin is publishe

  • homebridge-gpio-rgb-ledstrip RPi GPIO based LED Strip plugin for Homebridge Due to all the changes and updated that have occured in Homebridge since the original release of this plugin, i decided to r

  • homebridge-http-lightbulb Plugin homebridge-http-lightbulb is a Homebridge plugin with which you can configureHomeKit light bulbs which forward any requests to a defined http server. This comes in han

  • homebridge-http-switch Plugin homebridge-http-switch is a Homebridge plugin with which you can configureHomeKit switches which forward any requests to a defined http server. This comes in handy when y