【发布时间】:2021-01-02 22:25:41
【问题描述】:
我有一个简单的灯控制器(在树莓上),它订阅 MQTT 消息“/floor1/terrace/lamps”,打开最多 9 个灯并通过“/floor1/terrace/lamps_r”发布新设置的模式。 此外,本地交换机也可能会更改此模式,因此会将其发布在“/floor1/terrace/lamps_r”上。该模式是一个数字,用于保存与灯输出相对应的位模式。
我想使用 node-red-dashboard 控制这些灯,并根据它们的当前状态更新它们,所以我创建了一个带有相应图案(月亮符号)的 ui-dropdown
流程接收“lamps_r”以在 ui-dropdown 上显示它(通过选定的消息传递)并在它更改为“lamps”时发送消息
这可以完美运行,但是在 mqtt 断开连接(中断或网络断开连接)之后,它会快速循环通过 ui-dropdown 中定义的模式。
这是流程
[
{
"id": "4ec0402f.174028",
"type": "mqtt out",
"z": "f6f2187d.f17ca8",
"name": "",
"topic": "floor1/terrace/lamps",
"qos": "0",
"retain": "false",
"broker": "26e8c216.d6cd06",
"x": 900,
"y": 200,
"wires": []
},
{
"id": "a6324306.af9eb8",
"type": "debug",
"z": "f6f2187d.f17ca8",
"name": "incoming",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 580,
"y": 320,
"wires": []
},
{
"id": "4097bb88.a6b6fc",
"type": "ui_dropdown",
"z": "f6f2187d.f17ca8",
"name": "",
"label": "Lamps",
"tooltip": "",
"place": "Select option",
"group": "83e0c62c.0828d8",
"order": 1,
"width": 0,
"height": 0,
"passthru": false,
"multiple": false,
"options": [
{
"label": "????????????????????????????????????",
"value": 0,
"type": "num"
},
{
"label": "????????????????????????????????????",
"value": 1,
"type": "num"
},
{
"label": "????????????????????????????????????",
"value": 56,
"type": "num"
},
{
"label": "????????????????????????????????????",
"value": 17,
"type": "num"
},
{
"label": "????????????????????????????????????",
"value": 170,
"type": "num"
},
{
"label": "????????????????????????????????????",
"value": 85,
"type": "num"
},
{
"label": "????????????????????????????????????",
"value": 255,
"type": "num"
}
],
"payload": "",
"topic": "",
"x": 510,
"y": 200,
"wires": [
[
"29bfc4ae.3bfd64"
]
]
},
{
"id": "1592291a.25645f",
"type": "mqtt in",
"z": "f6f2187d.f17ca8",
"name": "",
"topic": "floor1/terrace/lamps_r",
"qos": "2",
"datatype": "json",
"broker": "26e8c216.d6cd06",
"x": 320,
"y": 200,
"wires": [
[
"4097bb88.a6b6fc",
"a6324306.af9eb8"
]
]
},
{
"id": "123f5abc.e6551d",
"type": "comment",
"z": "f6f2187d.f17ca8",
"name": "MQTT message propagation",
"info": "the dropdown element only shows the received state if the message is passed through!\nTo avoid an endless cycle 'only_if_changed' filters the message propagation if the current state was changed already.",
"x": 640,
"y": 260,
"wires": []
},
{
"id": "7776ebb4.fafda4",
"type": "debug",
"z": "f6f2187d.f17ca8",
"name": "outgoing",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 930,
"y": 320,
"wires": []
},
{
"id": "29bfc4ae.3bfd64",
"type": "rbe",
"z": "f6f2187d.f17ca8",
"name": "",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"property": "payload",
"x": 670,
"y": 200,
"wires": [
[
"4ec0402f.174028",
"7776ebb4.fafda4"
]
]
},
{
"id": "26e8c216.d6cd06",
"type": "mqtt-broker",
"name": "Morpheus",
"broker": "morpheus.lan",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
},
{
"id": "83e0c62c.0828d8",
"type": "ui_group",
"name": "Default",
"tab": "c3af9807.77191",
"order": 1,
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "c3af9807.77191",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]
我是 node-red 的新手,对可能发生的事情一无所知。
【问题讨论】: