OWM Call problem...

Good day,

I am trying to create an OWM function in my Watch Face to call Current and Daily weather data.

Can someone advise me where I am making a mistake and if it is at all possible to call data via:

api.openweathermap.org/.../weather

and

https://api.openweathermap.org/data/2.5/onecall ???

Here they attach their code that doesn't work.

Thank you

BG.service.zip

  • You don't seem to be calling either getWeatherDaily() or getWeatherCurrent() from onTemporalEvent, so you are never issuing the request.

  • And could I ask you for help with this code please?

    I don't know how to deal with it...

    Thank you

  • Make this your onTemporalEvent function:

    	function onTemporalEvent() {
    		System.println("Started onTemporalEvent..");
            getWeatherCurrent();
    	 }	

    and move this to inside your getWeatherCurrent() function (at the top)

    //right after System.println("Getting data for last known coordinates");
     		var units = "metric";
    		if (System.getDeviceSettings().temperatureUnits == System.UNIT_STATUTE){
    			units = "imperial";
    		}

  • So I modified it and I only get calls from Function getWeatherCurrent();

    but because the function getWeatherDaily();

    not yet.

    Is it possible to call two at the same time?

  • I wouldn't do them at the same time,  but I'd cain them, where in onReceiveOWMCurrent(), if the responseCode==200, call getWeatherDaily() instead of doing Background(exit) (with the same change for "units", then in the callback for that call, combine it with the responst from getWeatherCurrent() and do a Background.exit of the combine responses.