简介
Homebridge-pitherm 是一个基于 Raspberry Pi 温度传感器的 npm 包,可以通过 homebridge 将 Raspberry Pi 上的温度数据接入 HomeKit 中。它简单易用,适用于需要控制室内温度的项目。
安装
在安装 homebridge-pitherm 之前,请确保已安装 homebridge,并且 homebridge 已经成功运行。homebridge-pitherm 只支持 Raspberry Pi 上的 DS18B20 温度传感器。
步骤:
安装 homebridge-pitherm:
npm install -g homebridge-pitherm
配置
在 homebridge 的配置文件中添加以下配置:
-- -------------------- ---- ------- - ------------ - - ------- ---------- ----------- --- ------- --------- - - -
字段说明:
字段名 | 说明 |
---|---|
name | (必填) 插件名称,可以随意命名。 |
sensorId | (必填) 温度传感器 ID,视具体情况而定。 |
type | (必填) 温度传感器类型,目前仅支持 DS18B20。 |
interval | (选填) 更新温度数据的时间间隔(秒),默认为 60 秒。 |
scale | (选填) 温度数据的取值范围,默认为 Celsius。可选值为 Celsius 和 Fahrenheit。 |
使用
在 homebridge 配置文件中添加 homebridge-pitherm 插件后,可以通过 Apple 的 Home 应用或 Siri 控制温度。
示例代码
以下是一个简单的示例,将 homebridge-pitherm 插件与 homebridge 集成,在命令行中输入命令即可更新温度数据:
-- -------------------- ---- ------- ----- ------------- - -------------------------- ----- ------- - ------------------------------ ----- --- - -------------------------- ----- -------------- - --------------- ----- --------------- ------- ---------------------- - ----------- ----- ----------- ----------- - ---------- ----------- ------------ ------------------ ------- --- --------------------- ------------- ----- - - ------------------------ ------------ - --- ------------------- ------- ----------- --------- ---------------- - - ---------------------- -- - - --------------------------- - --------- ---------------------------- - ---------- --------------------------- - ------ ---------------------- - --------------- -------------- - ----------------
来源:JavaScript中文网 ,转载请注明来源 https://www.javascriptcn.com/post/6005590a81e8991b448d672a