c5te1n / node-red-contrib-dwd-local-weather

Node Red node to retrieve local weather forecast from DWD (Germany)
Apache License 2.0
13 stars 11 forks source link

lookAheadHours #36

Open kamcioo opened 2 years ago

kamcioo commented 2 years ago

Hello,

unfortunately I can only one time get information from DWD after I change the content of the “Look Ahead Hours”. I get always this message after I have asked second time for the informations: MOSMIX request failed: TypeError: Cannot read properties of undefined (reading 'lookAheadHours')

Thank You in advance, kamil

chengler commented 11 months ago

It works with this example of the function lookAheadHours (every injection one hour is added)

var hours = flow.get('hoursAhead');
if (  hours === undefined){
    hours = 0;
} else{
    hours += 1;
    }
flow.set('hoursAhead', hours);

msg.payload = {lookAheadHours : hours};
return msg ;

grafik

test this if you like

[ { "id": "6bc9afaa58d466be", "type": "function", "z": "07cb8451f6f8c0c0", "name": "lookAheadHours", "func": "var hours = flow.get('hoursAhead');\nif ( hours === undefined){\n hours = 0;\n} else{\n hours += 1;\n }\nflow.set('hoursAhead', hours);\n\nmsg.payload = {lookAheadHours : hours};\nreturn msg ;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 450, "y": 220, "wires": [ [ "33eb9a8b57792fca" ] ] } ]