Significant Rainfall Event SRE

Hi All,

I am developing a application that detects a significant rainfall event every 24 hours

SRE Definition:

Rainfall >= 25 mm in 24 hr

I am using open microsoft to get ranifall data for last 24 hours

After a SRE Event is detect (SRE_Event == True) I want to add rainfall data every 1 hour to 24 hour value(25mm) until the rainfall has ended (0 mm)

I am using change nodes right now to extract value for rainfall for past 24 hour and 1 Hour

[
    {
        "id": "b45146a810171392",
        "type": "inject",
        "z": "18a6ff3f97d0870e",
        "name": "",
        "props": [
            {
                "p": "timestamp",
                "v": "",
                "vt": "date"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "3600",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 430,
        "y": 2780,
        "wires": [
            [
                "27fccc2cab4e22b8"
            ]
        ]
    },
    {
        "id": "d4f68a3ce7fca3ce",
        "type": "debug",
        "z": "18a6ff3f97d0870e",
        "name": "debug 16",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "SRE_Event",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1340,
        "y": 2780,
        "wires": []
    },
    {
        "id": "27fccc2cab4e22b8",
        "type": "http request",
        "z": "18a6ff3f97d0870e",
        "name": "",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "https://atlas.microsoft.com/weather/currentConditions/json?api-version=1.0&query=47.60357,-122.32945&subscription-key=7KtFD0f7uB6C6Mo7Cq3XXXXXXXXXXXXXXXXXXXXXXV1iE0A1JQQJ99AIAC8vTInGlVfjAAAgAZMPvOZv",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [
            {
                "keyType": "Content-Type",
                "keyValue": "",
                "valueType": "application/json",
                "valueValue": ""
            }
        ],
        "x": 630,
        "y": 2780,
        "wires": [
            [
                "3ed88f69160a5794",
                "5dd1dea98a797ebc",
                "27bed8caabdd785d"
            ]
        ]
    },
    {
        "id": "113a9639bddb4196",
        "type": "function",
        "z": "18a6ff3f97d0870e",
        "name": "Check Precipitation",
        "func": "//$PROMPT: Write a function that checks if precipitation value is greater than 25 which will set SRE_Event = True if no Sre Event = False    {\"value\":0,\"unit\":\"mm\",\"unitType\":3}\nconst precipitation = msg.payload\n\nif (precipitation > 25) {\n    msg.SRE_Event = true\n} else {\n    msg.SRE_Event = false\n}\nreturn msg",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1090,
        "y": 2780,
        "wires": [
            [
                "d4f68a3ce7fca3ce"
            ]
        ]
    },
    {
        "id": "3ed88f69160a5794",
        "type": "change",
        "z": "18a6ff3f97d0870e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.results[0].precipitationSummary.past24Hours",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 820,
        "y": 2780,
        "wires": [
            [
                "113a9639bddb4196",
                "6247442d46094351"
            ]
        ]
    },
    {
        "id": "6247442d46094351",
        "type": "debug",
        "z": "18a6ff3f97d0870e",
        "name": "debug 17",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1040,
        "y": 2840,
        "wires": []
    },
    {
        "id": "5dd1dea98a797ebc",
        "type": "debug",
        "z": "18a6ff3f97d0870e",
        "name": "debug 18",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 2700,
        "wires": []
    },
    {
        "id": "c6fdce1d28345bc2",
        "type": "debug",
        "z": "18a6ff3f97d0870e",
        "name": "debug 19",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1200,
        "y": 2880,
        "wires": []
    },
    {
        "id": "27bed8caabdd785d",
        "type": "change",
        "z": "18a6ff3f97d0870e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.results[0].precipitationSummary.pastHour",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 820,
        "y": 2880,
        "wires": [
            [
                "113a9639bddb4196",
                "c6fdce1d28345bc2"
            ]
        ]
    }
]

@abhmeh Are you sure that you want to share your subscription key with the world?

Also, in order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your last post above by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

1 Like

You need to report your own post and ask a moderator to remove that API key!

Or since it's out in public, change it for a new one with the site it's for.

1 Like

@Paul-Reed Thanks for the correction I removed the link. I have uploaded my code I am using change nodes to get values from array for past24Hours Precipitation and pastHour precipitation.

You should still get a moderator (eg @Paul-Reed) to fix it because we can see the history of your edits.

@Paul-Reed Hi Paul can you please remove the link from the post?

I've hidden your history records and also edited a further exploit in the flow.
As it's been shown for a number of hours, I would generate a fresh key, and retire that one.

@Paul-Reed Thanks Paul, I will regenerate it. Coming back to my question please check my code.

Do you have an example of the data you receive, preferably with a SRE event?

You can post the data using the </> button just like with code.