本帖最后由 hunl0613 于 2023-12-23 15:23 编辑
msg.payload={
"name":"38度开关",
"command_topic": "homeassistant/switch/wanghe_switch_38/set",
"state_topic":"homeassistant/switch/wanghe_switch_38/state",
"unique_id":"wh101",
"device":{
"identifiers":[
"wanghe101"
],
"name":"热水器"
},
"payload_on": "ON",
"payload_off": "OFF",
"state_on": "ON",
"state_off": "OFF",
"qos": 0,
"retain": true,
"command_on_template": "ON",
"command_off_template": "OFF",
"state_on_template": "ON",
"state_off_template": "OFF",
"value_template": "{{ value_json.state }}"
}
msg.topic = "homeassistant/switch/wanghe_switch_38/config";
msg.retain = true; // 保留配置主题
return msg;
请问上面node-red代码向mqtt发送switch,发送ON或OFF到homeassistant/switch/wanghe_switch_38/state主题可以更改状态,但在homeassistant中mqtt生成的switch中没法点击更改状态,添加代码 "optimistic": true后可以更改状态,但显示的开关样式为turn而不是switch,
请问如何解决让按钮可以更改状态并样式为switch
flows .rar
(1.46 KB, 下载次数: 0)
|