本帖最后由 小灰 于 2018-12-5 01:41 编辑
利用command_line ,首先用python写了一个爬虫的。configuration.yaml里面配置好之后,首页并没有出现相应的图标。
sensor:
- platform: command_line
name: “power”
command: "python3 /usr/share/hassio/homeassistant/custom_components/sensor/querypower.py"
scan_interval: 3600
- platform: command_line
name: "test"
command: "python3 /usr/share/hassio/homeassistant/custom_components/sensor/test.py"
测试没有效果,然后就写了一个test.py,只输出hello world
print("hello world")
然而,首页依旧没有显示
想请问一下python文件需要怎么传值,return 还是 print,什么类型的?sensor怎么使用?我看大佬cxlwill的技术小站里关于command_line用的就是print
2018-12-04 13:36:13 ERROR (SyncWorker_14) [homeassistant.components.sensor.command_line] Command failed: /usr/games/fortune song100
2018-12-04 13:36:13 ERROR (SyncWorker_16) [homeassistant.components.sensor.command_line] Command failed: python3 /usr/share/hassio/homeassistant/custom_components/sensor/querypower.py
2018-12-04 13:36:13 ERROR (SyncWorker_0) [homeassistant.components.sensor.command_line] Command failed: python3 /usr/share/hassio/homeassistant/custom_components/sensor/tide.py
2018-12-04 13:36:13 ERROR (SyncWorker_8) [homeassistant.components.sensor.command_line] Command failed: python3 /usr/share/hassio/homeassistant/custom_components/sensor/test.py
看了一下日志
2018-12-04 17:22:53 ERROR (SyncWorker_14) [homeassistant.components.sensor.command_line] Command failed: python3 /usr/share/hassio/homeassistant/custom_components/sensor/querypower.py
在另一个帖子里也看到了同样的情况,他的是树莓派,添加了环境变量之后就解决了,我按照他的设置,没成功。
我的是Docker下安装hassio,不知道该怎么设置,求大佬帮忙,谢谢!
|