Weather Data (3.2)

Originally posted by  at https://forums.garmin.com/developer/connect-iq/i/bug-reports/weather-data-ciq-3-2:

I have a data field where I need the current temp to provide a better modeling for a metric. Device temps are not trustworthy because direct sun exposure (Edge devices in particular) heats up the device, generating bad data.

CIQ 3.2 Weather looks interesting. Questions:

Say you are climbing Pikes Peak, a mountain summit in Colorado, topping out over 14K ft up.

The weather data is probably based on a weather station near the base. Can we get the altitude of the weather station providing the temps so we can make altitude adjustments?

If we ride out of cell coverage at 11am, does the CIQ 3.2 weather data use cached projected temps for say 12noon, 1pm, etc. Or just return a null/error value?

Thanks!

-- Dave

  • The weather data is probably based on a weather station near the base. Can we get the altitude of the weather station providing the temps so we can make altitude adjustments?

    This information isn't available through our API, so it's not something that could be obtained.

    If we ride out of cell coverage at 11am, does the CIQ 3.2 weather data use cached projected temps for say 12noon, 1pm, etc. Or just return a null/error value?

    getHourlyForecast() will provide you with this kind of information if you wanted to cache data within your app, but the system doesn't cache this for you automatically.

  • This got me curious and I'll throw together a test case, but I think the hourly forecast is available for a while (hours), even if there is no connection so no reason for an app to cache it.   That seems to be the case with currentConditions()

  • With currentConditions(), I've see it be valid for hours even if there's no update, and here's what I'm doing with the 1hr forecast.

    I put together a simple WF to display info the info.  Here's the basics:

    	        	
    	        	var hf=Weather.getHourlyForecast();
    	        	if(hf==null) {
    					dc.drawText(centerW,y,largeFont,"No 1hr forecast",Gfx.TEXT_JUSTIFY_CENTER);	        	
    	        	} else {
    	        		var sz=hf.size();
    					dc.drawText(centerW,y,smallFont,"1hr forecast ok, sz="+sz,Gfx.TEXT_JUSTIFY_CENTER);
    					y+=smallHeight;
    					
    					var i=0;
    					while(i<sz) {
    	        			dc.drawText(width*.33,y,smallFont,makeTime(hf[i].forecastTime)+" "+makeTemp(hf[i].temperature)+degree,Gfx.TEXT_JUSTIFY_CENTER);
    	        			i++;
    	        			if(i<sz) {
    							dc.drawText(width*.66,y,smallFont,makeTime(hf[i].forecastTime)+" "+makeTemp(hf[i].temperature)+degree,Gfx.TEXT_JUSTIFY_CENTER);
    	        				i++;
    	        			}
    	        			y+=smallHeight;        								
    					}
    	 							
    	 			}

    And here's what I see in the sim:

    The first entry in the array is for the next hour.  While the time is 7am, the first forecast is 8am.

    On a real va4, I've seen the number of hours (sz=xx) vary from 9 to 12, so it's not always 12 hours, and when the hour changes, the first value also changes to the next hour, but the number of hours stays the same or may increase.

    Right now, I have the va4 inside a metal box on the other side of the house so it's not connected to the phone, and I'll take a peek every hour or two.  I'm thinking the number of hours will decrease, but what forecasts it has will remain for upcoming hours.  I'll updated this post after  I've seen what happens.

    Note:  I'm not caching anything.

  • So after what a few hours, what I expected to happen, happened.  The forecast for the next hour is at the beginning of the list, and the list shrinks (sz=5 for example).  Being brought back in range of the phone,the forecasts when back to 10 hours worth after a few minutes.

  • Well, you may have proved me wrong, Jim. Slight smile I was thinking we made a request to an API when we get weather, but I went back and reviewed the design, and we're actually getting the data from the system (which independently makes requests for weather data outside of CIQ). So you're right--weather data may be cached and available to CIQ, after all.

    I'll give the caveat that the availability of this data may be different depending on the device. In the meantime, I'm down-voting my original response. Cold sweat