本帖最后由 lyfff 于 2020-2-22 01:44 编辑
谢谢管理员回复,但是不用填的意思是留空吗?
我把那个项清空了,重新设置联网,用了两种方法来配置,都不成呀。
法一(按照hassmart.com):
- platform: mqtt
name: "Study Room Light"
state_topic: "hassmart/switch/hassmart_2key_8CA840_1/state"
command_topic: "hassmart/switch/hassmart_2key_8CA840_1/set"
qos: 1
retain: false
- platform: mqtt
name: "Mini Balcony Light"
state_topic: "hassmart/switch/hassmart_2key_8CA840_2/state"
command_topic: "hassmart/switch/hassmart_2key_8CA840_2/set"
qos: 1
retain: false
法二(按照考古帖):
- platform: mqtt
name: "Study Room Light"
state_topic: "home/hassmart-8CA840/key1/stat"
command_topic: "home/hassmart-8CA840/key1"
qos: 1
payload_on: "on"
payload_off: "off"
retain: true
- platform: mqtt
name: "Mini Balcony Light"
state_topic: "home/hassmart-8CA840/key2/stat"
command_topic: "home/hassmart-8CA840/key2"
qos: 1
payload_on: "on"
payload_off: "off"
retain: true
[solved]
并不是不用填,而是要填的。填好保存联网后,进入命令行,启动:
mosquitto_sub -t "#" -v -u <mqtt用户名> -P <mqtt密码> -h <服务器ip>
然后开一下开关,就会显示当前的mqtt服务器接收到开关的state信息(里面就有topic)。
然后例如我填入的topic是
hassmart/switch/hassmart_2key_8CA840
进入命令行看到的topic是
hassmart/switch/hassmart_2key_8CA840/008CA840/key1/stat
那么按照考古帖,对应的command_topic即是
hassmart/switch/hassmart_2key_8CA840/008CA840/key1/
问题解决。 |