[Nook Touch Themes and Apps] nmyshkin:
New NST Weather Widget is done! https://xdaforums.com/nook-touch/themes-apps/app-nst-weather-widget-t3946270

Updated to v1.1

--fixed issue that often caused app crash if initial contact with OWM was unsuccessful

--added sunrise/sunset update for condition icon

--added "current value" display in Settings for Lat., Long. and API

--some cosmetic changes to forecast panel

Everybody talks about the weather... :)

I miss WeatherAce, but when WeatherUnderground deep-sixed their free API service, there was nothing left in the app that worked. I made a few half-hearted attempts at updating the APIs for some of the other services included in the app but it became clear that my approach was too simple-minded and I gave up.

NSTWeather is my "learning app" for figuring out how to deal with xml weather data. It's a simple weather display and forecast app just for the NST (and sort of the NSTG...read on). Because Tasker (which I used to make this app) cannot create widgets, I started looking for some screen real estate that would (almost) always be visible. There is a small "blank" section of the status bar to the right of the soft Menu button. On the NST, this area is large enough for a temperature (no F or C) and a small condition icon. On the rare occasion that sync arrows appear, they overlap the condition icon. Alas, if you have an NSTG, the Glowlight indicator overlaps the condition icon when WiFi is on and, I suppose, sync arrows displayed with the WiFi on might overlap the temperature. So this might not be the best thing for NSTG users.

"What about apps that run full-screen?", you ask. I have only one or two, including the stock reader. I have made the weather information the same color as the reading page background. That's one reason the icons look a little rough. Only 2 colors. If you have other full-screen apps and the weather display is annoying you, it can be toggled by a long press once the app is activated.

This app is not quite experimental, but it is not a destination for me. This is a way for me to work out various issues leading up to an eventual Widget.

With that out of the way...

What it does

This app uses your latitude, longitude and free OpenWeatherMap API to fetch a 3-hr, 5-day forecast for your locale. The app makes up to two attempts to contact the OWM servers each morning, at 4:30 am. The xml file from OWM is then processed to extract sunrise/sunset times, and temperatures and precipitation amounts for each 3-hr period over the 5-day forecast. All this data is massaged to get the time zone corrected, adjust the day/night condition icons for sunrise/sunset (OWM has them wrong...) and convert the precipitation into the units you desire. There is lots of other information in the xml file, but I decided to keep this "simple" (it is anything but) and just go for this essential information.

At each 3-hr interval, starting at 2:00 am, the temperature/condition display is updated from the forecast data. In addition, a tap on the temperature display will open a panel with the forecast for all 5 days, at 3-hr intervals (see screenshot below).

If the app fails to contact OWM (their servers are sulking or you have arrived in a hotel the previous evening and your NST can't make a WiFi connection...), it will re-sort the panel data to keep the day display correct and continue to display whatever information it has in the last forecast received until it runs out of data. I don't know what happens then! Of course, one could hope that in the course of 5 days it will eventually reach OWM.

What it doesn't do

The app--as configured--does not display "tiny" amounts of precipitation. I have it set to indicate "trace" (tr.) when the value falls below a tenth of whatever unit is selected. Also, I make no distinction among the types of precipitation other than by the condition icon.

Unfortunately, in the old version of Tasker that runs on the NST there is no way to directly address the changes at sunrise or sunset since they are variable, and variable time contexts were added only to later versions of Tasker. In the current version of NSTWeather I have added a routine for updating the condition icon within 15 minutes of sunrise or sunset, always on the early side rather than later. I based my range of potential times on Anchorage and Oslo. If you live at even more extreme northerly or correspondingly southerly latitudes, this will not work for you all the time. Also, since the weather data is updated at 4:30 am, I did not include the entire potential sunrise range (as early as 3 am), but rather settled for 4:45 am as my starting value. Hopefully you are asleep at that point...

Requirements

1. This is a Tasker-generated app. If you already have one of my other Tasker-generated apps or have previously installed GApps, you don't need the two Google maps library files included in the zip and can delete them. If you do need them, copy the two files into the locations shown below:

/system/etc/permissions/com.google.android.maps.xml

/system/framework/com.google.android.maps.jar

Set permissions for both files to rw-r--r-- and reboot. Without these files resident, the app will not install.

2. Copy the folder "NSTWeather" and its contents from the zip below to the root of your sdcard. This contains all the condition icons and is where the weather.xml file from OWM will be stored.

3. Go to https://openweathermap.org/ and find the current weather for your locale. When this is displayed you will also see the "geocoordinates" (i.e., the latitude and longitude). Copy these two values.

4. Go to https://openweathermap.org/api and sign up for a free API (right there in the opening paragraph, click on the words "sign up"). You will eventually receive an email with the API.

Installation and Use

Install the app from the zip below either by side-loading or ADB. The only user interface of the app is a Settings page. Open NST Weather and enter your latitude and longitude, as well as your API. Be especially careful with the API and make sure to include any negative signs with the geocoordinates.

Next, make your selection of the units you want displayed. Finally, to make the app fully functional you need to check both of the boxes in the lower section (you can disable the app temporarily by unchecking these). When you've made all the selections, tap on the bottom box to start a manual data retrieval. The Settings page will close and you should see WiFi come on for a bit. It will then turn off. If a successful connection was made with OWM and if you entered your information correctly, you will eventually see a weather display in the status bar. How long will it take? About 3 minutes. There's an awful lot of stuff to be done. That's one reason for having the data update done at 4:30 am when you are hopefully snoozing.

If nothing seems to happen and you see WiFi come back on again in 15 minutes, then it failed to contact OWM the first time and is trying again. If the second time fails, you will get a notification telling you that download failed, assuming there is nothing wrong with the values you entered. Go back to the Settings page and carefully check your API. That's where the most likely error will occur. Of course you should check your geocoordinates, too, just to be sure.

If you have made a successful connection with OWM before and one day there is a notification saying download failed, you can just ignore it and hope for better luck the next day unless you absolutely must have an updated forecast. In that case, you can use the manual retrieval option. There is no need to re-enter the latitude, longitude and API each time you open the Settings page once they have been entered correctly. They are stored in the /data/data/app folder for the app. Also, if you decide to change the locale, you only need to enter the new latitude and longitude, not the API.

The 5-day forecast panel is updated daily even if a download fails (data is just shifted to the left and the names of the days are changed). You access the panel by tapping on the temperature display.

If you want to hide the weather display, a long press on the temperature will make it invisible, but the area on the status bar adjacent to the soft Menu button remains active. Another long press will re-display the weather information.

Widgets?

As I said early on, Tasker cannot make widgets on its own, although it can share data with some other apps which can. Of these, only one will still work on the NST/G: Minimalistic Text. The current version of NSTWeather shares the current temperature value display with Minimalistic Text as a "Locale" variable called CURRTEMP. If you have a working install of Minimalistic Text and some familiarity with the app, you can play with this just to get a feel for the possibilities (that's what I'm doing!). To do so, create a widget (1x1 or perhaps 2x1), and select "Custom" for the format/layout. Get rid of all the stuff that is there by default and tap on the "Misc" tab. One of the options there is "Locale". If you drag that up to the working area you can enter the name of the variable CURRTEMP. If you want to add a degree symbol and F or C, or perhaps your location, you can use the "Static Text" option. I've done this and it works wonderfully well, updating right along with the normal status bar temperature display of NSTWeather. There's still a tremendous amount of work to be done to get to the actual Widget with the condition icons, etc., but it's a start :)