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?
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.
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.
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:
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 ?
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.
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.
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.