|
|
发表于 2026-2-4 00:47:49
|
显示全部楼层
用events: state节点选择这个实体,然后接这个试试看:
[{"id":"f305986fc9a1675b","type":"function","z":"8061fcd8347eebb7","name":"提取虚拟事件","func":"// 确保对象路径存在,避免因为属性缺失导致脚本报错\nif (msg.data && msg.data.attributes) {\n \n // 获取 event_type 的值(即 \"有人出现了\")\n const eventType = msg.data.attributes.event_type;\n \n // 将其赋值给 msg.attributes(按照您的要求)\n msg.attributes = eventType;\n \n // 补充:如果你希望保留整个 attributes 对象,只是想加一个快捷访问方式\n // 可以写成 msg.event_type = eventType;\n}\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":695,"y":715,"wires":[["1f664d30db1e2a96"]]},{"id":"1f664d30db1e2a96","type":"switch","z":"8061fcd8347eebb7","name":"指令分发","property":"attributes","propertyType":"msg","rules":[{"t":"eq","v":"有人出现了","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":855,"y":715,"wires":[[]]}] |
|