Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fetching Weather using the dev code

ANSWERED
Hello, I have successfully gathered weather information using the code on the dev part of this site. Now I understand i can grab the data for the details set in this code : var ENDPOINT = "https://api.openweathermap.org/data/2.5/weather?"+"lat=52.7079&lon=-2.7541&units=metric"; Now in this line the latitude and longitude provide the temp and location data. The trouble is I have to enter these coordinates in the code which is fine for my location but that would be useless for others using my watch face Is there any way I can auto fill this ENDPOINT with with either user information based on settings or even better can I auto fill this information using the geolocation of the watch. I have looked at the weather module on github but it comes across long winded just to retrieve weather as this code is far more simple in its form. I would like to think I can auto fill this data based on the watch GPS or user input. Any help appreciated.
Best Answer
0 Votes
24 REPLIES 24

I already deleted the weather code from the clock face.

since it was overlapping with other elements, people were not pleased.

I will try to add this code to another clock face soon, I still want to make it work. Just don’t know why I did not see any weather and also no errors or anything in the console. I will test it out again soon!

Best Answer
0 Votes

I have setup a repository in github (https://github.com/gpfrello/FitbitOS_weather_clock) where I implemented my little weather code into a very basic digital clockface.

The next planned updates are the following (meaning I have a lot to learn!):

- implement weather as a external module

- implement icons for weather

- implement settings

- implement a code to make a sort of visualization when weather is updating and display of time of last update.

Best Answer
0 Votes

I made a new application on my computer with CLI (VS Code). Now your code is working fine. Before I tested it on Fitbit Studio, then I did not see it working. 

So I was porbably the only stupid one still using Studio 😄

 

does the temperature change atomatically to fahrenheit? Or does it only show celsius?

Best Answer
0 Votes

Hello @innak and sorry for late reply (I missed your post).

The code as it is provides the temperature in Celsius since the call to the API is specifically asking form metric 

var linkApi = "https://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon="  + long + "&units=metric" + "&APPID=" + API_KEY;
  fetch(linkApi)

If you want it in Fahrenheit simple replace units=metric with units=imperial as described in the API documentation

 

I actually use only Fitbit Studio and have no problem.

 

Best Answer
0 Votes

I'm having the same problem where the api is working with the simulator but it is not working when testing with my phone. Have you solved that problem yet?

Best Answer