- 积分
- 792
- 金钱
- 610
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
高级会员
- 积分
- 792
- 金钱
- 610
- HASS币
- 0
|
发表于 2017-11-22 13:31:25
|
显示全部楼层
本帖最后由 yuzheheart 于 2017-11-22 17:07 编辑
configuration.yaml@@@@@@@@@@@@@@@@@@@@@@配置如下:
# MQTT SERVER
mqtt:
broker: 127.0.0.1
port: 1883
client_id: hass
keepalive: 60
username: pi
password: xxxx
discovery: true
switch:
- platform: mqtt
name: "Sonoff_bedroom_1"
state_topic: "stat/Sonoff_bedroom_1/POWER"
command_topic: "cmnd/Sonoff_bedroom_1/POWER"
qos: 1
payload_on: "ON"
payload_off: "OFF"
retain: true
SONOFF里面配置如下:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
MQTT Host | 192.168.100.93 | MQTT Port | 1883 | MQTT Client &
Fallback Topic | DVES_8124B8 | MQTT User | pi | MQTT Topic | Sonoff_bedroom_1 | MQTT Group Topic | sonoffs | MQTT Full Topic | cmnd/Sonoff_bedroom_1/ |
====================================================================
pi@hassbian:~ $ mosquitto_sub -u pi -P xxxx -t stat/Sonoff_bedroom_1/POWER -v
stat/Sonoff_bedroom_1/POWER ON
stat/Sonoff_bedroom_1/POWER OFF
我用上面的指令监听MQTT,在WEB开关SONOFF,可以正常监听到消息。
监听消息:
mosquitto_sub -u pi -P Mqtt1258 -t stat/Sonoff_bedroom_1/POWER -v
mosquitto_sub -u pi -P Mqtt1258 -t cmnd/Sonoff_bedroom_1/POWER -v
另外一个终端发布消息:
mosquitto_pub -h 192.168.100.93 -u pi -P xxxx -t cmnd/Sonoff_bedroom_1/POWER -m on
mosquitto_pub -h 192.168.100.93 -u pi -P xxxx -t cmnd/Sonoff_bedroom_1/POWER -m off
也可以正常监听到消息,SONOFF开关也可以正常被控制。
我觉得问题还是出在homeassistant配置文件上。
从LOG里面来看有这样的错误。
pi@hassbian:/home/homeassistant/.homeassistant $ cat home-assistant.log
2017-11-22 16:50:27 ERROR (MainThread) [homeassistant.setup] Error during setup of component mqtt
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py", line 190, in _async_setup_component
result = yield from component.async_setup(hass, processed_config)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/__init__.py", line 374, in async_setup
will_message, birth_message, tls_version)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/__init__.py", line 451, in __init__
proto = mqtt.MQTTv311
AttributeError: module 'paho.mqtt.client' has no attribute 'MQTTv311'
2017-11-22 16:50:29 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of switch.mqtt. Setup failed for dependencies: mqtt
2017-11-22 16:50:29 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform switch.mqtt: Could not setup all dependencies.
|
|