[
{
"id": "0446174ddff59de7",
"type": "server-state-changed",
"z": "a479b09bca78b004",
"name": "sensor.ble_devices_scanner",
"server": "9ba8ac3a.124df",
"version": 4,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": "sensor.ble_devices_scanner",
"entityidfiltertype": "exact",
"outputinitially": false,
"state_type": "str",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"output_only_on_state_change": 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": 160,
"y": 2700,
"wires": [
[
"6e5f33bf90c43980",
"e593b1885b6b2234"
]
]
},
{
"id": "0e5779ebf176611c",
"type": "switch",
"z": "a479b09bca78b004",
"name": "",
"property": "payload.name",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "JDY-23",
"vt": "str"
},
{
"t": "eq",
"v": "HK1RBOX-X4",
"vt": "str"
},
{
"t": "eq",
"v": "Mi Smart Band 6",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 530,
"y": 2700,
"wires": [
[
"b49c40ca02e61e60"
],
[],
[]
]
},
{
"id": "b49c40ca02e61e60",
"type": "function",
"z": "a479b09bca78b004",
"name": "获取当前时间,并保存到 flow 里",
"func": "//使用data对象的getTime方法获取开始时间,\n//并存到'startTime'里\n//flow.set就是设置全局变量\nflow.set('mc23chufashijian', new Date().getTime());\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 790,
"y": 2700,
"wires": [
[]
]
},
{
"id": "6e5f33bf90c43980",
"type": "json",
"z": "a479b09bca78b004",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 390,
"y": 2700,
"wires": [
[
"0e5779ebf176611c"
]
]
},
{
"id": "285681c8cd67c218",
"type": "ha-binary-sensor",
"z": "a479b09bca78b004",
"name": "客厅大门开关状态",
"entityConfig": "aed3403e58b00ac1",
"version": 0,
"state": "payload",
"stateType": "msg",
"attributes": [],
"inputOverride": "allow",
"outputProperties": [],
"x": 790,
"y": 2840,
"wires": [
[]
]
},
{
"id": "e593b1885b6b2234",
"type": "function",
"z": "a479b09bca78b004",
"name": "计算出实际延时时间 = 当前时间-starttime",
"func": "var currentTime = new Date().getTime();\n//获取当前时间\nvar stratTime = flow.get('mc23chufashijian', stratTime);\n//用flow.get获取之间节点储存的开始时间\n//flow.get,就是获取全局变量\nvar timeElapsed = (currentTime - stratTime) / 1000;\n//计算时间差并从毫秒转换为秒\nvar zhuangtai;\nif (timeElapsed > 20){\n zhuangtai = 'off';\n}\nif (timeElapsed < 20) {\n zhuangtai = 'on';\n}\nmsg.payload = zhuangtai;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 2840,
"wires": [
[
"285681c8cd67c218"
]
]
},
{
"id": "9ba8ac3a.124df",
"type": "server",
"name": "hass_kt",
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "",
"statusSeparator": "",
"enableGlobalContextStore": false
},
{
"id": "aed3403e58b00ac1",
"type": "ha-entity-config",
"server": "9ba8ac3a.124df",
"deviceConfig": "434da9ebbf21b4f6",
"name": "客厅大门开关状态",
"version": "6",
"entityType": "binary_sensor",
"haConfig": [
{
"property": "name",
"value": "客厅大门开关状态"
},
{
"property": "icon",
"value": ""
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": "door"
}
],
"resend": false,
"debugEnabled": false
},
{
"id": "434da9ebbf21b4f6",
"type": "ha-device-config",
"name": "客厅大门开关状态",
"hwVersion": "",
"manufacturer": "Node-RED",
"model": "",
"swVersion": ""
}
]