『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
楼主: 花开堪折枝

[流程系列] 【node-red】彩云天气

  [复制链接]

0

主题

20

帖子

220

积分

中级会员

Rank: 3Rank: 3

积分
220
金钱
200
HASS币
0
发表于 2023-2-27 19:12:09 | 显示全部楼层
厉害了我的大佬
回复

使用道具 举报

8

主题

60

帖子

445

积分

中级会员

Rank: 3Rank: 3

积分
445
金钱
385
HASS币
0
发表于 2023-2-28 08:28:34 | 显示全部楼层
nodered是不是执行速度很慢
回复

使用道具 举报

0

主题

2

帖子

24

积分

新手上路

Rank: 1

积分
24
金钱
22
HASS币
0
发表于 2023-2-28 17:43:25 | 显示全部楼层
谢谢分享
回复

使用道具 举报

0

主题

15

帖子

58

积分

注册会员

Rank: 2

积分
58
金钱
43
HASS币
0
发表于 2023-3-3 14:41:11 | 显示全部楼层
6666666666
回复

使用道具 举报

0

主题

14

帖子

83

积分

注册会员

Rank: 2

积分
83
金钱
69
HASS币
0
发表于 2023-3-9 12:08:32 | 显示全部楼层
谢谢大佬,正一筹莫展呢
回复

使用道具 举报

4

主题

29

帖子

442

积分

中级会员

Rank: 3Rank: 3

积分
442
金钱
413
HASS币
0
发表于 2023-3-14 11:27:04 | 显示全部楼层
好好学习 天天向上
回复

使用道具 举报

0

主题

12

帖子

38

积分

新手上路

Rank: 1

积分
38
金钱
26
HASS币
0
发表于 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"
    }
]
回复

使用道具 举报

2

主题

19

帖子

416

积分

中级会员

Rank: 3Rank: 3

积分
416
金钱
397
HASS币
0
发表于 2023-3-17 17:23:02 | 显示全部楼层
谢谢 大佬
回复

使用道具 举报

0

主题

11

帖子

116

积分

注册会员

Rank: 2

积分
116
金钱
105
HASS币
0
发表于 2023-3-18 00:00:58 | 显示全部楼层
强烈支持
回复

使用道具 举报

0

主题

1

帖子

18

积分

新手上路

Rank: 1

积分
18
金钱
17
HASS币
0
发表于 2023-3-21 21:12:19 | 显示全部楼层
点赞,学习了!!!!!!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-6 16:24 , Processed in 0.100424 second(s), 30 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表