Simple Weather Forecast #1142
Ed-Mar
started this conversation in
Templates Showcase
Replies: 2 comments
-
This is really cool, thanks for making this! |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'm getting a "end of the stream or a document separator is expected" in Swagger for Line 16 that includes my code, any suggestions on how to resolve? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Simple Weather Forecast
Wanted a simple study to learn how to create/work with custom templates.
I do daily notes for task/events and that day's note is often the first thing I look at when I wake up. I thought having some weather information would be relativity helpful and simple to implement.
Weather API
I just picked a free one off the first page of google: https://www.weatherapi.com/ (Not Sponsored). Made and account and got my key and docs Swagger Doc . Note that you get 1 million API calls a month, but only up to a 3 day forecast.
User Code
forecast00.js
Templater 'Markup'
Result
Weather Forecast
Raleigh, North Carolina | Thursday 13th July, 2023
Overcast | ↑ 92.7°f | μ 83.9°f | ↓ 75.7°f | Hμ 72%
↳ Fri 14th: Heavy rain ↑ 91.4°f | Sat 15th: Moderate rain ↑ 88.5°f
Post Thoughts
Learned a good amount from this, mostly I remember by I don't like java script. There's a lot info in this API I did not use in the finial product, wind, solar and lunar info, uv index, Hourly forecast, heat/windchill/dew indexs, and etc. I just found the more I added it chunky it be came and the less I liked it. I just picked what I wanted
Forecast Table
Total Precipitation: <% forecastAPI.data.forecast.forecastday[0].day.totalprecip_in %>" <%* }else { %> <%* } -%><%* if ( forecastAPI.data.forecast.forecastday[0].day.totalsnow_cm > 0 ){ %>
Total Snow: <%forecastAPI.data.forecast.forecastday[0].day.totalsnow_cm %>(cm)<%* }else { %> <%* } -%><%* if (forecastAPI.data.forecast.forecastday[0].day.daily_chance_of_rain > 0 ){ %>
24h % of Rain: <%forecastAPI.data.forecast.forecastday[0].day.daily_chance_of_rain%>%<%* }else { %> <%* } -%>
Total Precipitation: <% forecastAPI.data.forecast.forecastday[1].day.totalprecip_in %>" <%* }else { %> <%* } -%><%* if (forecastAPI.data.forecast.forecastday[1].day.daily_chance_of_rain > 0 ){ %>
24h % of Rain: <%forecastAPI.data.forecast.forecastday[1].day.daily_chance_of_rain%>%<%* }else { %> <%* } -%>
Total Precipitation: <% forecastAPI.data.forecast.forecastday[2].day.totalprecip_in %>"<%* }else { %> <%* } -%><%* if ( forecastAPI.data.forecast.forecastday[2].day.totalsnow_cm > 0 ){ %>
Total Snow: <%forecastAPI.data.forecast.forecastday[2].day.totalsnow_cm %><%* }else { %> <%* } -%><%* if (forecastAPI.data.forecast.forecastday[2].day.daily_chance_of_rain> 0 ){ %>
24h % of Rain: <%forecastAPI.data.forecast.forecastday[2].day.daily_chance_of_rain%>%<%* }else { %> <%* } -%>
Beta Was this translation helpful? Give feedback.
All reactions