Belchertown DarkSky Alerts

233 views
Skip to first unread message

rich T

unread,
Dec 20, 2018, 10:13:16 PM12/20/18
to weewx-user
Pat

Wondering if there was a way to pull/display the Alerts for the area from Darksky using your coding?

Rich

Pat

unread,
Dec 22, 2018, 8:46:44 PM12/22/18
to weewx-user
I don't see their alerts in the API doc. Only what Colin is doing on his site to have their widget embedded. Do you see something I'm missing for API alerting?

Colin Larsen

unread,
Dec 22, 2018, 10:17:42 PM12/22/18
to weewx...@googlegroups.com
Those alerts come as a part of the NZ Metservice widget that I use - it isn't a Darksky widget

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rich T

unread,
Dec 25, 2018, 2:41:58 PM12/25/18
to weewx-user
Happy Holidays

I have the embedded widget; to get the alerts you must click on the provided link. Which API are you using?

Pat

unread,
Dec 25, 2018, 8:17:22 PM12/25/18
to weewx-user
Belchertown skin is using the DarkSky API

rich T

unread,
Dec 25, 2018, 9:57:56 PM12/25/18
to weewx-user
Could this work with in your code:

DarkSkyApi.loadItAll(excludes, position);

DarkSkyApi.loadItAll()
  .then(console.log);

DarkSkyApi.loadItAll('daily,hourly,minutely,flags') // just return alerts

Pat

unread,
Dec 26, 2018, 9:29:16 AM12/26/18
to weewx-user
Ok cool. That GitHub repo just confirmed that I am doing what they're doing. I'm not using JavaScript though, I'm just grabbing the raw JSON from DarkSky. I guess I've never seen the alerts array in my output when I initially created it, so out of sight out of mind?

I just grabbed a forecast for an area in South Dakota that was under weather advisory, and I see in DarkSky's forecast it has the alert data. So I can use this sample data to include it in the skin. 

Where and how should the alert be shown? I'd like to keep it in line with the clean look of the skin. 

I think I'll show the alert at the top of the page beneath the timestamp. An alert icon (maybe something like this?) and a brief text of the alert next to it. Then you can click the alert to see the full details. 

rich T

unread,
Dec 26, 2018, 9:47:56 AM12/26/18
to weewx-user
I think underneath the timestamp with the Icon would look fine.  Same text size as the timestamp but bold.  Maybe make the Alerts optional feature, so the users has a choice to display the Alerts.

Pat

unread,
Dec 26, 2018, 9:54:46 AM12/26/18
to weewx-user
Agreed. Let me work on a concept

Pat

unread,
Dec 26, 2018, 11:39:24 AM12/26/18
to weewx-user
I just committed an initial attempt. You can download the files from GitHub or from the attachments here. 

As usual, have a backup of your setup just in case. To test it out, copy the attached files to skins/Belchertown and restart weewx. Wait for an archive period and if you have a weather alert, it should appear like in the screenshot. Clicking the link will take you to the source of the alert. 

The alert area should update automatically in the background (no page refresh needed). So if an alert goes active, it'll pop up the alert area. When it's gone it'll disappear. At least it should in theory :)

Will need some testing and ironing out over the next few days for sure... Let me know how it goes. 
style.css
index.html.tmpl
alert_concept.jpg

Pat

unread,
Dec 26, 2018, 11:47:44 AM12/26/18
to weewx-user
Oops - forgot to hide the alert bar when an alert clears. Try this updated version attached. Same rules apply as above. 
index.html.tmpl

rich T

unread,
Dec 26, 2018, 1:45:49 PM12/26/18
to weewx-user
Thanks Pat...Downloaded and installed both files and restarted weewx. No alerts in the area at this time; mostly likely some alerts towards end of week when the icy weather comes through.  We'll keep you informed.

Rich

Pat

unread,
Dec 26, 2018, 3:49:45 PM12/26/18
to weewx-user
Sounds good! 

I should add another disclaimer that the showing and hiding of the alert bar automatically without reloading the website is only accomplished if you have the MQTT feature enabled. 

Which reminds me I need to add an option to show that bar if MQTT is disabled. I'll have to make another update later today. 

Colin Larsen

unread,
Dec 26, 2018, 4:09:00 PM12/26/18
to weewx...@googlegroups.com
Does that mean that I'll see alerts even though I only use the Darksky current conditions? Did you pop in the option to disable the alerts?

--

Pat

unread,
Dec 26, 2018, 7:53:57 PM12/26/18
to weewx-user
I've made more changes to this. Now you have to opt in for the alerts. Erring on the side that alerts may not appeal or be available to everyone in every region, it's opt-in. Simply add forecast_alert_enabled = 1 to your skin options in weewx.conf. 

The alert description has a default truncate at 75 characters. You can override that with skin option forecast_alert_length

Also non-MQTT sites now have alerts available to them. 

Changes made to skin.conf, index.html.tmpl and user/bin/belchertown.py. You can find the latest files in the repository and in the list of recent commits

Please test it out. 

G Hammer

unread,
Dec 27, 2018, 9:37:23 AM12/27/18
to weewx-user
The changes didn't break anything here when there are no alerts, and perhaps tomorrow morning I'll be able to see the alert in action.

Thanks

rich T

unread,
Dec 27, 2018, 12:11:59 PM12/27/18
to weewx-user
Updated the files and all is running well. thanks Pat

Pat

unread,
Dec 27, 2018, 3:15:38 PM12/27/18
to weewx-user
I just received a weather alert on https://belchertownweather.com/ - so far so good.

Keep me posted on any alerts you guys get to make sure there's no bugs

G Hammer

unread,
Dec 27, 2018, 5:16:39 PM12/27/18
to weewx-user
Hi Pat,

I have the Winter Weather Advisory. Nothing broken.
Thanks!

rich T

unread,
Dec 27, 2018, 7:55:35 PM12/27/18
to weewx-user
Pat

If an area has multiple alerts, the skin only displays the first Alert.





2018-12-27_19-53-02.png

Pat

unread,
Dec 27, 2018, 7:56:42 PM12/27/18
to weewx-user
Yeah I was afraid of that. I was thinking on my drive home today how best to show them without flooding the screen. 

Pat

unread,
Dec 27, 2018, 8:19:15 PM12/27/18
to weewx-user
I feel like the attachment is too busy, but it's an option. Otherwise I could try to pare it down to something like the NWS has with something simple: High Wind Watch in effect until December 30, 08:00 AM MST
multiple.jpg

G Hammer

unread,
Dec 27, 2018, 8:27:23 PM12/27/18
to weewx...@googlegroups.com
If you could just link the alert and no additional text you could fit several on one line. 
If I see an alert, I’m going to click for more info anyway. 

--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/sEd4sVkjpZw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.

Pat

unread,
Dec 27, 2018, 8:33:40 PM12/27/18
to weewx-user
Perhaps something like this?
multiple1.jpg

G Hammer

unread,
Dec 27, 2018, 8:35:21 PM12/27/18
to weewx...@googlegroups.com
That gives the alert and enough info to decide if you want to see the whole alert. 
I like it. 

Pat

unread,
Dec 27, 2018, 8:57:39 PM12/27/18
to weewx-user
I agree. I've pushed these changes to GitHub

Feel free to grab the latest skins/Belchertown/index.html.tmpl and skin.conf, as well as bin/user/belchertown.py. 

The forecast_alert_length option is now deleted (not needed)

Restart weewx. 

Pat

unread,
Dec 27, 2018, 9:11:04 PM12/27/18
to weewx-user
I've also just updates the styles.css to have the correct spacing for the alert area. Be sure to grab a copy of that and restart weewx

G Hammer

unread,
Dec 27, 2018, 11:34:16 PM12/27/18
to weewx-user
Pat,

A bit late on getting the files, but while it didn't break anything, I now have two alert symbols displayed.
I replaced /index.html.tmpl skin.conf styles.css and bin/user/belchertown.py with the latest github versions.

Alert.png

Scott Grayban

unread,
Dec 28, 2018, 7:42:38 AM12/28/18
to weewx-user
Not for me but I did notice that my alert icon is black and not red....

Pat

unread,
Dec 28, 2018, 8:01:05 AM12/28/18
to weewx-user
Looks like you still have a bit of an older index.html.tmpl based on the alert source code I can see on your site. I'm not sure why you have 2 icons, but replace your index.html.tmpl with this one and then restart weewx. 

Scott Grayban

unread,
Dec 28, 2018, 8:32:36 AM12/28/18
to weewx-user
Why is my alert icon black though ? I did replace my index with yours and modified my styles by hand because I made some font color/text changes.

Pat

unread,
Dec 28, 2018, 8:35:36 AM12/28/18
to weewx-user
It doesn't look like you have the latest styles.css. Viewing your source shows the section missing where I set the icon red. 

Grab an updated copy, place in skins/Belchertown then restart weewx. It should update on the next archive interval

.wx-stn-alert i {
    color
: red;
}

Scott Grayban

unread,
Dec 28, 2018, 8:41:53 AM12/28/18
to weewx-user
Yup missed that commit !

I can't overwrite the file because I have modified it for my tastes. So I use diff's

Pat

unread,
Dec 28, 2018, 8:44:31 AM12/28/18
to weewx-user
I see. I've made 2 changes to the styles.css file in the last couple of days. 

You can see those specific commits here and here

Scott Grayban

unread,
Dec 28, 2018, 8:47:03 AM12/28/18
to weewx-user
I got your last commit but missed the previous one for the alert icon. I'm all good now !

kutz...@gmail.com

unread,
Dec 28, 2018, 8:59:30 AM12/28/18
to weewx-user
Pat, Nice addition!!

It seems to be working great for me. We're in the middle of a major rainstorm - we currently have an embarrassment of alerts! See the attached jpg.

phil

On Thursday, December 27, 2018 at 9:11:04 PM UTC-5, Pat wrote:
Screenshot_2018-12-28 Biltmore Lake, NC Weather Conditions.jpg

Scott Grayban

unread,
Dec 28, 2018, 9:01:32 AM12/28/18
to weewx-user
Damn...... as if combining all alerts into 1 isn't good enough !!!

Pat

unread,
Dec 28, 2018, 9:03:04 AM12/28/18
to weewx-user
Wow that is a lot of alerts!

G Hammer

unread,
Dec 28, 2018, 9:14:51 AM12/28/18
to weewx-user
That was it. Thanks.

Scott Grayban

unread,
Dec 28, 2018, 9:16:16 AM12/28/18
to weewx-user
Well shit... I updated the styles and index.html.tmpl and the icon is STILL black...


On Friday, December 28, 2018 at 5:44:31 AM UTC-8, Pat wrote:

Pat

unread,
Dec 28, 2018, 9:24:44 AM12/28/18
to weewx-user
Double check your diff for typos and extra characters. Chrome is showing an error in your styles.css at line 1628 for .wx-stn-alert

Scott Grayban

unread,
Dec 28, 2018, 9:50:26 AM12/28/18
to weewx-user
Fixed that and went through everything 3 times.... no more errors but still black icon... odd

kutz...@gmail.com

unread,
Dec 28, 2018, 10:56:58 AM12/28/18
to weewx-user
Pat,

Do the alerts update automatically on archive refresh like the graphs? Or do you need to manually refresh the page. I disabled timeout for my page as I want people to be able to leave it up always on a tablet, if they like. It would be nice if the alerts went away when withdrawn or update if changed. If they don't update automatically, could that feature be added?

phil

Pat

unread,
Dec 28, 2018, 11:38:49 AM12/28/18
to weewx-user
It should clear on archive intervals. Keep an eye on it and let me know

kutz...@gmail.com

unread,
Dec 28, 2018, 11:52:28 AM12/28/18
to weewx-user
Sounds great Pat! I'll watch it and let you know.

Speaking of updates, I notice that the "Current Day" under "Weather Record Snapshots" on the main page (see attached screenshot) doesn't update automatically on archive intervals. The data in that block does update on archive intervals, but you need to refresh the page to get the day to change if you leave the website up overnight.

Can that be changed?

phil
InkedScreenshot_2018-12-28 Biltmore Lake, NC Weather Conditions_LI.jpg

Pat

unread,
Dec 28, 2018, 1:08:08 PM12/28/18
to weewx-user
I could have sworn I looked at this. Can you put in a quick issue for me on the GitHub page so I don't forget it again?

kutz...@gmail.com

unread,
Dec 28, 2018, 1:20:08 PM12/28/18
to weewx...@googlegroups.com

Done. Issue #31.

 

phil

--

Scott Grayban

unread,
Dec 28, 2018, 3:50:55 PM12/28/18
to weewx-user
I just checked again and the icon is still black.... I didn't see any errors in my chrome console either.


On Friday, December 28, 2018 at 6:24:44 AM UTC-8, Pat wrote:

Pat

unread,
Dec 28, 2018, 3:56:51 PM12/28/18
to weewx-user
The errors are still there. I'd even say they're worse. You have some ascii characters in there. 

Top part of screenshot is Chrome developer tools, bottom part is your styles.css. 

Try to delete and re-enter the diff. Something is very sideways. See attached screenshot. 
errors.jpg

Scott Grayban

unread,
Dec 28, 2018, 4:03:46 PM12/28/18
to weewx-user
friggiin tab spacing.... so used to doing that i forget css hates it

kutz...@gmail.com

unread,
Dec 28, 2018, 4:56:33 PM12/28/18
to weewx-user
Pat,
Yes, the alerts update automatically! I have a few that disappeared and new ones were added without my doing a refresh. I now have 7 alerts showing! We've gotten a huge amount of rain and I'm showing flood alerts for several nearby rivers as well as alerts for the county. So, alerts are working great for me.

We've had a total of 3.3 inches of rain since the storm started yesterday - 2.6 inches of that has been since midnight 🌧☔. Hopefully it's over for now (radar looks clear). But there is some more rain forecast for Monday night.
phil

On Friday, December 28, 2018 at 11:38:49 AM UTC-5, Pat wrote:

Scott Grayban

unread,
Dec 28, 2018, 8:43:33 PM12/28/18
to weewx-user
Wasn't the tabbing editing in nano... seems my ssh environment was the issue. I fixed that and is working correctly.

G Hammer

unread,
Jan 20, 2019, 10:55:36 AM1/20/19
to weewx-user
Pat,

I'm getting two alerts for the Winter Storm Warning and two for the Wind Chill Advisory.
They are different NWS alerts for each and one of each is not for my area.
I looked through the DarkSky API alerts but don't see why it would give two regions alerts.
Any ideas?

On Friday, December 28, 2018 at 9:03:04 AM UTC-5, Pat wrote:

Pat

unread,
Jan 20, 2019, 11:05:48 AM1/20/19
to weewx-user
I'm seeing the same thing on my site. 

This isn't a skin problem though. 

My guess is we're near the county lines and DarkSky is showing alerts for both?

Looking at your darksky_forecast.json (yes, I remembered your site), and running that data through https://jsonformatter.org you can see near the bottom the "alerts": [ section shows the 8 alerts on your website currently. 

So the skin is just showing the data that DarkSky is providing. 

You could reach out to DarkSky to see what they say?

Pat
Reply all
Reply to author
Forward
0 new messages