Prognozowana pogoda na X godzin/dni do przodu - forecast.home

Witam, dzielę się swoimi dokonaniami w dziedzinie prognozowaniem pogody i późniejszym jej wykorzystaniem w automatyzacjach.

wynik

kod node-red

[
    {
        "id": "a1c1d25f1caa1111",
        "type": "inject",
        "z": "c617c3f41b6c4831",
        "name": "Co 5 minut",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "300",
        "crontab": "",
        "once": true,
        "onceDelay": 5,
        "topic": "",
        "payload": "",
        "payloadType": "str",
        "x": 190,
        "y": 1460,
        "wires": [
            [
                "f8c15c6a0b1c2222",
                "cda0457d8e02c70f",
                "9feff861919c0049",
                "8244f32981afca61",
                "0264929d17a08e21",
                "0a2da83a7a50fe37",
                "e1bec5ae88969006"
            ]
        ]
    },
    {
        "id": "f8c15c6a0b1c2222",
        "type": "api-call-service",
        "z": "c617c3f41b6c4831",
        "name": "Prognoza pogody godzinowa",
        "server": "42e1a8c4.ec01f8",
        "version": 7,
        "debugenabled": false,
        "action": "weather.get_forecasts",
        "floorId": [],
        "areaId": [],
        "deviceId": [
            "54312a4b894eabcfba9122426953ac24"
        ],
        "entityId": [],
        "labelId": [],
        "data": "{\"type\":\"hourly\"}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [
            {
                "property": "results",
                "propertyType": "msg",
                "value": "",
                "valueType": "results"
            },
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "(\t    $a:=results.*[0].forecast;\t    {\t        \"cała doba\": $a,\t        \"o 8:00\": $a[0], \t        \"o 12:00\": $a[4],\t        \"o 15:00\": $a[7]\t    }\t    \t)",
                "valueType": "jsonata"
            }
        ],
        "blockInputOverrides": false,
        "domain": "weather",
        "service": "get_forecasts",
        "output_location": "hourly",
        "output_location_type": "msg",
        "mergecontext": "",
        "x": 540,
        "y": 1440,
        "wires": [
            [
                "2d2f4465af444444"
            ]
        ]
    },
    {
        "id": "2d2f4465af444444",
        "type": "debug",
        "z": "c617c3f41b6c4831",
        "name": "Prognoza pogody",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1010,
        "y": 1440,
        "wires": []
    },
    {
        "id": "cda0457d8e02c70f",
        "type": "api-call-service",
        "z": "c617c3f41b6c4831",
        "name": "Prognoza pogody dzienna",
        "server": "42e1a8c4.ec01f8",
        "version": 7,
        "debugenabled": false,
        "action": "weather.get_forecasts",
        "floorId": [],
        "areaId": [],
        "deviceId": [
            "54312a4b894eabcfba9122426953ac24"
        ],
        "entityId": [],
        "labelId": [],
        "data": "{\"type\":\"daily\"}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [
            {
                "property": "results",
                "propertyType": "msg",
                "value": "",
                "valueType": "results"
            },
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "(\t    $a:=results.*[0].forecast;\t    {\t        \"tydzień\": $a, \t        \"dzisiaj\": $a[0], \t        \"jutro\": $a[1],\t        \"pojutrze\": $a[2]\t    }\t    \t)",
                "valueType": "jsonata"
            }
        ],
        "blockInputOverrides": false,
        "domain": "weather",
        "service": "get_forecasts",
        "output_location": "hourly",
        "output_location_type": "msg",
        "mergecontext": "",
        "x": 530,
        "y": 1500,
        "wires": [
            [
                "2d2f4465af444444"
            ]
        ]
    },
    {
        "id": "9feff861919c0049",
        "type": "api-call-service",
        "z": "c617c3f41b6c4831",
        "name": "Temperatura o 12:00",
        "server": "42e1a8c4.ec01f8",
        "version": 7,
        "debugenabled": false,
        "action": "weather.get_forecasts",
        "floorId": [],
        "areaId": [],
        "deviceId": [
            "54312a4b894eabcfba9122426953ac24"
        ],
        "entityId": [],
        "labelId": [],
        "data": "{\"type\":\"hourly\"}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [
            {
                "property": "results",
                "propertyType": "msg",
                "value": "",
                "valueType": "results"
            },
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "(\t   $a:=results.*[0].forecast[4].temperature  \t)",
                "valueType": "jsonata"
            }
        ],
        "blockInputOverrides": false,
        "domain": "weather",
        "service": "get_forecasts",
        "output_location": "hourly",
        "output_location_type": "msg",
        "mergecontext": "",
        "x": 520,
        "y": 1560,
        "wires": [
            [
                "9ab507d923fdf6ba"
            ]
        ]
    },
    {
        "id": "8244f32981afca61",
        "type": "api-call-service",
        "z": "c617c3f41b6c4831",
        "name": "Pogoda o 12:00",
        "server": "42e1a8c4.ec01f8",
        "version": 7,
        "debugenabled": false,
        "action": "weather.get_forecasts",
        "floorId": [],
        "areaId": [],
        "deviceId": [
            "54312a4b894eabcfba9122426953ac24"
        ],
        "entityId": [],
        "labelId": [],
        "data": "{\"type\":\"hourly\"}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [
            {
                "property": "results",
                "propertyType": "msg",
                "value": "",
                "valueType": "results"
            },
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "(\t   $a:=results.*[0].forecast[4].condition\t)",
                "valueType": "jsonata"
            }
        ],
        "blockInputOverrides": false,
        "domain": "weather",
        "service": "get_forecasts",
        "output_location": "hourly",
        "output_location_type": "msg",
        "mergecontext": "",
        "x": 500,
        "y": 1620,
        "wires": [
            [
                "11b4916dcca9914e"
            ]
        ]
    },
    {
        "id": "11b4916dcca9914e",
        "type": "change",
        "z": "c617c3f41b6c4831",
        "name": "Tłumacz",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "sunny",
                "fromt": "str",
                "to": "słonecznie",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "partlycloudy",
                "fromt": "str",
                "to": "częściowe zachmurzenie",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "cloudy",
                "fromt": "str",
                "to": "pochmurno",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "rainy",
                "fromt": "str",
                "to": "deszczowo",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "snowy",
                "fromt": "str",
                "to": "śniże",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "fog",
                "fromt": "str",
                "to": "mgliście",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "pouring",
                "fromt": "str",
                "to": "ulewnie",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "clear-night",
                "fromt": "str",
                "to": "bezchmurnie",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 720,
        "y": 1620,
        "wires": [
            [
                "9ab507d923fdf6ba"
            ]
        ]
    },
    {
        "id": "0264929d17a08e21",
        "type": "api-call-service",
        "z": "c617c3f41b6c4831",
        "name": "Prognoza pogody +3",
        "server": "42e1a8c4.ec01f8",
        "version": 7,
        "debugenabled": false,
        "action": "weather.get_forecasts",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "weather.dom"
        ],
        "labelId": [],
        "data": "{\"type\":\"hourly\"}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [
            {
                "property": "results",
                "propertyType": "msg",
                "value": "",
                "valueType": "results"
            },
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "(\t   $a := results.*[0].forecast;\t   $now := $toMillis($now());\t   $future := $now + (4*60*60*1000);\t   $najblizsza := $filter($a, function($v) {\t       $toMillis($v.datetime) >= $future\t   })[0];\t   {\t       \"godzina\": $substring($najblizsza.datetime, 11, 5),\t       \"temperatura\": $najblizsza.temperature,\t       \"warunki\": $najblizsza.condition,\t       \"kierunek wiatru\": $najblizsza.wind_bearing,\t       \"indeks UV\": $najblizsza.uv_index,\t       \"templow\": $najblizsza.templow,\t       \"prędkość wiatru\": $najblizsza.wind_speed,\t       \"opady\": $najblizsza.precipitation,\t       \"wilgotność\": $najblizsza.humidity\t   }\t)",
                "valueType": "jsonata"
            }
        ],
        "blockInputOverrides": false,
        "domain": "weather",
        "service": "get_forecasts",
        "x": 520,
        "y": 1260,
        "wires": [
            [
                "7f825bad57f0b642"
            ]
        ]
    },
    {
        "id": "7f825bad57f0b642",
        "type": "debug",
        "z": "c617c3f41b6c4831",
        "name": "Prognoza pogody +3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1020,
        "y": 1260,
        "wires": []
    },
    {
        "id": "0a2da83a7a50fe37",
        "type": "api-call-service",
        "z": "c617c3f41b6c4831",
        "name": "Temperatura +3",
        "server": "42e1a8c4.ec01f8",
        "version": 7,
        "debugenabled": false,
        "action": "weather.get_forecasts",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "weather.dom"
        ],
        "labelId": [],
        "data": "{\"type\":\"hourly\"}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [
            {
                "property": "results",
                "propertyType": "msg",
                "value": "",
                "valueType": "results"
            },
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "(\t   $a := results.*[0].forecast;\t   $now := $toMillis($now());\t   $future := $now + (4*60*60*1000);\t   $najblizsza := $filter($a, function($v) {\t       $toMillis($v.datetime) >= $future\t   })[0];\t   $najblizsza.temperature\t)\t",
                "valueType": "jsonata"
            }
        ],
        "blockInputOverrides": false,
        "domain": "weather",
        "service": "get_forecasts",
        "x": 500,
        "y": 1320,
        "wires": [
            [
                "7f825bad57f0b642"
            ]
        ]
    },
    {
        "id": "9ab507d923fdf6ba",
        "type": "debug",
        "z": "c617c3f41b6c4831",
        "name": "Prognoza pogody o 12:00",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1030,
        "y": 1560,
        "wires": []
    },
    {
        "id": "e1bec5ae88969006",
        "type": "api-call-service",
        "z": "c617c3f41b6c4831",
        "name": "Temperatura +3",
        "server": "42e1a8c4.ec01f8",
        "version": 7,
        "debugenabled": false,
        "action": "weather.get_forecasts",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "weather.dom"
        ],
        "labelId": [],
        "data": "{\"type\":\"hourly\"}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [
            {
                "property": "results",
                "propertyType": "msg",
                "value": "",
                "valueType": "results"
            },
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "(\t   $a := results.*[0].forecast;\t   $now := $toMillis($now());\t   $future := $now + (4*60*60*1000);\t   $najblizsza := $filter($a, function($v) {\t       $toMillis($v.datetime) >= $future\t   })[0];\t   $najblizsza\t)\t",
                "valueType": "jsonata"
            }
        ],
        "blockInputOverrides": false,
        "domain": "weather",
        "service": "get_forecasts",
        "x": 500,
        "y": 1380,
        "wires": [
            [
                "7f825bad57f0b642"
            ]
        ]
    },
    {
        "id": "42e1a8c4.ec01f8",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": "at: ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "h23",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": true
    }
]
1 Like