I am only able to access Weather.getCurrentConditions().condition within my WF, but attempts to access hour and daily condition results in a "symbol not found error". Is this data limited to specific watches or SDK versions?
I am only able to access Weather.getCurrentConditions().condition within my WF, but attempts to access hour and daily condition results in a "symbol not found error". Is this data limited to specific watches or SDK versions?
Weather is only available on some 3.2 devices, but if a device has weather, I've not had an issue with getting the forecasts. What device are you simulating?
Post the code you are seeing this issue in. Are you null checking things and going by the length of the array in things like hourly forecast? If the watch doesn't have the recent weather data, things like that can be off.
Here's one of mine that graphs the hourly forecast for up to the next 8 hours:
If the Weather module is available, then each of the weather API functions (Weather.getCurrentConditions(), Weather.getDailyForecast(), and Weather.getHourlyForecast()) will be available. I agree.. we probably need more information to be able to help here.
I am simulating a 6x (running either 3.1 or 3.2). Here is the line that errors out:
This error goes away and the value is returned when I replace "getDailyForecast" with "getCurrentConditions".
Update: After going back over the API documentation, I see now I should have been parsing an array for daily/hourly weather data. :(
Thanks for the info. So, the hourly/daily is an array which I did not pick up on earlier (its in the documentation but I must have glossed over that part) . This would explain the error.
Btw, cool WF feature to plot out the weather conditions like that.
You want to null check Weather.getDailyForecast().
What you are doing could equate to
null.condition
throwing the error you see.
From the API doc:
Get the daily forecast
Returns:
An array of daily forecasts or null
if no data is available
Also, if it's not null, is you get an array of forecasts.
Here's a small sample of code that shows how to do things:
if(Toybox has :Weather) { var cast=Weather.getDailyForecast(); if(cast!=null) { System.println("forecasts for "+cast.size()+" days"); for(var i=0;i<cast.size();i++) { System.println("low temp for day "+(i+1)+" "+cast[i].lowTemperature); } } }
The output in the sim:
forecasts for 5 days low temp for day 1 7 low temp for day 2 14 low temp for day 3 16 low temp for day 4 18 low temp for day 5 14
Is there something that you have to do with a device to make it get the weather forecast? I have used the same code as you have detailed above and when I run my app in the simulator it works fine. It shows current and hourly forecast information. However, when I run the app on my edge 1030, nothing. It will not get weather information. I have turned on weather in the device settings via the connect app. My phone is connected to the edge unit via bluetooth.
Am I missing something?
Install also the garmin weather widget on your watch. If it’s not installed, you will probably not get anything out. I have had few that uninstalled it, and no garmin weather displayed after installing a watchface with garmin weather.
I see weather data in a ciq-device app on my Edge 530.
What's the CIQ version on your 1030 (it's in "About")