RT,
用了2种方法获取,第一种时命令行,貌似有问题。频率一直显示不变!
第二种是通过 mqtt,宿主public cpu频率消息给broker,ha订阅。
- platform: command_line
name: cpu freq
command: " cat /sys/devices/system/cpu/cpufreq/policy?/cpuinfo_cur_freq "
value_template: "{{ value | multiply(0.000001) | round(1) }}"
unit_of_measurement: "GHz"
scan_interval: 60
- platform: mqtt
name: cpu freq mqtt
state_topic: "getinfo/cpufreq"
value_template: "{{ value | multiply(0.000001) | round(1) }}"
unit_of_measurement: "GHz"
scan_interval: 60
icon: mdi:cpu-64-bit
宿主开一个crontab
*/1 * * * * mosquitto_pub -r -L mqtt://username:password@ip:1883/getinfo/cpufreq -m `cat /sys/devices/system/cpu/cpufreq/policy?/cpuinfo_cur_freq`
此贴就是起到一个抛砖引玉的作用,所有宿主的信息,都可以通过mqtt,供容器使用。
|