电子发烧友App

硬声App

0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看威廉希尔官方网站 视频
  • 写文章/发帖/加入社区
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示
创作
电子发烧友网>电子资料下载>电子资料>通过HomeKit应用程序执行自定义

通过HomeKit应用程序执行自定义

2022-04-20 | zip | 0.00 MB | 次下载 | 免费

资料介绍

授权协议 Readme
开发语言 JavaScript
操作系统 跨平台
软件类型 开源软件
所属分类 其他开源物联网

软件简介

homebridge-script2

Execute custom scripts via homekit apps.

Core of the code written by @xxcombat. Great plugin that has served me well. Original plugin homebridge-script.

Because it appears that the original homebridge-script plugin has stopped being maintained and supported and PR's are also not being accepted. I've updated it to allow for executing a state script or work by checking for the existance of a file. Thanks to @ybizeul for the code snipet that allows for state.sh to execute. This plugin also works with the latest file-exists that broke the original plugin. While this fork depends on file-exists there is no need to install it seperately for this fork, as i've included it as a dependency.

Installation

(Requires node >=6.0.0)

  1. Install homebridge using: npm install -g homebridge
  2. Install this plugin using: npm install -g homebridge-script2
  3. Update your configuration file. See examples below that show the plugin working by using filestate for current state check as well as an example using state.sh script for current state check.
  4. Make sure scripts have been made executable (chmod +x scriptname.sh) and also accessible by the homebridge user.

For autostart homebridge with OSX copy com.homebridge.startup.plist to /Library/LaunchDaemons

Homebridge-script configuration parameters

Name Value Required Notes
accessory "Script2" yes Must be set to "Script2" and is required
name (custom) yes Name of accessory that will appear in homekit app and is required
on (custom) yes Location of script to execute the on action and is required
off (custom) yes Location of script to execute the off action and is required
fileState (custom) fileState or state is required (see note) Location of file that flags on or off current state. If this is configured the plugin will use the existence of this file to determine the current on or off state. If file exists, accessory is determined to be on. If file does not exist, accessory is determined to be off. This is not required. But if set, it will override using the state script. fileState or state must be configured. Use full path when setting this it's value. Do not use "~/".
state (custom) fileState or state is required (see note) Location of script to execute the current state check. It must output to stdout the current state. It is not required if fileState is being used instead. fileState or state must be configured.
on_value (custom) no* (see note, default set to "true") Used in conjunction with the state script. If using the state script this is the value that will be used to match against the state script output. If this value matches the output, then the accessory will be determined to be on. Required if using state script.
unique_serial (custom) no (default set to "Script2 Serial number") If you have more than one "accessory" configured, please set unique values for each accessory. Unique values per accessory required for the Eve app.

Configuration

Configuration example 1, using filestate for current state check:

"accessories": [
	{
              "accessory": "Script2",
              "name": "RPC3 Socket 1",
              "on": "/var/homebridge/rpc3control/on.sh 1",
              "off": "/var/homebridge/rpc3control/off.sh 1",
              "state": "/var/homebridge/rpc3control/state.sh 1",
              "fileState": "/var/homebridge/rpc3control/script1.flag",
              "on_value" : "true",
	      "unique_serial" : "1234567"
	}
]

Notes

Using the above configuration as an example:
  • The on.sh script executes when you turn on the accessory via a homekit app. (In this case we are the using existence of a file to determine on or off current state, so you must insure the on.sh script creates the configured fileState file.
  • The off.sh script executes when you turn off the accessory via a homekit app. ( In this case we are using existence of a file to determine on or off current state, insure the off.sh script deletes the configured fileState file.)
  • The state.sh script in this case would not execute as fileState parameter overrides its use.
  • The configured fileState file is used as a flag. When the homekit app checks for current state it checks for the existence of this file. If it exists, current state is on. If it does not exist, current state is off.
  • The on_value in this case is not being used as it is only used when the state script is used to check for current state.

Configuration example 2, executing state.sh script for current state check:

"accessories": [
	{
              "accessory": "Script2",
              "name": "Alarm of bike",
              "on": "~/on.sh",
              "off": "~/off.sh",
              "state": "~/state.sh",
              "on_value" : "true",
	      "unique_serial" : "1234567"
	}
]

Notes

Using the above configuration as an example:
  • The on.sh script executes when you turn on the accessory via a homekit app. (In this case we are executing a state script to determine on or off current state.)
  • The off.sh script executes when you turn off the accessory via a homekit app. ( In this case we are executing a state script to determine on or off current state.)
  • The state.sh script in this case would be executed to check current state. Insure that this script outputs to stdout the matching on value as configured by the on_value config parameter. If the on_value matches the on value output of this script then the accessory will be determined to be on.
  • The configured fileState file is not used in this example. Because it was not configured, the state script is being used.
  • The on_value in this case is used to match against the state script output. If the value matches the output of the state script, the accessory is determined to be on.
 

下载该资料的人也在下载 下载该资料的人还在阅读
更多 >

评论

查看更多

下载排行

本周

  1. 1山景DSP芯片AP8248A2数据手册
  2. 1.06 MB  |  532次下载  |  免费
  3. 2RK3399完整板原理图(支持平板,盒子VR)
  4. 3.28 MB  |  339次下载  |  免费
  5. 3TC358743XBG评估板参考手册
  6. 1.36 MB  |  330次下载  |  免费
  7. 4DFM软件使用教程
  8. 0.84 MB  |  295次下载  |  免费
  9. 5元宇宙深度解析—未来的未来-风口还是泡沫
  10. 6.40 MB  |  227次下载  |  免费
  11. 6迪文DGUS开发指南
  12. 31.67 MB  |  194次下载  |  免费
  13. 7元宇宙底层硬件系列报告
  14. 13.42 MB  |  182次下载  |  免费
  15. 8FP5207XR-G1中文应用手册
  16. 1.09 MB  |  178次下载  |  免费

本月

  1. 1OrCAD10.5下载OrCAD10.5中文版软件
  2. 0.00 MB  |  234315次下载  |  免费
  3. 2555集成电路应用800例(新编版)
  4. 0.00 MB  |  33566次下载  |  免费
  5. 3接口电路图大全
  6. 未知  |  30323次下载  |  免费
  7. 4开关电源设计实例指南
  8. 未知  |  21549次下载  |  免费
  9. 5电气工程师手册免费下载(新编第二版pdf电子书)
  10. 0.00 MB  |  15349次下载  |  免费
  11. 6数字电路基础pdf(下载)
  12. 未知  |  13750次下载  |  免费
  13. 7电子制作实例集锦 下载
  14. 未知  |  8113次下载  |  免费
  15. 8《LED驱动电路设计》 温德尔著
  16. 0.00 MB  |  6656次下载  |  免费

总榜

  1. 1matlab软件下载入口
  2. 未知  |  935054次下载  |  免费
  3. 2protel99se软件下载(可英文版转中文版)
  4. 78.1 MB  |  537798次下载  |  免费
  5. 3MATLAB 7.1 下载 (含软件介绍)
  6. 未知  |  420027次下载  |  免费
  7. 4OrCAD10.5下载OrCAD10.5中文版软件
  8. 0.00 MB  |  234315次下载  |  免费
  9. 5Altium DXP2002下载入口
  10. 未知  |  233046次下载  |  免费
  11. 6电路仿真软件multisim 10.0免费下载
  12. 340992  |  191187次下载  |  免费
  13. 7十天学会AVR单片机与C语言视频教程 下载
  14. 158M  |  183279次下载  |  免费
  15. 8proe5.0野火版下载(中文版免费下载)
  16. 未知  |  138040次下载  |  免费