Skip to content

Commit

Permalink
Added stale_age for month and year tamplates. More easy deactivation …
Browse files Browse the repository at this point in the history
…of tables. [GH-14]
  • Loading branch information
Daveiano committed Jun 9, 2022
1 parent f05d5d5 commit dc62959
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/user/diagram_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_rounding(self, observation):
if observation == 'UV' or observation == 'cloudbase':
return 0

if observation == 'ET':
if observation == 'ET' or observation == 'rain':
return 2

return 1
Expand Down
9 changes: 4 additions & 5 deletions bin/user/table_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self, generator):
SearchList.__init__(self, generator)
self.unit = UnitInfoHelper(generator.formatter, generator.converter)
self.obs = ObsInfoHelper(generator.skin_dict)
self.diagram_util = DiagramUtil(SearchList)

def get_table_aggregate_interval(self, observation, precision):
"""
Expand All @@ -25,7 +26,6 @@ def get_table_aggregate_interval(self, observation, precision):
Returns:
int: aggregate_interval
"""
#return 3600 * 72 # 1 day
if precision == 'day':
return 900 * 8 # 2 hours

Expand Down Expand Up @@ -83,19 +83,18 @@ def get_table_rows(self, obs, period, precision):
"""
carbon_values = []

diagramUtil = DiagramUtil(SearchList)

# TODO: Get values directly from DB?
for observation in obs:
if getattr(period, observation).has_data:
series = getattr(period, observation).series(
aggregate_type=diagramUtil.get_aggregate_type(observation),
aggregate_type=self.diagram_util.get_aggregate_type(observation),
aggregate_interval=self.get_table_aggregate_interval(
observation,
precision
),
time_series='start',
time_unit='unix_epoch'
).round(diagramUtil.get_rounding(observation))
).round(self.diagram_util.get_rounding(observation))

for start, data in zip(series.start, series.data):
cs_time = datetime.fromtimestamp(start.raw)
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,7 @@
- Bugfix: Added forecast_util.py in install.py, see https://github.com/Daveiano/weewx-interceptor-docker/issues/1

# Next

- Updated rain rounding in diagrams
- Make Data Tables easy to deactivate, see readme
- Generate month and year pages less frequently
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ If you like the look and feel of the skin please consider having a look into the

### Installation

**Requires weewx >= 4.5**

**Please note:** For installation, please use the generated zip archive from a release, eg. https://github.com/Daveiano/weewx-wdc/releases/download/v1.2.0/weewx-wdc-v1.2.0.zip.
Don't download the repository directly and don't use the GitHub generated zip and tar.gz archives that come alongside the release. Always use the zip archive named **weewx-wdc-vX.X.X.zip**

Expand Down Expand Up @@ -222,6 +224,8 @@ SKIN_VERSION = 1.0.0-beta2
`climatological_days` E.g. Rain days (days with precipitation) or Summer days (Temp > 25°C). Leave empty to disable. When activated a rain days calendar chart and an averge temperature calendar chart is shown alongside.

`table_tile_observations` Defines which observations should be shown in the data table component.
Simply comment this out or leave empty to hide the tables at all pages:
`#table_tile_observations = outTemp, outHumidity, barometer, ...`

`stat_tile_observations` Define which observations should be shown in the stat tiles (at the top of each page).

Expand Down
2 changes: 2 additions & 0 deletions skins/weewx-wdc/index.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@
#end for
</div>

#if 'table_tile_observations' in $DisplayOptions
<div class="bx--row">
<!-- prettier-ignore -->
#include "includes/data-table-tile.inc"
</div>
#end if
</div>
</section>
</main>
Expand Down
2 changes: 2 additions & 0 deletions skins/weewx-wdc/month-%Y-%m.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@
#end for
</div>

#if 'table_tile_observations' in $DisplayOptions
<div class="bx--row">
<!-- prettier-ignore -->
#include "includes/data-table-tile.inc"
</div>
#end if
</div>
</section>
</main>
Expand Down
2 changes: 2 additions & 0 deletions skins/weewx-wdc/month.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@
#end for
</div>

#if 'table_tile_observations' in $DisplayOptions
<div class="bx--row">
<!-- prettier-ignore -->
#include "includes/data-table-tile.inc"
</div>
#end if
</div>
</section>
</main>
Expand Down
6 changes: 6 additions & 0 deletions skins/weewx-wdc/skin.conf
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,20 @@ SKIN_VERSION = 1.2.2
[[[NOAA_month]]]
encoding = normalized_ascii
template = NOAA/NOAA-%Y-%m.txt.tmpl
stale_age = 3600 # Every hour
[[[summary_month]]]
template = month-%Y-%m.html.tmpl
stale_age = 3600 # Every hour

[[SummaryByYear]]
# Reports that summarize "by year"
[[[NOAA_year]]]
encoding = normalized_ascii
template = NOAA/NOAA-%Y.txt.tmpl
stale_age = 3600 # Every hour
[[[summary_year]]]
template = year-%Y.html.tmpl
stale_age = 3600 # Every hour

# Reports that show statistics "to date", such as day-to-date,
# week-to-date, month-to-date, etc.
Expand All @@ -91,9 +95,11 @@ SKIN_VERSION = 1.2.2

[[[year]]]
template = year.html.tmpl
stale_age = 3600 # Every hour

[[[statistics]]]
template = statistics.html.tmpl
stale_age = 43200 # Twice a day

[[[celestial]]]
template = celestial.html.tmpl
Expand Down
3 changes: 3 additions & 0 deletions skins/weewx-wdc/statistics.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@
#end for
</div>

<!-- prettier-ignore -->
#if 'table_tile_observations' in $DisplayOptions and len($DisplayOptions.get('table_tile_observations', [])) > 0
<div class="bx--row">
<!-- prettier-ignore -->
#include "includes/data-table-tile.inc"
</div>
#end if
</div>
</section>
</main>
Expand Down
2 changes: 2 additions & 0 deletions skins/weewx-wdc/week.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@
#end for
</div>

#if 'table_tile_observations' in $DisplayOptions
<div class="bx--row">
<!-- prettier-ignore -->
#include "includes/data-table-tile.inc"
</div>
#end if
</div>
</section>
</main>
Expand Down
2 changes: 2 additions & 0 deletions skins/weewx-wdc/year-%Y.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@
#end for
</div>

#if 'table_tile_observations' in $DisplayOptions
<div class="bx--row">
<!-- prettier-ignore -->
#include "includes/data-table-tile.inc"
</div>
#end if
</div>
</section>
</main>
Expand Down
2 changes: 2 additions & 0 deletions skins/weewx-wdc/year.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@
#end for
</div>

#if 'table_tile_observations' in $DisplayOptions
<div class="bx--row">
<!-- prettier-ignore -->
#include "includes/data-table-tile.inc"
</div>
#end if
</div>
</section>
</main>
Expand Down

0 comments on commit dc62959

Please sign in to comment.