Current weather

Post your questions and help other users.

Moderator: Martin

Akt
Posts: 133
Joined: 25 May 2014 08:57

Current weather

Post by Akt » 13 Feb 2017 15:06

Hi,
How to show current weather in widget?
Which site supply variable or how to get weather report from installed weather app?

User avatar
Scotty
Posts: 78
Joined: 26 Aug 2016 20:29
Location: Southern California

Re: Current weather

Post by Scotty » 13 Feb 2017 23:38

1. Get a (free) API key from weather underground, here. You'll have to sign up, but that's free, too.

2. In automagic, do an http request (GET) using the URL below (replacing the info that I have put in CAPS):

http://api.wunderground.com/api/YOUR_API_KEY_HERE/conditions/q/DESIRED_WEATHER_INFO.xml

That xml info is saved in a variable whose name you define (e.g., weather).

Then you can extract the desired items from the xml info contained in the variable "weather", and feed that to your widget

Akt
Posts: 133
Joined: 25 May 2014 08:57

Re: Current weather

Post by Akt » 14 Feb 2017 14:58

Hi scotty,
I tried to follow all your steps, but I am facing some problem.
The location is showing in U.S. And I live in India.
And how to get weather information from that.
Last edited by Akt on 15 Feb 2017 03:25, edited 1 time in total.

User avatar
Scotty
Posts: 78
Joined: 26 Aug 2016 20:29
Location: Southern California

Re: Current weather

Post by Scotty » 14 Feb 2017 19:16

@Akt

1. Your flow contains your API key, in text format - I'd delete that ASAP.

2. Your http request is aimed at "weather.xml", which delivers a DEFAULT report from Pennsylvania USA. To get weather from India, you simply need to change the text from "weather.xml" to (for example) "mumbai.xml"

Akt
Posts: 133
Joined: 25 May 2014 08:57

Re: Current weather

Post by Akt » 15 Feb 2017 03:27

Hi
Could you post your flow after deleting your key.
And what all can we write in xml, only city names or anything else also?

User avatar
Scotty
Posts: 78
Joined: 26 Aug 2016 20:29
Location: Southern California

Re: Current weather

Post by Scotty » 17 Feb 2017 20:46

flow_Bare_bones_weather_flow_20170217_122205.xml
Bare bones weather flow
(3.04 KiB) Downloaded 916 times
I attach a bare bones flow. It is triggered by Time, but you can change that.

In the http request action, you need to replace two things: (i) apikeyhere (replace with your API key) and (ii) desiredlocationhere (replace with mumbai, as a test instance)

Then, when executed, the flow will obtain the weather info for Mumbai, saving it (in xml format) in the variable weather

The script then extracts (from weather) the current temp info (in F), and writes that numerical value to the variable global_CurrentTemp.

Then (merely as an example of what you could do) there's a condition (expression) to determine how to act on that information (if the current temp is 57 or less, returns TRUE).

Note 1: You may want to see the entire content of the weather information that was returned by the http request. There are several ways to do that. I suggest that you change where the HTTP request action stores the info (change it from Variable to File). Then, after executing the http request, you can open the xml file, and view it at your leisure. Seeing all of the weather info that is returned will allow you to change the flow's script, to extract information other than (or in addition to) the current temp.

Note 2: re/ your specific question. I can use, for example, a US ZIP code (e.g., 92110.xml) to successfully get weather forecast in that ZIP. I suggest that you identify the region from which you want the forecast, and then see what is available on Weather Underground. For example, in the USA a lot of people have personal weather stations that report to weather underground, and you can use them as a source (pws:InsertStationCodeHere.xml).

Akt
Posts: 133
Joined: 25 May 2014 08:57

Re: Current weather

Post by Akt » 17 Feb 2017 23:36

Hi scotty,
Thanks for detailed information and explanation and I love your flow.
It is of very use to me.

Akt
Posts: 133
Joined: 25 May 2014 08:57

Re: Current weather

Post by Akt » 22 Feb 2017 15:43

Hi scotty,
I tried to extract weather forecast but I was unable to do that .

Can you give me the script to get weather forecast.

User avatar
Scotty
Posts: 78
Joined: 26 Aug 2016 20:29
Location: Southern California

Re: Current weather

Post by Scotty » 22 Feb 2017 19:58

Akt wrote:Hi scotty,
I tried to extract weather forecast but I was unable to do that .

Can you give me the script to get weather forecast.
You don't get the weather forecast using a script, you get it using the http request action, and then you use a script to extract the desired information (for example, maybe you want only the forecast for tomorrow).

So, look at the http request action in the bare bones flow that I provided, above. You'll see, in the URL, the word "conditions". That means that you're requesting to download the current weather conditions for the area you're interested in.

To obtain the forecast for that same area, replace "conditions" with "forecast", save it, and run the http request. Then, the variable weather will contain all of the forecast info, and you design a script to extract what you want....

Akt
Posts: 133
Joined: 25 May 2014 08:57

Re: Current weather

Post by Akt » 23 Feb 2017 02:16

Thanks scotty.
What else can be written in place of conditions?

Post Reply