一个支持 Homebridge 网络钩子的 http 插件: https://GitHub.com/nfarina/homebridge
一个支持 Homebridge 网络钩子的 http 插件: https://GitHub.com/nfarina/homebridge
A http plugin with support of webhooks for Homebridge.
The plugin gets its states from any system that is calling the url to trigger a state change.
Currently supports contact, motion, occupancy, smoke sensors, switches, push buttons, lights (only on/off and brightness), temperature sensors, humidity sensors, thermostats, CO2 sensors and leak sensors.
npm install -g homebridgenpm install -g homebridge-http-webhooksTo retrieve the current state, you need to call the url http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToTrigger
The returned JSON format is:
{
"success": true,
"state": cachedState
}To trigger a change of a boolean accessory you need to call the url http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToTrigger&state=NEWSTATE
Use only the text true or false. Do not use numbers 1 or 0.
For contact sensors the value for NEWSTATE is either true for contact or false for no contact. If autoRelease is used, then the state will be released after autoReleaseTime, if not set 5 seconds.
For motion sensors the value for NEWSTATE is either true for motion detection or false for no motion. If autoRelease is used, then the state will be released autoReleaseTime, if not set 5 seconds.
For occupancy sensors the value for NEWSTATE is either true for occupancy detection or false for no occupancy. If autoRelease is used, than the state will be released autoReleaseTime, if not set 5 seconds.
For smoke sensors the value for NEWSTATE is either true for smoke detection or false for no smoke.
For switches the value for NEWSTATE is either true for on or false for off.
For push buttons the value for NEWSTATE is true. The button will be released automatically.
For lights the value for NEWSTATE is either true for on or false for off.
For outlets the value for NEWSTATE is either true for on or false for off.
For outlets the additional state stateOutletInUse is available. The value for NEWSTATE is either true for on or false for off and
can be changed by calling the url http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToTrigger&stateOutletInUse=NEWSTATE
For fanv2 the value for NEWSTATE is either true for on or false for off.
For valves/faucets the value for NEWSTATE is either true for on or false for off.
For valves the additional state statusFault is available. The value for NEWSTATE is either true for on or false for off and
can be changed by calling the url http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToTrigger&statusFault=NEWSTATE
For switches you can call the url from any system to switch the switch on or off.
For push buttons you can call the url from any system to push the button. The button will be released automatically.
Doorbells require 2 parameters: accessoryId and the event to trigger:
http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&event=EVENTExamples:
http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&event=0http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&event=2Doorbells are shown as a stateless programmable switch. When the doorbell is rung by calling the webhooks url, it generates the notification "Roomname doorbell rang." and executes any actions which have been added in the Home app to the stateless programmable switch. When adding the doorbell to the Home app, it will ask for somme options to recognise familiar faces. These can be ignored, as no camera is associated with the doorbell.
For lights you can call the url from any system to switch the light on or off.
For outlets you can call the url from any system to switch the outlet on or off.
For fanv2 you can call the url from any system to switch the fanv2 on or off.
To update a numeric accessory, you need to call the url http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&value=NEWVALUE
For temperature sensors the value for NEWVALUE is the new temperature reading.
For light sensors the value for NEWVALUE is the new light intensity in lux (as float).
For humidity sensors the value for NEWVALUE is the new relative humidity percentage reading.
For air quality sensors the value for NEWVALUE is the new air quality value (Between 1-5, 1 Excellent).
For a CO2 sensor the value for NEWVALUE is the new PPM reading.
For leak sensors the value for NEWVALUE is the new leak state value (1 for leak, 0 for dry).
For light brightness the value for NEWVALUE is the new light brightness (as integer, between 0 and 100 with respect to brightness factor).
To update a thermostat, you can update four different values:
http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate¤ttemperature=NEWVALUEhttp://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&targettemperature=NEWVALUEhttp://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate¤tstate=NEWVALUEhttp://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&targetstate=NEWVALUETo update the state of security, you can update two different values:
http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate¤tstate=NEWVALUEhttp://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&targetstate=NEWVALUETo update a garage door opener, you can update three different values:
http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate¤tdoorstate=NEWVALUEhttp://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&targetdoorstate=NEWVALUEhttp://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&obstructiondetected=NEWVALUEStateless switches requires 3 parameters: accessoryId, buttonName and the event to trigger:
http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&buttonName=theButtonName&event=EVENT
To update a lock mechanism, you can update two different values:
http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&lockcurrentstate=NEWVALUEhttp://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&locktargetstate=NEWVALUETo update a window covering you can update three different values:
http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate¤tposition=%s (%s is replaced by corresponding current position)http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&targetposition=%s (%s is replaced by corresponding target position)
Setting of target position you can realize by send link to: open, 20%, 40%, 60% 80% and closehttp://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&positionstate=0 (1 or 2) (position state is not mandatory and not fully tested yet)If you don't use callbacks to let your covering give feedback of current position back to HomeKit you can set "auto_set_current_position" to true.
To update a fanv2 you can update five different values:
http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&speed=%s (%s is replaced by fan's rotation speed)http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&swingMode=0 (or 1) (To use this feature, "enableSwingModeControls" in config must be set to true.)http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&rotationDirection=0 (or 1)http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&lockstate=0 (or 1) (To use this feature, "enableLockPhysicalControls" in config must be set to true.)http://yourHomebridgeServerIp:webhook_port/?accessoryId=theAccessoryIdToUpdate&targetState=0 (or 1)(To use this feature, "enableTargetStateControls" in config must be set to true.)For valves/faucets you can call the url from any system to switch the valve on or off.
Example config.json:
…The cache directory is used to cache the state of the accessories. It must point to a valid and empty directory and the user that runs homebridge must have write access.
If you want to create a secure connection for the webhooks you need to enable it by setting https to true. Then a self signed ssl certificate will be created automatically and a secure connection will be used. If you want to use your own generated ssl certificate you can do this by setting the values for https_keyfile and https_certfile to the corresponding file paths.
暂无开放 Issues,或尚未同步最近议题。