Retrieving Weather ...
 
Notifications
Clear all

Retrieving Weather info with HTTPGET and wttr.in

6 Posts
2 Users
2 Reactions
333 Views
(@ratboyjim)
Active Member Registered
Joined: 1 month ago
Posts: 4
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: 6 years ago
Posts: 1342
 

try adding a regex to filter out non ascii characters:

regex:[^\x00-\x7F]+

   
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 6 years ago
Posts: 1342
 

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


   
RatboyJim reacted
ReplyQuote
(@ratboyjim)
Active Member Registered
Joined: 1 month ago
Posts: 4
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: 6 years ago
Posts: 1342
 

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

This post was modified 2 days ago 2 times by Glenn

   
ReplyQuote
(@ratboyjim)
Active Member Registered
Joined: 1 month ago
Posts: 4
Topic starter  

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

 


   
Glenn reacted
ReplyQuote
Glenn's Page