本帖最后由 lidicn 于 2017-11-2 16:25 编辑
不会写插件?No problem!会敲命令就行
command line sensor 可以将任意命令行获取的数据、文本 转换成sensor。详细介绍参考官方文档
https://home-assistant.io/components/sensor.command_line/
fortune命令介绍参看下面链接
http://www.ruanyifeng.com/blog/2015/04/fortune.html
安装fortune:
sudo apt-get install fortune
安装中文谚语、唐诗三百首、宋词一百首数据库
git clone --recursive https://github.com/ruanyf/fortunes.git
复制数据库到用户文件夹
sudo mv fortunes/data/* /usr/share/games/fortunes/
测试下能不能正常使用
fortune -e fortunes chinese tang300 song100
配置yaml
sensor: - platform: command_line
name: fortune_chinese
command: "/usr/games/fortune chinese"
scan_interval: 18000
- platform: command_line
name: fortune_tang
command: "/usr/games/fortune tang300"
value_template: '{{ value | replace("[32m", "") | replace("[m", "") | replace("[33m", "") }}'
scan_interval: 18000
- platform: command_line
name: fortune_song
command: "/usr/games/fortune song100"
value_template: '{{ value | replace("[32m", "") | replace("[m", "") | replace("[33m", "") }}'
scan_interval: 18000
- platform: command_line
name: fortune_fortunes
command: "/usr/games/fortune fortunes"
scan_interval: 18000
homeassistant:
customize:
sensor.fortune_chinese:
friendly_name: 中文谚语
homebridge_hidden: hidden
icon: mdi:comment-text
sensor.fortune_tang:
friendly_name: 唐诗三百首
homebridge_hidden: hidden
icon: mdi:comment-text
sensor.fortune_song:
friendly_name: 宋词一百
homebridge_hidden: hidden
icon: mdi:comment-text
sensor.fortune_fortunes:
friendly_name: 英文谚语
homebridge_hidden: hidden
icon: mdi:comment-text
附件有写好的yaml
|