Use parameters

Hi,
I use Hassio together with Node-red.
I have added the wheather from SMHI (sweden).
From SMHI there is several parameters that you should be able to use, see documentation http://opendata.smhi.se/apidocs/metfcst/parameters.html
The problem is when I try this in Node-red I can not see the parameters only the payload and so on.

Dose anyone know how to get the paramers,
for example tcc and tcc_mean = The total cloud cover. How big part of the sky is covered by clouds.

BR,
Fredrik

You just need to parse the json…
msg.payload.data.state should give you cloudy.
or
msg.payload.data.attributes.temperature will give you 14
Try first using debug node and then, do what you want with the value eg. send it to HA.
GV

From what I see in the src of hass for that component doesn’t include that data. You can use the http request node to consult the api directly from nodered

subzero79, what do you mean?
I’m not good at this can you please give me a exemple. So I can understand!

It means the component doesn’t include the data you want. I can take a look tomorrow to see if I can use the api to query more data than what hass does directly from node red

subzero79, if you could do that it would be great. :slight_smile:
So if I understod it correct doesn’t Hassio have all the information that is described in the description for the component.

well the component did state in docs what measurements it was pulling. My comments are based on what i saw on the source of the component. At the moment it doesn’t work using curl, looks like service is unavailable

Now is working

[{"id":"86de26b3.d4b448","type":"http request","z":"2281650b.2e5c5a","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"https://opendata-download-metfcst.smhi.se/api/category/pmp3g/version/2/geotype/point/lon/14.018554/lat/60.586967/data.json","tls":"","proxy":"","authType":"basic","x":820,"y":240,"wires":[["c50f7868.2f60d8"]]},{"id":"a9533dea.07dff","type":"debug","z":"2281650b.2e5c5a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1110,"y":240,"wires":[]},{"id":"d212e486.96ca98","type":"inject","z":"2281650b.2e5c5a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":660,"y":240,"wires":[["86de26b3.d4b448"]]},{"id":"c50f7868.2f60d8","type":"json","z":"2281650b.2e5c5a","name":"","property":"payload","action":"","pretty":false,"x":970,"y":240,"wires":[["a9533dea.07dff"]]}]

subzero79
Thanks for the help.
I tried your workflow but unfortunately it gave the result of 0, see figure


Do you know why?

I tested it again and now it is working!
But what is the different number series, what do they stands for?
image
Under each serie can I found same parameters
Is it different time?
If that is the case how do I know which parameter to take ?
Can I take different parameter depending of the current time?

I believe is a forecast. Each number is One day. The date should show on each array element.

Value 0, don’t know look at the website, says there the ranges and what do they mean.

Subzero79, Yes each parameter number seems to be a forecast for different time.

In this case it all depents on when I would like to check the parameters.
Different parameters for 10.00 o’clock and 20.00 o’clock for the same day.
I need some function/code that select parameter after current time.
Any suggestions how I can do that?

You’ll have to iterate using for in a function or you can use a split node which separates en array into separate messages and just filter the date string. If you want just say the third day in advance since looks like is in order you can pick by array element.

msg.payload.timeSeries[2] and so on.

I cant write code atm not in my pc right now. What specific date are you looking for or value ?

Subzero79.
The value I’m interesting in is “lcc_mean”, see picture.


But I’m only interested to know the current lcc_mean value, i.e it all depends on what the current time is when the selection of parameter shall be done.
I will use the lcc_mean value to determind if I going to turn on the lights at 18.00 or 20.00, i.e if it’s cloudy the light shall be turned on earlier.

Assuming the today is element 0, and lcc_mean will always be element 7 then try this

[{"id":"86de26b3.d4b448","type":"http request","z":"2281650b.2e5c5a","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"https://opendata-download-metfcst.smhi.se/api/category/pmp3g/version/2/geotype/point/lon/14.018554/lat/60.586967/data.json","tls":"","proxy":"","authType":"basic","x":820,"y":240,"wires":[["c50f7868.2f60d8"]]},{"id":"a9533dea.07dff","type":"debug","z":"2281650b.2e5c5a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1410,"y":180,"wires":[]},{"id":"d212e486.96ca98","type":"inject","z":"2281650b.2e5c5a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":660,"y":240,"wires":[["86de26b3.d4b448"]]},{"id":"c50f7868.2f60d8","type":"json","z":"2281650b.2e5c5a","name":"","property":"payload","action":"","pretty":false,"x":970,"y":240,"wires":[["96f4778.2031c88","f11f7d98.d2e5b"]]},{"id":"96f4778.2031c88","type":"function","z":"2281650b.2e5c5a","name":"","func":"msg = msg.payload.timeSeries[0].parameters[7];\nreturn msg;","outputs":1,"noerr":0,"x":1110,"y":240,"wires":[["a7c76a11.db9498","f6e294b4.b74748"]]},{"id":"f11f7d98.d2e5b","type":"debug","z":"2281650b.2e5c5a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1130,"y":120,"wires":[]},{"id":"a7c76a11.db9498","type":"switch","z":"2281650b.2e5c5a","name":"","property":"values[0]","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":1250,"y":240,"wires":[["a9533dea.07dff"],["5617df7.0db652"]]},{"id":"f6e294b4.b74748","type":"debug","z":"2281650b.2e5c5a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1270,"y":120,"wires":[]},{"id":"5617df7.0db652","type":"debug","z":"2281650b.2e5c5a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1410,"y":260,"wires":[]}]

subzero79.
Thanks that will probably work but it all depends on which time I call the function if element 0 shall be used or not, i.e I made a test at 15:34 and then the value in element 0 is an old value, dated to 14:00

Not sure there, time seems correct is UTC time not local, Sweden is +1.