没有学过js,修改了下,可以控制开关了,但MQTT开关出现回弹,node-red 的 state 状态是有反馈,不知那个环节出现问题。现将MQTT改为 optimistic: true,没有实时状态反馈,但也可以将就使用。
hass mqtt 开关
- platform: mqtt
unique_id: "S000000101"
name: "电饭煲"
state_topic: "home/switche/broadlink-01/state"
command_topic: "home/switche/broadlink-01/setup"
value_template: "{{ value_json['state'] }}"
payload_on: '{"key":"state","action":"on"}'
payload_off: '{"key":"state","action":"off"}'
state_on: true
state_off: false
optimistic: true
- platform: mqtt
unique_id: "S000000201"
name: "捕蝇器"
state_topic: "home/switche/broadlink-02/state"
command_topic: "home/switche/broadlink-02/setup"
value_template: "{{ value_json['state'] }}"
payload_on: '{"key":"state","action":"on"}'
payload_off: '{"key":"state","action":"off"}'
state_on: true
state_off: false
optimistic: true
- platform: mqtt
unique_id: "S000000301"
name: "二楼厅"
state_topic: "home/switche/broadlink-03/state"
command_topic: "home/switche/broadlink-03/setup"
value_template: "{{ value_json['state'] }}"
payload_on: '{"key":"state","action":"on"}'
payload_off: '{"key":"state","action":"off"}'
state_on: true
state_off: false
optimistic: true
- platform: mqtt
unique_id: "S000000401"
name: "洗手间"
state_topic: "home/switche/broadlink-04/state"
command_topic: "home/switche/broadlink-04/setup"
value_template: "{{ value_json['s1'] }}"
payload_on: '{"key":"s1","action":"on"}'
payload_off: '{"key":"s1","action":"off"}'
state_on: true
state_off: false
鸿雁插座.json
(14.44 KB, 下载次数: 2)
|