|
发表于 2023-3-17 15:44:30
|
显示全部楼层
[
{
"id": "70eb9fe7.3ab83",
"type": "comment",
"z": "ac193d76.b37cd",
"name": "天气路况恶化提前出门",
"info": "## 原理简述\n1. 降雨概率大于75%\n2. 通勤时间大于常规时间\n3. 提前半个小时推送消息提醒用户提前出门",
"x": 220,
"y": 360,
"wires": []
},
{
"id": "f97d6824.1a5638",
"type": "api-current-state",
"z": "ac193d76.b37cd",
"name": "获取从家到公司的通勤时间",
"server": "a4e11aa1.558da8",
"halt_if": "",
"override_topic": true,
"override_payload": true,
"entity_id": "sensor.traffic_home_to_office",
"x": 580,
"y": 320,
"wires": [
[
"8b11990e.79cf48"
]
]
},
{
"id": "8b11990e.79cf48",
"type": "switch",
"z": "ac193d76.b37cd",
"name": "通勤时间大于30分钟",
"property": "data.state",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "30",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 820,
"y": 320,
"wires": [
[
"ea4f67.852ec098"
]
]
},
{
"id": "ae0604ce.837618",
"type": "api-current-state",
"z": "ac193d76.b37cd",
"name": "获取30分钟内的降雨概率",
"server": "a4e11aa1.558da8",
"halt_if": "",
"override_topic": true,
"override_payload": true,
"entity_id": "sensor.caiyun_minutely_probability_0",
"x": 570,
"y": 400,
"wires": [
[
"270f2a8b.dba5a6"
]
]
},
{
"id": "270f2a8b.dba5a6",
"type": "switch",
"z": "ac193d76.b37cd",
"name": "降雨概率超过80%",
"property": "data.state",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "80",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 810,
"y": 400,
"wires": [
[
"3c7956ed.65dfda"
]
]
},
{
"id": "bca9082d.4a9a48",
"type": "inject",
"z": "ac193d76.b37cd",
"name": "",
"topic": "指定时间触发",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "30 07 * * 1,2,3,4,5",
"once": false,
"onceDelay": 0.1,
"x": 240,
"y": 440,
"wires": [
[
"f97d6824.1a5638"
]
]
},
{
"id": "2b37ed2d.868062",
"type": "api-current-state",
"z": "ac193d76.b37cd",
"name": "获取一小时内最大降雨量",
"server": "a4e11aa1.558da8",
"halt_if": "",
"override_topic": true,
"override_payload": true,
"entity_id": "sensor.caiyun_minutely_precipitation",
"x": 570,
"y": 480,
"wires": [
[
"1086f8e7.d8e947"
]
]
},
{
"id": "1086f8e7.d8e947",
"type": "switch",
"z": "ac193d76.b37cd",
"name": "一小时内最大降雨量大于0.9mm",
"property": "data.state",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "0.9",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 830,
"y": 480,
"wires": [
[
"10025c7d.5d7144"
]
]
},
{
"id": "ea4f67.852ec098",
"type": "change",
"z": "ac193d76.b37cd",
"name": "转移变量",
"rules": [
{
"t": "move",
"p": "data.state",
"pt": "msg",
"to": "commuting_time",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1020,
"y": 320,
"wires": [
[
"ae0604ce.837618"
]
]
},
{
"id": "52f688a7.52dc18",
"type": "debug",
"z": "ac193d76.b37cd",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "commuting_time",
"x": 1340,
"y": 420,
"wires": []
},
{
"id": "3c7956ed.65dfda",
"type": "change",
"z": "ac193d76.b37cd",
"name": "转移变量",
"rules": [
{
"t": "move",
"p": "data.state",
"pt": "msg",
"to": "minutely_probability",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1020,
"y": 400,
"wires": [
[
"2b37ed2d.868062"
]
]
},
{
"id": "10025c7d.5d7144",
"type": "change",
"z": "ac193d76.b37cd",
"name": "转移变量",
"rules": [
{
"t": "move",
"p": "data.state",
"pt": "msg",
"to": "precipitation",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1040,
"y": 480,
"wires": [
[
"52f688a7.52dc18",
"3511a8ff.6afbf8",
"5ad984b1.be3c3c",
"9140fe96.69d89"
]
]
},
{
"id": "3511a8ff.6afbf8",
"type": "debug",
"z": "ac193d76.b37cd",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "minutely_probability",
"x": 1330,
"y": 480,
"wires": []
},
{
"id": "5ad984b1.be3c3c",
"type": "debug",
"z": "ac193d76.b37cd",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "precipitation",
"x": 1330,
"y": 540,
"wires": []
},
{
"id": "2fd6b27c.72729e",
"type": "function",
"z": "ac193d76.b37cd",
"name": "推送内容",
"func": "String.prototype.format= function(){\n //将arguments转化为数组(ES5中并非严格的数组)\n var args = Array.prototype.slice.call(arguments);\n var count=0;\n //通过正则替换%s\n return this.replace(/%s/g,function(s,i){\n return args[count++];\n });\n}\nvar message = \"突发状况,8点钟下雨概率为%s%, 预计到达公司所需时间为%s分钟,当前前进路路况%s,拥堵率为%s,小碧建议您提前出发。![图片](http://www.yourhawebsite.top:8123/local/traffic.jpg)[深圳气象局天气预测](http://www.szmb.gov.cn/qixiangfuwu/yubaofuwu/jinmingtianqiyubao/)![图片](http://www.yourhawebsite.top:8123/local/caiyunweather.png)\"\nmessage = message.format(msg.minutely_probability,msg.commuting_time,msg.payload,msg.data.attributes[\"拥堵所占百分比\"])\nmsg.payload = {};\nmsg.payload.data = {\"title\":\"天气路况预警\",\"message\":message};\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 540,
"y": 660,
"wires": [
[
"563fc4d7.55dedc",
"33924f16.c503b"
]
]
},
{
"id": "dd8e9c6a.685ab",
"type": "api-current-state",
"z": "ac193d76.b37cd",
"name": "获取关键道路路况",
"server": "a4e11aa1.558da8",
"halt_if": "",
"override_topic": true,
"override_payload": true,
"entity_id": "sensor.qianjinroad_traffic",
"x": 970,
"y": 560,
"wires": [
[
"2fd6b27c.72729e"
]
]
},
{
"id": "563fc4d7.55dedc",
"type": "api-call-service",
"z": "ac193d76.b37cd",
"name": "APP推送",
"server": "a4e11aa1.558da8",
"service_domain": "notify",
"service": "weixin",
"data": "",
"mergecontext": "",
"x": 940,
"y": 660,
"wires": [
[]
]
},
{
"id": "9140fe96.69d89",
"type": "http request",
"z": "ac193d76.b37cd",
"name": "获取高德路况图",
"method": "GET",
"ret": "bin",
"url": "http://restapi.amap.com/v3/staticmap?zoom=13&size=1024*1024&markers=-1,http://www.yourhawebsite.top:8123/local/lidicnIcon.png,0:111.1111111,22.2222222|-1,http://www.yourhawebsite.top:8123/local/apple.png,0:111.111111,22.222222&location=111.1111111,22.2222222&traffic=1&key=高德地图api_key",
"tls": "",
"x": 560,
"y": 560,
"wires": [
[
"7462fb55.af55f4"
]
]
},
{
"id": "7462fb55.af55f4",
"type": "file",
"z": "ac193d76.b37cd",
"name": " 存储路况图",
"filename": "/config/www/traffic.jpg",
"appendNewline": true,
"createDir": false,
"overwriteFile": "true",
"x": 770,
"y": 560,
"wires": [
[
"dd8e9c6a.685ab"
]
]
},
{
"id": "33924f16.c503b",
"type": "debug",
"z": "ac193d76.b37cd",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 690,
"y": 700,
"wires": []
},
{
"id": "a4e11aa1.558da8",
"type": "server",
"z": "",
"name": "Home Assistant",
"url": "http://192.168.2.200:8123",
"pass": "password"
}
]
|
|