today_last_year = TimeSpanBinder(.....)
search_list_extension = {todaylastyear: 'today_last_year'}
$todaylastyear.outTemp.max
I'm making pretty good progress on this, but it is slow going to troubleshoot my extension script since I have to wait for the Cheetah Generator to run. Is there any way to run that process manually?Many thanks!
--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
today_last_year
week_last_year
mont_last_year
last_year
last_year_to_date--
import datetimeimport timefrom dateutil.relativedelta import relativedelta
from weewx.cheetahgenerator import SearchListfrom weewx.tags import TimespanBinderfrom weeutil.weeutil import TimeSpanfrom weeutil.weeutil import archiveDaySpanfrom weeutil.weeutil import archiveWeekSpanfrom weeutil.weeutil import archiveMonthSpanfrom weeutil.weeutil import archiveYearSpan
class ArchiveSearch(SearchList): # 1 """My search list extension"""
def __init__(self, generator): # 2 SearchList.__init__(self, generator) def get_extension_list(self, timespan, db_lookup): # 3 """Returns a search list extension with two additions. Parameters: timespan: An instance of weeutil.weeutil.TimeSpan. This will hold the start and stop times of the domain of valid times.
db_lookup: This is a function that, given a data binding as its only parameter, will return a database manager object. """
# First, create TimespanBinder object for all time. This one is easy # because the object timespan already holds all valid times to be # used in the report. all_time = TimespanBinder(timespan, db_lookup, formatter=self.generator.formatter, converter=self.generator.converter, context="month") # 4 # Now get a TimespanBinder object for the last seven days. This one we # will have to calculate. First, calculate the time at midnight, seven # days ago. The variable week_dt will be an instance of datetime.date. today_last_year_dt = datetime.date.fromtimestamp(timespan.stop) - relativedelta(years=1)
# Convert it to unix epoch time: today_last_year_ts = time.mktime(today_last_year_dt.timetuple()) # 6
today_last_year_time_span = archiveDaySpan(today_last_year_ts)
# Form a TimespanBinder object, using the time span we just # calculated: today_last_year= TimespanBinder(today_last_year_time_span, db_lookup, formatter=self.generator.formatter, converter=self.generator.converter, context="month") # 7#Assembles this week last year week_last_year_time_span = archiveWeekSpan(today_last_year_ts) # Form a TimespanBinder object, using the time span we just # calculated: week_last_year= TimespanBinder(week_last_year_time_span, db_lookup, formatter=self.generator.formatter, converter=self.generator.converter, context="month") # 7
#Assembles this month last year. month_last_year_time_span = archiveMonthSpan(today_last_year_ts) # Form a TimespanBinder object, using the time span we just # calculated: month_last_year= TimespanBinder(month_last_year_time_span, db_lookup, formatter=self.generator.formatter, converter=self.generator.converter, context="month") # 7
#Assembles last year. last_year_time_span = archiveYearSpan(today_last_year_ts) # Form a TimespanBinder object, using the time span we just # calculated: last_year= TimespanBinder(last_year_time_span, db_lookup, formatter=self.generator.formatter, converter=self.generator.converter, context="month") # 7
#Assembles last year to date. last_year_start_dt = datetime.date(today_last_year_dt.year,1,1)
last_year_start_ts = time.mktime(last_year_start_dt.timetuple())
# Form a TimespanBinder object, using the time span we just # calculated:
last_year_to_date= TimespanBinder(TimeSpan(last_year_start_ts, today_last_year_ts), db_lookup, formatter=self.generator.formatter, converter=self.generator.converter, context="month") # 7
# Now create a small dictionary with keys 'alltime' and 'seven_day': search_list_extension = {'today_last_year' : today_last_year, 'week_last_year' : week_last_year, 'month_last_year': month_last_year, 'last_year': last_year, 'last_year_to_date' : last_year_to_date, 'all_time' : all_time} # 8 # Finally, return our extension as a list: return [search_list_extension] # 9
[CheetahGenerator] # This section is used by the generator CheetahGenerator, and specifies # which files are to be generated from which template. # Possible encodings are 'html_entities', 'utf8', or 'strict_ascii' encoding = html_entities search_list_extensions = user.ArchiveSearch.ArchiveSearch
<div class="card" > <h1><i class="fa fa-history m-rot" ></i> History: Last Year to Date</h1> <div> <table class="tablespacer"> <tr><td colspan=3><h3>Outdoor Conditions</h3></td></tr> <tr><td>High Temperature</td><td>$last_year_to_date.outTemp.max</td><td>$last_year_to_date.outTemp.maxtime</td></tr> <tr><td>Low Temperature</td><td>$last_year_to_date.outTemp.min</td><td>$last_year_to_date.outTemp.mintime</td></tr> <tr><td>Average Temperature</td><td>$last_year_to_date.outTemp.avg</td><td></tr></tr> <tr><td>High Heat Index</td><td>$last_year_to_date.heatindex.max</td><td>$last_year_to_date.heatindex.maxtime</td></tr> <tr><td>Low Wind Chill</td><td>$last_year_to_date.windchill.min</td><td>$last_year_to_date.windchill.mintime</td></tr> <tr><td>High Dewpoint</td><td>$last_year_to_date.dewpoint.max</td><td>$last_year_to_date.dewpoint.maxtime</td></tr> <tr><td>Low Dewpoint</td><td>$last_year_to_date.dewpoint.min</td><td>$last_year_to_date.dewpoint.mintime</td></tr> <tr><td>High Humidity</td><td>$last_year_to_date.outHumidity.max</td><td>$last_year_to_date.outHumidity.maxtime</td></tr> <tr><td>Low Humidity</td><td>$year.outHumidity.min</td><td>$last_year_to_date.outHumidity.mintime</td></tr> <tr><td>High Barometer</td><td>$last_year_to_date.barometer.max</td><td>$last_year_to_date.barometer.maxtime</td></tr> <tr><td>Low Barometer</td><td>$last_year_to_date.barometer.min</td><td>$last_year_to_date.barometer.mintime</td></tr> <tr><td colspan=3><h3>Wind and Rain</h3></td></tr> <tr><td>High Wind Speed</td><td>$last_year_to_date.wind.max $last_year_to_date.wind.gustdir</td><td>$last_year_to_date.wind.maxtime</td></tr> <tr><td>Average Wind</td><td>$last_year_to_date.wind.avg</td><td></td></tr> <tr><td>RMS Wind</td><td>$last_year_to_date.wind.rms</td><td></td></tr> <tr><td>Vector Average Speed</td><td>$last_year_to_date.wind.vecavg</td><td></td></tr> <tr><td>Vector Average Direction</td><td>$last_year_to_date.wind.vecdir</td><td></td></tr> <tr><td colspan=3><h3>Indoor Conditions</h3></td></tr> <tr><td>High Inside Temperature</td><td>$last_year_to_date.inTemp.max</td><td>$last_year_to_date.inTemp.maxtime</td></tr> <tr><td>Low Inside Temperature</td><td>$last_year_to_date.inTemp.min</td><td>$last_year_to_date.inTemp.mintime</td></tr> </table> </div> </div>
--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/FHuFLPrg_DE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.