homebridge-ping-hostsPing state sensor plugin for homebridge

联合创作 · 2023-09-26 09:29

homebridge-ping-hosts

A ping state sensor plugin for homebridge (https://github.com/nfarina/homebridge).

Installation

  1. Install homebridge using: npm install -g homebridge
  2. Install this plugin: npm install -g --unsafe-perm @vectronic/homebridge-ping-hosts
  3. Update your config.json configuration file

Configuration

Example config.json entry:

    "platforms": [
		{
			"platform": "PingHosts",
			"hosts": [
				{
					"name": "Router",
					"host": "192.168.0.1",
					"interval": 60,
					"timeout": 25,
					"retries": 1
				},
				{
					"name": "Internet",
					"host": "1.1.1.1",
					"interval": 60,
					"timeout": 25,
					"retries": 1,
					"startup_as_failed": false,
					"closed_on_success": false
				}
			]
		}
	]

Notes

  • Hostnames are not currently supported, only IPv4 Addresses.
  • retries defaults to 1
  • timeout defaults to 25
  • interval defaults to 60
  • Works better if timeout * (1 + retries) < interval
  • On startup the sensor will default to a 'failed' ping state. This can be overridden by configuring startup_as_failed: false.
  • The sensor will have a "closed" state for successful pings and an "open" state for failed pings (or for any other issues). This can be overridden by configuring closed_on_success: false.

Permission Problem?

If you get an error which looks like:

Error: Operation not permitted
at new Socket (/usr/local/lib/node_modules/@vectronic/homebridge-ping-hosts/node_modules/raw-socket/index.js:47:14)

then you are probably running on a Linux based OS requiring the CAP_NET_RAW capability to be added to the NodeJS executable.

Try something like this:

sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
浏览 6
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报