|
楼主 |
发表于 2023-12-29 10:12:54
|
显示全部楼层
- platform: command_line
name: RaspInfo
scan_interval: 60
command: "python3 /config/scripts/host_monitor.py" # 脚本路径问题参考下面注意事项
json_attributes: # 键名可为大小写
- RAMinfo
- DISKinfo
- CPUuse
- CPUtemp
- platform: template
# 传感器列表
sensors:
# 实体名称:小写,下划线
cpu_temp:
# (可选)在前端显示的传感器昵称
friendly_name: "CPU Temperature"
# (可选)传感器数值的单位
unit_of_measurement: '℃'
#(必须)定义一个获取传感器状态(数值)的模板
# 这里就是获取上面定义的命令行传感器实体 sensor.raspinfo 的相应属性值,注意大小写
value_template: "{{state_attr('sensor.raspinfo', 'CPUtemp')}}"
# 以下配置类似,不再赘述
cpu_used:
friendly_name: "CPU Used"
# unit_of_measurement: '%'
value_template: "{{state_attr('sensor.raspinfo', 'CPUuse')}}"
ram_total:
friendly_name: "RAM total"
unit_of_measurement: 'MB'
value_template: "{{state_attr('sensor.raspinfo', 'RAMinfo')[0]}}"
ram_used:
friendly_name: "RAM used"
unit_of_measurement: 'MB'
value_template: "{{state_attr('sensor.raspinfo', 'RAMinfo')[1]}}"
ram_free:
friendly_name: "RAM free"
unit_of_measurement: 'MB'
value_template: "{{state_attr('sensor.raspinfo', 'RAMinfo')[2]}}"
disk_total:
friendly_name: "DISK total"
value_template: "{{state_attr('sensor.raspinfo', 'DISKinfo')[0]}}"
disk_used:
friendly_name: "DISK used"
value_template: "{{state_attr('sensor.raspinfo', 'DISKinfo')[1]}}"
disk_left:
friendly_name: "DISK left"
value_template: "{{state_attr('sensor.raspinfo', 'DISKinfo')[2]}}"
disk_percentage:
friendly_name: "DISK percentage"
value_template: "{{state_attr('sensor.raspinfo', 'DISKinfo')[3]}}" |
|