Local weather group for Dashboard

Thank you very much for your reply, I changed to the code you had posted but now I get the following on both the "current" and "forecast" Parse Icon nodes.

"TypeError: Cannot read property 'icon' of undefined"

I really do try to work things out before I ask for help as I think, it's the best way to learn for me but this somewhat simple task has kicked my butt :slight_smile:

If you replace the ui_template node with a debug node, what do you see in the info panel?

In the forecast ui_template I get

"TypeError: Cannot read property 'icon' of undefined"

In the "current" ui_temlpate I get

msg : Object

object

payload: "partly-cloudy-day"

_msgid: "c9b4d82c.0f4bf8"

So that suggests an error with your parsing, as you should have a msg.payload of something like "partly-cloudy-day", which in the ui_template node should resolve to;
<i class="fa-4x wi wi-darksky-partly-cloudy-day"></i>

So do I have to have a line in the node for every icon such as
i class="fa-4x wi wi-darksky-partly-cloudy-day"
i class="fa-4x wi wi-darksky- clear-day" etc...

No. If you have <i class="fa-4x wi wi-darksky-{{msg.payload}}"></i> in a ui_template node, and you pass in a msg.payload of partly-cloudy-day, the template node will replace {{msg.payload}} with partly-cloudy-day, so the result would be;
<i class="fa-4x wi wi-darksky-partly-cloudy-day"></i>
....which will display the icon.

Ok, that's what I thought. I'll dig into this more. I may have path problems because the device I'm using has a different directory structure for node-red. its running on a Siemens iot2040. The path I'm using is in the flow I posted earlier in this post.
Also I'm confused a bit because I'm not sure if I should be using wi-forecast-io- or wi-darksky- in the ui_template node.

Thank you very much for your time and help.

Craig, the path I was trying to lead you on to debug this is simple. In the ui_template you are trying to pass in the name of the icon to use like 'rain'
<i class="fa-4x wi wi-forecast-io-{{msg.payload}}"></i>
so in this case msg.payload has to be just the word 'rain'

So you have to look at the function that is trying to send this to the ui_templace and see what is it actually sending? It is sending
msg.payload = (msg.payload.weather);

so it assumes that the incoming msg.payload had a key(?) called 'weather' and it contains the value 'rain' (in this example.)

So now the question is what is actually gtting to that function and is there a msg.payload.weather in it?

Thank you for your help, I've tried following your instructions as well and still no icons.
I have a Ubuntu server so I'm going to try getting it running on that server to find out what I'm doing wrong.

So it sort of works on the Ubuntu server, see the icon in the lower left.

Is the url path in the ui_template node the same in locations you are testing?

It seems to me that the Parse icon function node should be setting:
msg.payload = (msg.payload.icon);
and not:
msg.payload = (msg.payload.weather);

@zenofmud - forecast-io is the old descriptor for darksky, and I updated Weather icons (which is merged into node-RED) way back in Dec 2017 to reflect the name change.

So the correct i class for the ui_template is
<i class="fa-4x wi wi-darksky-{{msg.payload}}"></i>
and not
<i class="fa-4x wi wi-forecast-io-{{msg.payload}}"></i>
which is depreciated.

Paul

Thank you everyone that gave guidance, I figured out what was wrong.

The Parse function that works for the current weather is
const i = msg.payload.icon;

and the parse function that works for the forecast weather is
const i = msg.icon;

2 Likes

This has been an interesting thread to read through. I see a number of folks converted over to Darksky. I've created a flow that generates a dashboard combining current conditions from my "WeatherFlow" weather station which sends data over UDP and forecast data from Darksky. I've also pulled in GPS since my weather station is in my RV. Anyhow, I'm passing in msg.location.lon/lat as well as msg.time to iterate through future forecasts. My only problem seems to be that darksky spits on whatever date format i send it in msg.time. I've tried moments node to no avail. Can anyone provide an example of the time object / string you are passing darksky?

Thanks!!!

Kirk

@rvexodus - Kirk if you go to the darksky API documentation (https://darksky.net/dev/docs#forecast-request) you can see the format of the Request Parameters and there is a nice explation of the time format.

Hi all,

I have been reading this thread with great interest as its pretty much what I have been looking for.

I only understand the very basics of Node Red which I am running on my RPi at home. My original idea was gathering information from my home weather/environment station to record and display.

Originally, I was running several sensors, (light, UV, temperature, humidity, pressure, battery state including charge) on an Arduino mini pro which ran various calculations and smoothing, sending the results as a .csv string via Bluetooth to the RPi running Node-Red.

I ran out of memory on the Arduino, so decided to use it just to get the raw data from the sensors and send that string, moving the calculations and filtering etc. to Node-Red which is much better as I can change it as and when without having to re-program the Arduino.

This worked great, but I work away from home and as unlucky as I am, my battery failed just 2 days after going to work leaving me with nothing.

The lucky part of it was that before leaving home, I set up my router, so I could communicate with my PRi and Node-Red whilst I am away.

Coming across this thread enabled me to change the whole code so I could 'leach' information from Darksky and OpenWeatherMap and add some things I hadnā€™t thought of.

Having spent 5 weeks away from home, I'm looking forward to getting home and updating my whole system, so I can display my own data along with Darksky and OpenWeatherMap.

I now have an anemometer and weather vane to add to my system along with a dust particle monitor, I also intend to attach a lightning detector to the system and pretty much anything else I can come up with.

Anyway, I just want to say thanks to everyone on here for unknowingly pointing me in the right direction and teaching me a few things about Node-Red and what it can do.

I hope at some point I will be able to contribute too.

Thanks

Martin

Neat. Some details on the dust sensor and how you integrated it would be of interest and a great start.

Still at work, hopefully home by this time next week.
Brief rest then I will getting on with it.
Will post my progress if anyone is interested.
Thanks
Martin

1 Like

Is your node-red accessible via the internet? If so, then hopefully you have secured it to prevent ne'er do wells from hacking it.

Yes, it is secured from the internet but thanks for the reminder.

As I am at work, I run a local copy on my laptop where I make changes and when I'm happy I then log on to my home system and deploy the changes.
Always a worry, especially if I reboot the Pi. If something goes wrong, there is little I can do.