Skip to content

Commit

Permalink
add dewpoint to forecast
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePeePs committed Jul 6, 2022
1 parent 026619d commit e40bf19
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -374,6 +374,7 @@ For ease of readability I have broken them out into separate tables. However you
| forecast_alert_limit | 1 | **Only applies to AerisWeather Alerts**. The number of alerts to show for your location. Max of 10.
| forecast_show_daily_forecast_link | 0 | Show a link beneath each forecast day to an external website with more details of the forecast.
| forecast_daily_forecast_link | "" | **Only applies to AerisWeather Alerts**. The actual link to the external detailed forecast site of your choosing. You must provide all relevant URL links like location, lat/lon, etc., but you can use `YYYY` to specify the 4 digit year, `MM` to specify the 2 digit month and `DD` to specify the 2 digit day of the forecast link. For example: `https://wx.aerisweather.com/local/us/ma/belchertown/forecast/YYYY/MM/DD`
|forecast_show_humidiy_dewpoint| 0 | **AerisWeather Only** 0 = disabled, 1 = humidity, 2 = dew point.
| aqi_enabled | 0 | Enables display of Air Quality Index from AerisWeather. Defaults to off. Turn on by setting this to `1`. AQI is read from the nearest reporting station within 50 miles. If no stations are available within 50 miles, no value will be available.
| aqi_location_enabled | 0 | Enables display of the AQI reporting station underneath AQI. Use this option to display where the AQI is being read from--it may be very far away, depending on your location.

Expand Down
30 changes: 28 additions & 2 deletions skins/Belchertown/js/belchertown.js.tmpl
Expand Up @@ -1219,11 +1219,13 @@ function update_forecast_data(data) {
avgTemp = data[(forecast_interval)][0]["response"][0]["periods"][i]["avgTempC"];
minTemp = data[(forecast_interval)][0]["response"][0]["periods"][i]["minTempC"];
maxTemp = data[(forecast_interval)][0]["response"][0]["periods"][i]["maxTempC"];
var dewPoint = data[(forecast_interval)][0]["response"][0]["periods"][i]["dewpointC"];
} else {
// Default
avgTemp = data[(forecast_interval)][0]["response"][0]["periods"][i]["avgTempF"];
minTemp = data[(forecast_interval)][0]["response"][0]["periods"][i]["minTempF"];
maxTemp = data[(forecast_interval)][0]["response"][0]["periods"][i]["maxTempF"];
var dewPoint = data[(forecast_interval)][0]["response"][0]["periods"][i]["dewpointF"];
}

// for 1hr interval determine temperature range, set to a minimum value of 2; also avoids div by zero
Expand Down Expand Up @@ -1264,6 +1266,9 @@ function update_forecast_data(data) {
*/
var precip = data[(forecast_interval)][0]["response"][0]["periods"][i]["pop"] || 0;

// Humidity
var humidity = data[(forecast_interval)][0]["response"][0]["periods"][i]["humidity"];

/*
Determine snow unit. "snowCM" and "snowIN" are specified
to always return a number. We still convert to 0 if we ever get
Expand Down Expand Up @@ -1299,6 +1304,8 @@ function update_forecast_data(data) {
"snow_depth": snow_depth,
"snow_unit": snow_unit,
"precip": precip,
"humidity": humidity,
"dewPoint": dewPoint,
"forecast_link": forecast_link
});
}
Expand All @@ -1322,17 +1329,31 @@ function update_forecast_data(data) {
}
output_html += '<span id="weekday">' + forecast_time(i, forecast_interval, forecast_row[i]["weekday"]) + '</span>';
output_html += '<br>';
output_html += '<div class="forecast-conditions">';
output_html += '<div class="forecast-conditions"';
#if $Extras.has_key("forecast_show_humidity_dewpoint") and $Extras.forecast_show_humidity_dewpoint > '0'
output_html += ' style="min-height:155px">'
output_html += '<div class="forecast-temp-graph" style="padding-top:';
// padding = ( ( highTemp - forecast_row[i]["avgTemp"] = offset ) * 76 / ( rangeTemp) ) where 100 ~ max calculated space available for padding
output_html += parseInt((highTemp - forecast_row[i]["avgTemp"] + offset) * 76 / (rangeTemp)) + 'px';
output_html += '; height:155px">'
#else
output_html += '>'
output_html += '<div class="forecast-temp-graph" style="padding-top:';
// padding = ( ( highTemp - forecast_row[i]["avgTemp"] = offset ) * 100 / ( rangeTemp) ) where 100 ~ max calculated space available for padding
// padding = ( ( highTemp - forecast_row[i]["avgTemp"] = offset ) * 100 / ( rangeTemp) ) where 100 ~ max calculated space available for padding
output_html += parseInt((highTemp - forecast_row[i]["avgTemp"] + offset) * 100 / (rangeTemp)) + 'px">';
#end if
output_html += '<div class="forecast-image">';
output_html += '<img id="icon" src="' + forecast_row[i]["image_url"] + '">';
output_html += '</div>';
output_html += parseFloat(forecast_row[i]["avgTemp"]).toFixed(0) + '&deg;</div>';
output_html += '</div>';
// output_html += '<br>';
output_html += '<div class="forecast-precip">';
#if $Extras.has_key("forecast_show_humidity_dewpoint") and $Extras.forecast_show_humidity_dewpoint == '1'
output_html += '<div><i class="wi wi-humidity rain-precip"></i> <span>' + parseFloat(forecast_row[i]["humidity"]).toFixed(0) + '%</span></div>';
#elif $Extras.has_key("forecast_show_humidity_dewpoint") and $Extras.forecast_show_humidity_dewpoint == '2'
output_html += '<div><i class="wi wi-raindrops rain-precip"></i> <span>' + parseFloat(forecast_row[i]["dewPoint"]).toFixed(0) + '&deg;</span></div>';
#end if
if (forecast_row[i]["snow_depth"] > 0) {
output_html += '<div class="snow-precip">';
// output_html += '<img src="'+get_relative_url()+'/images/snowflake-icon-15px.png"> <span>';
Expand Down Expand Up @@ -1380,6 +1401,11 @@ function update_forecast_data(data) {
output_html += '<span class="forecast-high">' + parseFloat(forecast_row[i]["maxTemp"]).toFixed(0) + '&deg;</span> | <span class="forecast-low">' + parseFloat(forecast_row[i]["minTemp"]).toFixed(0) + '&deg;</span>';
output_html += '<br>';
output_html += '<div class="forecast-precip">';
#if $Extras.has_key("forecast_show_humidity_dewpoint") and $Extras.forecast_show_humidity_dewpoint == '1'
output_html += '<i class="wi wi-humidity rain-precip"></i> <span>' + parseFloat(forecast_row[i]["humidity"]).toFixed(0) + '%</span> | ';
#elif $Extras.has_key("forecast_show_humidity_dewpoint") and $Extras.forecast_show_humidity_dewpoint == '2'
output_html += '<i class="wi wi-raindrops rain-precip"></i> <span>' + parseFloat(forecast_row[i]["dewPoint"]).toFixed(0) + '&deg;</span> | ';
#end if
if (forecast_row[i]["snow_depth"] > 0) {
output_html += '<div class="snow-precip">';
output_html += '<img src="' + get_relative_url() + '/images/snowflake-icon-15px.png"> <span>' + parseFloat(forecast_row[i]["snow_depth"]).toFixed(0) + '<span> ' + forecast_row[i]["snow_unit"];
Expand Down
1 change: 1 addition & 0 deletions skins/Belchertown/skin.conf
Expand Up @@ -85,6 +85,7 @@
forecast_alert_limit = 1
forecast_show_daily_forecast_link = 0
forecast_daily_forecast_link = ""
forecast_show_humidity_dewpoint = 2

# Air Quality Index (AQI) defaults
aqi_enabled = 0
Expand Down

1 comment on commit e40bf19

@fvirgola80
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good morning,
Would it be possible to enter other values ​​in addition to the dew point and humidity?
The idea would be to add
wind direction, pressure, millimeters or inc for rain and uv in 24h 3h and 1h
Thank you

Please sign in to comment.