Daily weather and next day forecast in a template

Things I have tried

Explored the https://wttr.in site and browsed through a few threads here.

What I’m trying to do

I’d like to insert a pair of codes into a template for a daily running log.

In one line, the code should insert that particular day’s weather into the note matching the day that note was created. I’m looking mainly for temperature (in deg C), humidity, dewpoint, wind and wind direction. After the log is created, that weather information should not keep changing or updating. It is specific to that day.

In another line, a similar weather forecast for the next day would be handy as I read the note to plan my next day. Again, once the file is created , this information should be static.

Can anyone give me a helpful tip how to accomplish this?

From my reference vault. :slight_smile: I hope this gives you a leg up:

How to show the weather in Obsidian using wttr




  • https://wttr.in/Seattle.png - Show weather for Seattle as a png
  • ? - Begin parameters
  • I - Invert colors (normally it’s white-on-black)
  • 0 - Just show current weather, no forecast
  • &background=ffffff - Make background white



This will give you the current weather if you open the note 10 days later, not the weather on the date the page was first viewed/created. I think the poster wants to pull some web info and insert as static text into the page. I am not sure how to do this as you’d have to modify the underlying file and replace the link with the data it retrieves.

1 Like

Exactly, I dont want that weather data changing as I pull the log 10 days later. To give an idea of context, I’m trying to create a runner’s log. I want to capture the particular weather on the day I ran, so if it keeps changing everytime I access the log, it defeats the purpose.

Does anyone know how to pass an argument consisting of the date of creation of the note and a given time to the weather query? Then I think output will remain static.

Oh, I see! No, so far as I know wttr.in doesn’t record or provide historical info. I suppose you could copy the image and paste it into your daily doc so it would remain static, but I can’t think of an automated way to do that.

Sorry. Good luck, hope you find a solution!

1 Like

I use curl in a bash script to find out the current weather, and then created a user function with the Templater plugin system commands feature to return it’s output.

curl "wttr.in/Kiev?format=%m"

And then call the user function in my daily template:

<% tp.user.weathernow() %>

yes, i think that works. you create the note from a template and you get the result the original poster wants.

Thanks! That approaches what I’m looking for, but my implementation spits unformated text into my note when created from the template. Can you show your output what it looks like? What am I missing ?

Here’s mine.

Inputs -

Output -

I’m only looking for temperature, humidity, wind speed.

Alternatively, I used

curl “https://api.openweathermap.org/data/2.5/weather?q=Dubai&appid=a457e758ed0d9ab3fcc40xxxe&units=metric

and was able to get this

Much more reliable and textual information, although a bit verbose.

I still can’t figure out why my wttr code fails with the formatting. Let me know if one of you figured what I did wrong.

Use wttr.in/Dubai?T to avoid all the escape codes that you’re seeing.

To see all the options, try wttr.in/:help

Also you might want to enclose the output in your template inside a code block. (i.e. put three back ticks on the line before <% tp.user.weathernow() %> and three back ticks on the line after). The output from wttr.in won’t look right if it’s not seen with a monospaced font.

1 Like


curl -s Weather report: city

btw, if you want multiple cities, use:

curl -s http://wttr.in/{city1,city2,...}?format=4

1 Like

Tried it. Good tip with the backtick.

Here’s the output, still messy looking. I’m not sure what is the red font “esc” everywhere. This way I can’t read anything.

I’m assuming this is the implementation in user defined functions :

Output still messy.

All that junk you’re seeing are escape codes that color the output when viewed inside a terminal window (Mac or Linux). To get the site not to send those codes, you need to apply the ‘T’ option to your URL.

Thus your User Function should be defined as curl "https://wttr.in/Dubai?T"

‘T’ is not the only option. To see the complete list, using your web browser, go to https://wttr.in/:help.

For instance, I use https://wttr.in/Pohnpei?TuF0 which produces just:

Weather report: Pohnpei

       .-.      Light rain shower
      (   ).    +80(86) °F     
     (___(__)   ← 5 mph        
      ‘ ‘ ‘ ‘   13 mi          
     ‘ ‘ ‘ ‘    0.0 in         

[T = no terminal colors, u = U.S. units, F = no Follow line, and 0 (that’s a zero) = just the current weather]



When I leave the suffix just as Dubai?T, I get text thats bunching up.

Could it be the narrow view within the window? How can I expand it?

In Settings, under the Editor section, try turning off the Readable Line Length option. That will expand the width of all your notes, so it may be a change that you don’t really like overall.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.