Author Topic: Squeezing WeatherCat custom alerts into MacOS notifications.  (Read 1881 times)

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 6661
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
Squeezing WeatherCat custom alerts into MacOS notifications.
« on: January 08, 2023, 11:06:09 PM »
Dear WeatherCat DIY types,

I think it likely that I'm not the only longtime Macintosh user who has concluded that Apple's attention span is getting steadily shorter.  Evidence for this comes from an unlikely source: MacOS notification framework.  For starters, it is difficult to get much information about simple matters like exactly how much can be displayed in the MacOS notification network.   After considerable searching, I found this webpage on web notifications that indicated what were the limits of MacOS notifications.

https://help.batch.com/en/articles/4367478-what-is-the-optimal-length-for-every-web-push-notification

You will find the information on MacOS at the bottom of the article and you will note that the MacOS notification displays the least amount of text and has no facility for anything else like graphics - something its rival systems do support.

This has become important to WeatherCat users because build 320 of the WeatherCat 3.2.0 Beta now includes support for custom alerts being displayed as MacOS notifications.  As noted in the release notes:

Quote
8. Custom alerts are now sent to the macOS notification system. Note that the alert text will be truncated by the notification system . . .

As a result, the first notifications I received looked like this:



All the useful information was truncated!  So I started to rephrase everything to be as terse as possible.  This is what I finally came up with:



You will find instructions on how to format the custom alert text on starting on page 153 of the current WeatherCat manual.  One of the tricks I had to come up with is to display the date and time at the end of the second line of text.  The date ends up being truncated but the time appears which is what I was interested in.  As a result the MacOS notifications for temperature alerts (and their clearing) look now like this:



I cannot say I'm exactly happy, but at least I can live with these changes. 

To make it easier to mock up a MacOS notification I cobbled together a tiny AppleScript that you can use to test out various alert text combinations.  It is attached to this posting and displayed as text below.

Code: [Select]
set titleText to "Notification title"
set subtitleText to "First line of text"
set notificationText to "Second line of text"
display notification notificationText with title titleText subtitle subtitleText

To use it, double-click on the script and then replace the text in the first 3 lines of the script with your proposed alert text (obviously, put your text between the quotation symbols.)  You can click on the run triangle at the top of the AppleScript editor to see what your proposed notification looks like.

I hope this is some help in taming the MacOS notification system such that it becomes more usable to us WeatherCatters.

Cheers, Edouard

xairbusdriver

  • Storm
  • *****
  • Posts: 3131
Re: Squeezing WeatherCat custom alerts into MacOS notifications.
« Reply #1 on: January 09, 2023, 03:54:13 PM »
Seems that Apple uses the "Notification" engine to let us know what has changed when we get a Security Update: Short with little or no useful information. [banghead] cmu:-)

Thanks for your work and this information. I must confess I don't expect to use this "access", I reply on simple (but less limiting) emails since I almost always have my email app running. And emails work cross-platform/cross-devices. [tup]

Perhaps a bit more shortening can be achieved by using <, >, ^,,, ±, «, »,,,,,, etc.  [coffee]
THERE ARE TWO TYPES OF COUNTRIES
Those that use metric = #1 Measurement system
And the United States = The Banana system

Blicj11

  • Storm
  • *****
  • Posts: 4061
    • EW3808
    • KUTHEBER6
    • Timber Lakes Weather
  • Station Details: Davis Vantage Pro2 Plus | WeatherLinkIP Data Logger | iMac (2019), 3.6 GHz Intel Core i9, 40 GB RAM, macOS Sonoma 14.8.3 | WeatherCat 3.3 | Supportive Wife
Re: Squeezing WeatherCat custom alerts into MacOS notifications.
« Reply #2 on: January 12, 2023, 05:35:29 PM »
Edouard, thanks so much for explaining the pitfalls and providing us with a real live sample of how to do it. After discovering that editing today's rainfall in the 3.2.0 beta doesn't actually work as intended (as explained in the beta thread), I reverted back to the previous version. However, your helpful post on using the macOS notification system will help me when I install the next beta release.
Blick


xairbusdriver

  • Storm
  • *****
  • Posts: 3131
Re: Squeezing WeatherCat custom alerts into MacOS notifications.
« Reply #3 on: January 13, 2023, 06:09:39 PM »
We didn't need any "Notifications" yesterday when the heavens literally opened up for a few minutes!! Rained so hard I could not see the street from the front porch (about 50 ft)! :o Only got .63 inches, but the ISS says the rate was 9.93 in/hr!! Part of the visibility problem could have also been due to the hail. [rolleyes2] Fortunately, we did not have any of the storms that ravaged Alabama.
THERE ARE TWO TYPES OF COUNTRIES
Those that use metric = #1 Measurement system
And the United States = The Banana system

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 6661
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
So did ya' . . . (Re: Squeezing WeatherCat alerts into MacOS notifications.)
« Reply #4 on: January 13, 2023, 10:57:39 PM »
Dear X-Air and WeatherCatters experiencing extreme weather a bit too up-close and personal,

We didn't need any "Notifications" yesterday when the heavens literally opened up for a few minutes!! Rained so hard I could not see the street from the front porch (about 50 ft)! :o Only got .63 inches, but the ISS says the rate was 9.93 in/hr!! Part of the visibility problem could have also been due to the hail. [rolleyes2] Fortunately, we did not have any of the storms that ravaged Alabama.

 [wink] . . . . So did you fire the weather person or do you only do that when it snows? . .  [snow] . . . . .  lol(1)

Cheers, Edouard  [cheers1]