Author Topic: Add Option Allowing WeatherCat to Sleep  (Read 1235 times)

BertL

  • Gentle Breeze
  • **
  • Posts: 15
    • FW0481
    • KCACARLS84
  • Station Details: Davis VP2 Plus, 24hr-FARS, WeatherLinkIP, WeatherBridge, iMac 5K
Add Option Allowing WeatherCat to Sleep
« on: January 08, 2017, 03:17:09 PM »
I appreciate many, if not most WeatherCat users want it to run all the time, collecting 100% of available data and able to update external sources 7x24.  I also see this was a recent change to WeatherCat's design to force macOS to never sleep when WeatherCat is operational.

In my use case, I have a Davis WeatherLinkIP which will record basic (not all) data for some period of time while WeatherCat is unavailable.  I also have available a meteobridge to provide current upload of data to my preferred weather sites.  I do not have a need for personal website  updates and capabilities at this time -- in fact, I'm in process of shutting down my personal website of 17 years to reduce my life's complexities.  ;)  I really love WeatherCat's interface, widgets, tools, general documentation and robustness, and the helpful people on this forum, allowing me to expand capabilities as I may need to in the future  ...but I do not want to keep my 27" iMac and the various external Drobo, HDD and peripherals running 7x24 (only 15 hrs or so ;)), nor do I want to have to remember to shutdown WeatherCat each time I may leave my Mac during the day.  Since I have a meteobridge, I'm not in the market to get into a Mac Mini as it's replacement to run a standalone copy of WeatherCat there -- perhaps some day.

So, my request is:
- Add an option to WeatherCat allowing it to Sleep
- When WeatherCat then awakes from sleep, just as it does at startup, if it has a station with logged data (like a WeatherLink), automatically read that in and continue operation without intervention
- I recognize the disadvantage of this is WeatherCat's historical data will have periods with none, or in my case only basic data provided by the WeatherLink, no different than if WeatherCat was not running -- but it would make WeatherCat able to accommodate perhaps less prevalant use cases like mine, which I believe from my limited testing it's unable to with the recent design change.  (BTW, it appears a certain competitive product does operate this way by default.)

Thanks for the consideration.  I'd really rather get started with and use WeatherCat as my primary weather analytics tool.  It's got everything and more than I need.
Bert
Davis VP2 Plus w/ 24hr-FARS, WeatherLinkIP, WeatherBridge, iMac 5K
WU/PWS: KCACARLS84 CWOP: FW0481

BertL

  • Gentle Breeze
  • **
  • Posts: 15
    • FW0481
    • KCACARLS84
  • Station Details: Davis VP2 Plus, 24hr-FARS, WeatherLinkIP, WeatherBridge, iMac 5K
Re: Add Option Allowing WeatherCat to Sleep
« Reply #1 on: February 08, 2017, 03:47:24 PM »
I thought I'd try to put a little more analytics behind how much it costs me to have WeatherCat running with my out-of-the-ordinary usage case which only uses WeatherCat to collect data, display desktop gauges, and perform ad-hoc data inquiries upon occassion.  I love that WeatherCat already retrieves history data from my Davis WeatherLink each time WeatherCat starts to bring my local database up-to-date.  The net is, it isn't a lot of money each year, but with WeatherCat now preventing sleep on my iMac and my asking it to collect local data every 2 minutes, it does add approx 34% to the energy consumed when I'm not using my machine.

For those interested in a little more detail, here you go.  It's not super-scientific, but IMHO beats the anecdotal guesses I (and I suspect others) tend to make about situations like this.

Environment:
- 27" 5K iMac, 4 GHz i7, 16GB, with SSD -- running macOS Sierra 10.12.3
- Davis VP2 Plus, WeatherLinkIP set to 1-minute logging

- I purchased a Kill-A-Watt to measure kWh used on my iMac in two 8-hour scenarios
-- 1) My normal apps (Mail, iMessage, etc) with macOS Energy Savings ON to wake on network access, turning the display off after 5 mins, and putting disk drives to sleep when not in use.  WeatherCat was NOT running.  I did not otherwise touch or interfere with macOS during this 8-hour period.
-- 2) Same environment as above, but with WeatherCat RUNNING.  WeatherCat only collects data on 2-min intervals, and I allow it to collect more often if it determines the need.  It also has 8 custom gauges displaying on my desktop, but otherwise, no other functions most users utilize (weather site uploads, banners, FTP, etc) were enabled.

- I generally have my iMac turned-on for ~15 hours/day, and while the time I'm sitting in front of it varies, for this purpose I estimated 3 hours of use/day/365-days per year when macOS would not otherwise be sleeping.  I assumed WeatherCat would be running for the time I was using macOS.
- My electrical rates vary for 6 months of summer vs winter, and also by time-of-day, so I took that into considerations in the cost extrapolation.

Summary
With my setup, WeatherCat consumes approx 0.041 kWh additional energy for what I am asking it to do.  Extrapolating for my varying costs of energy and without taxes and other tariffs, that's about $24.29/year of additional energy cost that really isn't necessary in my use case (because WeatherCat catches-up data recording from logger history upon startup).

While it seems perhaps ridiculous for less than $25/year savings, I have recently started to try and remember to manually shut WeatherCat down when I am leaving my iMac for an extended period.  I already had WeatherCat automatically start when I login to macOS, so it will catch it's database up the next morning, or when I start it again manually during the day.  My original thought with this request still stands ... while perhaps the die-hard WeatherCat users may not make use of this new functionality, some outliers like myself and perhaps a future set of users would, and we'd save a few ongoing pennies of energy at the same time.



Bert
Davis VP2 Plus w/ 24hr-FARS, WeatherLinkIP, WeatherBridge, iMac 5K
WU/PWS: KCACARLS84 CWOP: FW0481

xairbusdriver

  • Storm
  • *****
  • Posts: 2042
    • EW7115 (E7115)
    • KTNGERMA20
    • Mid-South Weather
  • Station Details: Davis VP2 wireless + remote Anemometer/2014 Mac min - 10.13.4/WC 3.0
Re: Add Option Allowing WeatherCat to Sleep
« Reply #2 on: February 08, 2017, 05:09:22 PM »
I'm no AppleScript expert, heck, I'm should barely be called a user. [blush] OTOH, I think it is fully capable of starting and stopping an app that has an AS library, which certainly includes WC. I'll try to remember to take a look at it later today. We do have an AS expert at the forums, perhaps he can supply a script (or some Automator actions) that can handle the task of Quitting WC after a set number of hours. [computer] You could then change Energy Saver to put the computer to sleep after that number of hours. [tup]

Perhaps the WC dev could create a 'fake' "network access" System Event on a user-defined schedule that would then "Wake for network access"? After all, 'programming is just typing'! cmu:-) OTOH, he does have a pretty extensive 'feature request' list.

BertL

  • Gentle Breeze
  • **
  • Posts: 15
    • FW0481
    • KCACARLS84
  • Station Details: Davis VP2 Plus, 24hr-FARS, WeatherLinkIP, WeatherBridge, iMac 5K
Re: Add Option Allowing WeatherCat to Sleep
« Reply #3 on: February 08, 2017, 05:38:07 PM »
Thanks.

Sort of along the lines of the other idea we recently discussed, this request is one of those "try to prevent the user from having to code something" if at all possible.  I really try not to go there these days unless it's my last resort for something that really bugs me, and I can't find an alternative pre-built solution.  I've never coded AppleScript, but in a 30-min glance through the constructs that I did before posting this a few days ago, I didn't see how to really force quit an app once macOS goes to sleep, IF some app is specifically coded to prevent sleep from happening in the first place.  Perhaps there is a trick a knowledgeable coder can think of -- there many times are -- but for me, having a "timer" that would just force quit WeatherCat after some period of time without regard to if I'm using my Mac or not wouldn't be a solution I'd likely use.  The reality is, I'm on for a while every morning, but the duration varies greatly and sometimes I am on-and-off throughout the day.  I'll just keep manually shutting WC down for the time being.  Appreciate the idea and reply though!

BTW, I know this request will be way down on the requirements list if it ever makes it onto it in the first place -- simply because my use case is unlike most WeatherCat users today.  I do though think a large part of the code and logic to make WC operate as I suggest already exists ... If a person is using a WeatherLink, WC already knows to look at the logger history and use that data to bring its own database up-to-date if need be each time WC is started.  "All" :) WC needs to satisfy this requirement is to remove the "prevent sleep" code that was added as part of the last code drop, and then a bit of logic to watch for if WeatherCat is awakened from sleep, to perform the same check and update against the logger history it already does at startup while keeping everything else running.  (My impression from much more limited use I've made of WeatherSnoop3 that I also own, is that is how it operates...  WS does not force macOS to stay awake, but instead checks for logger/database updates each time it starts and awakes.  The function isn't something people would care about unless their use case is more like mine or perhaps they are only updating weather networks on a less frequent basis where a few minutes of macOS sleep could make sense in-between.
Bert
Davis VP2 Plus w/ 24hr-FARS, WeatherLinkIP, WeatherBridge, iMac 5K
WU/PWS: KCACARLS84 CWOP: FW0481

xairbusdriver

  • Storm
  • *****
  • Posts: 2042
    • EW7115 (E7115)
    • KTNGERMA20
    • Mid-South Weather
  • Station Details: Davis VP2 wireless + remote Anemometer/2014 Mac min - 10.13.4/WC 3.0
Re: Add Option Allowing WeatherCat to Sleep
« Reply #4 on: February 08, 2017, 09:51:37 PM »
I'm sure Stu can explain things to you privately as long as his methods are not proprietary, but I'll not attempt to even figure it out. OTOH, I don't think WC is forcing the OS/machine to stay awake. Rather, WC (like any other app, or maybe just those that 'front facing' interfaces) cannot run when the computer "sleeps". I'm in no way an OS programmer, and I've only created a handful of AppleScripts in 20+ years. I don't even do regex, if at all possible!!! cmu:-)

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 4778
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, MacBook Pro (Early 2011)
Certainly the green thing to do. (Re: Add Option Allowing WeatherCat to Sleep)
« Reply #5 on: February 08, 2017, 11:05:56 PM »
Dear Bert, X-Air, and WeatherCat "penny-pinchers,"

p, WeatherCat consumes approx 0.041 kWh additional energy for what I am asking it to do.  Extrapolating for my varying costs of energy and without taxes and other tariffs, that's about $24.29/year of additional energy cost that really isn't necessary in my use case (because WeatherCat catches-up data recording from logger history upon startup).

Perhaps an odd way to do think about it, but we should all consider ourselves lucky that electricity is so inexpensive in the United States that we have the luxury of running WeatherCat 24/7 for only about $25 a year.

Still, I don't think you need to make an economic case for your feature request.  Some of our European users have asked for as miserly a WeatherCat as possible because energy is much more expensive over there.  In addition, with Meteobridge, not running WeatherCat 24/7 is more attractive.   No matter how small the energy savings, WeatherCat users should be free to make that choice if for no other reason for the environmental benefits.

The one thing I'm not sure about is what do you mean by allowing WeatherCat to "sleep?"  One way an application can "sleep" is via the AppNap feature of macOS.  Another is how the WeatherCat is supposed to handle when the system goes into sleep mode.  I think the problem in both cases is that the operating system doesn't give the application any warning when either event is about to happen.  When you quit WeatherCat it can do things like shut down the station driver.  If WeatherCat code is just "stopped" the station driver can sometimes freeze, so that when WeatherCat "wakes" it can no longer communicate with the station.  We'll just have to wait for Stu to look into this and report if this feature request is feasible or not.

Nonetheless, I see the merit in your suggestion and after all . . . . .

 [wink] . . . . . .  Everybody knows that real cats always take a "cat nap" from time to time!!  [cat]. . . . . .  lol(1)

Cheers, Edouard  [cheers1]