Retrieving Weather ...
 
Notifications
Clear all

We had a major storm through here recently and we suffered damage to the house roof and ceilings. I just received the quote to repair. I’m hoping that a small fraction of the 80,000 odd people that download SDIO and/or Desktop Info every month won’t mind chipping in a few dollars to help out. Click on the big blue button at the bottom of the page to help us keep a roof over our heads, literally!

Guests have read-only access to our forums. If you wish to participate you will need to register. Be sure to activate your account from the email sent to you when you register.

[Solved] Retrieving Weather info with HTTPGET and wttr.in

6 Posts
2 Users
2 Reactions
808 Views
RatboyJim
(@ratboyjim)
Eminent Member Registered
Joined: 6 months ago
Posts: 19
Topic starter  

I am using the following statement to get weather information, but I cannot figure out how to set the text encoding to remove the extra characters. It shows fine in browsers, but not in desktopinfo.

HTTPGET=interval:600,source: http://wttr.in/chicago?u&format=Cond:+%C|Temp:+%t|Wind:+%w,display:%1,Wide:1 

   
Quote
Glenn
(@glenn)
Member Admin
Joined: 7 years ago
Posts: 1507
 

try adding a regex to filter out non ascii characters:

regex:[^\x00-\x7F]+

   
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 7 years ago
Posts: 1507
 

btw the next release will have a little code to deal with json response in HTTPGET


   
RatboyJim reacted
ReplyQuote
RatboyJim
(@ratboyjim)
Eminent Member Registered
Joined: 6 months ago
Posts: 19
Topic starter  

Thanks for implementing the JSON parsing! I've been trying to use it, but am having an issue getting any data.

This is the portion of the JSON output from wttr.in I need to parse:

{
    "current_condition": [
        {
            "FeelsLikeC": "-1",
            "FeelsLikeF": "31",
            "cloudcover": "0",
            "humidity": "64",
            "localObsDateTime": "2024-12-03 11:08 AM",
            "observation_time": "04:08 PM",
            "precipInches": "0.0",
            "precipMM": "0.0",
            "pressure": "1025",
            "pressureInches": "30",
            "temp_C": "3",
            "temp_F": "37",
            "uvIndex": "1",
            "visibility": "16",
            "visibilityMiles": "9",
            "weatherCode": "113",
            "weatherDesc": [
                {
                    "value": "Sunny"
                }
            ],
            "weatherIconUrl": [
                {
                    "value": ""
                }
            ],
            "winddir16Point": "NW",
            "winddirDegree": "307",
            "windspeedKmph": "14",
            "windspeedMiles": "9"
        }
    ],
...

This is the statement I am using:

HTTPGET=interval:600,source: https://wttr.in/chicago?u&format=j1,json-keys:current_condition.Temp_F,  text:Temp: %1F

 

Which does not work. I'm new to using JSON data. Any Help?

 


   
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 7 years ago
Posts: 1507
 

i know i had to do some reading to figure out how to navigate json. you'll notice the square bracket immediately after "current_condition". this indicates current_condition is an array and what follows is an element of that array. The closing bracket for the array element is right at the end.  There is just one element in this array. So I believe the correct way to reference the content in question is:

current_condition[0].temp_F


   
ReplyQuote
RatboyJim
(@ratboyjim)
Eminent Member Registered
Joined: 6 months ago
Posts: 19
Topic starter  

Thanks. I'm a dumbass and was using Temp_F forgetting that it's case sensitive.

 


   
Glenn reacted
ReplyQuote
Glenn's Page