- 积分
- 580
- 金钱
- 515
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
高级会员
- 积分
- 580
- 金钱
- 515
- HASS币
- 0
|
发表于 2025-7-24 14:13:42
|
显示全部楼层
[
{
"id": "390285781bff0ead",
"type": "server-state-changed",
"z": "80e78a6215a3f960",
"d": true,
"name": "虚拟事件变化",
"server": "server-id-placeholder",
"version": 6,
"outputs": 1,
"exposeAsEntityConfig": "",
"entities": {
"entity": [
"event.placeholder_virtual_event"
],
"substring": [],
"regex": []
},
"outputInitially": false,
"stateType": "str",
"ifState": "",
"ifStateType": "str",
"ifStateOperator": "is",
"outputOnlyOnStateChange": true,
"for": "0",
"forType": "num",
"forUnits": "minutes",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": false,
"ignoreCurrentStateUnavailable": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
}
],
"x": 110,
"y": 520,
"wires": [
[
"479445f1a1a4a7d4"
]
]
},
{
"id": "479445f1a1a4a7d4",
"type": "function",
"z": "80e78a6215a3f960",
"d": true,
"name": "提取虚拟事件",
"func": "// let attributes = msg.data.old_state.attributes.event_types[0][\"事件名称\"];\nlet attributes = msg.data.old_state.attributes.事件名称;\nmsg.attributes = attributes;\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 300,
"y": 520,
"wires": [
[
"331e59e70c83e184",
"197e62524ad2816d",
"1e2ac1102902aa61"
]
]
},
{
"id": "331e59e70c83e184",
"type": "switch",
"z": "80e78a6215a3f960",
"d": true,
"name": "",
"property": "attributes",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "虚拟事件A",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 470,
"y": 520,
"wires": [
[
"fea5783cb28beef8"
]
]
},
{
"id": "server-id-placeholder",
"type": "server",
"name": "My Home Assistant",
"version": 5,
"addon": false,
"rejectUnauthorizedCerts": false,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "id",
"deviceSelector": "id",
"entitySelector": "friendlyName",
"statusSeparator": "at: ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "h23",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": true
}
]
但是实测,在nodered里反应速度很慢,比在自动化里慢2s以上,在意时效性,可以用创建一个辅助变量,在自动化里用虚拟事件操作辅助变量,再在nodered里用辅助变量触发后续操作 |
|