{{#Name=5 Day Forecast}} {{#Description=Displays the weather forecast for 5 days, used HS long/lat}} {{#Version=1.0}} {{#Author=HomeSeer}} {{#CanBeDeleted=False}} {{includefileraw Dashboards/Cards/Custom/Common/CommonHeader.html}} {{#get settings}} {{sections[index]="Settings"}} {{loc_long=get_value 'save_loc_long' (get_setting_text 'gLongitude') 'Location Longitude'}} {{loc_lat=get_value 'save_loc_lat' (get_setting_text 'gLatitude') 'Location Latitude'}} {{sections[index]="Title"}} {{title=get_value 'save_title' '' 'Name'}} {{title_size=get_value 'save_title_size' '25' 'Size'}} {{title_color=get_value 'save_title_color' '#000000' 'Color'}} {{sections[index]="Current Icon Size"}} {{current_icon_width=get_value 'save_current_icon_width' '50' 'Width'}} {{current_icon_height=get_value 'save_current_icon_height' '50' 'Height'}} {{sections[index]="Current Conditions"}} {{current_text_size=get_value 'save_current_text_size' '20' 'Size'}} {{current_text_color=get_value 'save_current_text_color' '#000000' 'Color'}} {{sections[index]="Current Temp"}} {{current_temp_size=get_value 'save_current_temp_size' '25' 'Size'}} {{current_temp_color=get_value 'save_current_temp_color' '#000000' 'Color'}} {{sections[index]="Current Humidity"}} {{current_humidity_size=get_value 'save_current_humidity_size' '25' 'Size'}} {{current_humidity_color=get_value 'save_current_humidity_color' '#000000' 'Color'}} {{sections[index]="Day"}} {{day_size=get_value 'save_day_size' '16' 'Size'}} {{day_color=get_value 'save_day_color' '#000000' 'Color'}} {{sections[index]="Day High Temp"}} {{day_temp_size=get_value 'save_day_temp_size' '16' 'Size'}} {{day_temp_color=get_value 'save_day_temp_color' '#FF8C00' 'Color'}} {{sections[index]="Day Low Temp"}} {{night_temp_size=get_value 'save_night_temp_size' '16' 'Size'}} {{night_temp_color=get_value 'save_night_temp_color' '#33c7ff' 'Color'}} {{sections[index]="Day Icon Size"}} {{icon_width=get_value 'save_icon_width' '40' 'Width'}} {{icon_height=get_value 'save_icon_height' '40' 'Height'}} {{#temp scale: empty string or "True" =F else C}} {{ch=get_setting_text 'gGlobalTempScaleF'}} {{temp_unit=''}} {{if ch=='' || ch=='True'}} {{temp_unit='&temperature_unit=fahrenheit'}} {{end}} {{weather_url='https://api.open-meteo.com/v1/forecast?latitude=' | string.append loc_lat | string.append '&longitude=' | string.append loc_long | string.append '&daily=weather_code,temperature_2m_max,temperature_2m_min¤t=temperature_2m¤t=is_day,temperature_2m,relative_humidity_2m,weather_code'}} {{weather_url=weather_url | string.append temp_unit}} {{if queries['fetch_weather_data']=='true'}} {{#we cache this request to limit the # of weather API requests}} {{#web_download_json_to_object url,useragent,cache_timeout(ms)}} {{obj=web_download_json_to_object weather_url "" 36000}} {{end}} {{if obj==null}}
Loading...
{{else}}
{{current_temp=obj.current.temperature_2m//1}} {{#// always rounds value to an integer}} {{current_humidity=obj.current.relative_humidity_2m}} {{current_code=obj.current.weather_code}} {{current_text=''}} {{ case current_code when 0 current_text="Sunny" when 1,2,3 current_text="Partly Cloudy" when 45,48 current_text="Fog" when 51,53,55 current_text="Drizzle" when 56,57 current_text="Freezing Drizzle" when 61,63,65 current_text="Rain" when 66,67 current_text="Freezing Rain" when 71,73,75 current_text="Snow" when 77 current_text="Sleet" when 80,81,82 current_text="Rain Showers" when 85,86 current_text="Snow Showers" when 95 current_text="Thunderstorms" when 96,99 current_text="Thunderstorms with Hail" end }} {{days=[]}} {{temph=[]}} {{templ=[]}} {{wc=[]}} {{index=0}} {{sunset=get_setting_text 'gSunset'}} {{dtsunset=date.parse sunset}} {{sunset_hour=date.to_string dtsunset "%H"}} {{current_hour=date.to_string date.now "%H"}} {{if current_hour > sunset_hour is_night=true else is_night=false end}} {{for tm in obj.daily.time}} {{dt=date.parse tm}} {{days[index]=date.to_string dt "%a"}} {{wc[index]=obj.daily.weather_code[index]}} {{temph[index]=obj.daily.temperature_2m_max[index]//1}} {{templ[index]=obj.daily.temperature_2m_min[index]//1}} {{index=index+1}} {{end}} {{if title != ''}}
{{title}}
{{end}}
{{current_temp}}°
{{current_text}}
{{current_humidity}}%
{{for i in 0..4}}
{{days[i]}}
{{temph[i]}}°
{{templ[i]}}°
{{end}}
{{#if we are not in edit mode, don't bother including the edit mode content}} {{if dbs.edit_mode}} {{# card settings dialog}} {{#this dialog has 2 tabs, one for formatting the card, the other for card content}}
{{end}} {{end}} {{if dbs.edit_mode}} {{includefileraw Dashboards/Cards/Custom/Common/CommonScript.html}} {{else}} {{end}}