02-01-2022 21:23
02-01-2022 21:23
I'm in the process of adding weather to my clock face, and I got it working with OpenWeatherMap. However, I'm trying to figure out how to save the values of the temperature and condition. Currently, when I open an app, or do anything to cause the clock face to stop, both values are erased. I have it calling to update the weather when the minute is 0, 15, 30, or 45. However, if it is not one of those minutes, it is not updated. I would like to save the last registered temperature and last registered condition code and render it. I am able to get those, but only at the aforementioned times. I tried using localStorage, but I couldn't figure out how to get that to the app from the companion.
02-01-2022 21:27
02-01-2022 21:27
Use fs API on watch (device).
You could do it using localStorage, but then you'd need to communicate the values to the watch, which introduces more latency (especially if there is no bluetooth connection).
02-01-2022 21:33
02-01-2022 21:33
How would I go about doing that?
02-01-2022 23:05
02-01-2022 23:05
@hellomynameisbe - normal procedure for any clock or app is to load and save it's parameter on start and exit.
A simple read and save to a file works easily to maintain current values, however
Depending on how long the clock or app was not active it could mean the saved data is very old. An alternative is to also check the weather at startup [which avoids the load/save logic] in addition to every 15 minutes.
Having the weather in a clock face means an Internet connection - if you are going to make your clock face public some people might not grant that permission for reasons of security and performance which could cause problems. For personal use it doesn't matter as you know what is happening.
For the newer watches it is somewhat redundant as a swipe up gets you current weather and in more detail.
Author | ch, passion for improvement.
02-02-2022 07:59
02-02-2022 07:59
What would the code look like for that?