Home Assistant 用 Command line Sensor 获取硬盘温度

Home Assistant 获取 CPU 温度比较简单,官方的示例中即有。

Home Assistant 支持 hddtemp 获取硬盘温度,只是 hddtemp 不支持USB移动硬盘,所以使用 smartmontools 通过 S.M.A.R.T 获取温度。

首先安装 smartmontools,

apt-get install smartmontools

Home Assistant 用 Command line Sensor 获取温度数据,参数中的 -d sat 是关键,

#CPU温度
- platform: command_line
name: CPU Temperature
command: "cat /sys/class/thermal/thermal_zone0/temp"
unit_of_measurement: "°C"
scan_interval: 300
#硬盘温度
- platform: command_line
name: HDD Temperature
command: "smartctl -d sat -a /dev/sda | grep Temperature_Celsius | cut -c88-89"
unit_of_measurement: "°C"
scan_interval: 300

相关链接:https://home-assistant.io/components/sensor.command_line/

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注