Hello, Michael and welcome to WeeWX.

Would it work if I did  something like
> seven_day_stats1 = TimespanBinder ....
> seven_day_stats2 = TimespanBinder ....
> seven_day_stats = seven_day_stats1 - seven_day_stats2


Unfortunately, no, because there is no subtraction operator defined for
type TimespanBinder.

Why not just use the existing tag $trend
<http://weewx.com/docs/customizing.htm#_________Tag_$trend_______>? If
that's not what you had in mind, try hacking object TrendObj to get exactly
what you want.

-tk


On Tue, Nov 28, 2017 at 5:17 PM, Michael Hornsby <
[email protected]> wrote:

> Hi
>
> I'm migrating from wview and very excited with what can be done with
> weewx. At the moment I have php code and custom C code and I can see I can
> create a much better package with weewx.
>
> I'm trying to get my head around how a can construct a search list
> extension so I can find the change in a value from a week , month or year
> ago
>
> For example in a template I have this
> $week.outHumidity.avg.raw - $week($weeks_ago=1).outHumidity.avg.raw
>
> I want to know compared to last week / month / year whats the difference
> in the average temp , total rain etc
>
> I'm looking at the example below and thinking ok. So I need to run the
> stats for two periods and subtract them.
>
>
>  week_dt = datetime.date.fromtimestamp(timespan.stop) - \
>
>                     datetime.timedelta(weeks=1)                              
> # 5
>         # Convert it to unix epoch time:
>         week_ts = time.mktime(week_dt.timetuple())                           
> # 6
>         # Form a TimespanBinder object, using the time span we just
>         # calculated:
>         seven_day_stats = TimespanBinder(TimeSpan(week_ts, timespan.stop),
>                                          db_lookup,
>                                          formatter=self.generator.formatter,
>                                          converter=self.generator.converter,
>                                          skin_dict=self.generator.skin_dict)
>
>
>
> Would it work if I did  something like
>
> seven_day_stats1 = TimespanBinder ....
> seven_day_stats2 = TimespanBinder ....
>
> seven_day_stats = seven_day_stats1 - seven_day_stats2
>
>
> Thanks - I contributed a few features to wview. Hopefully I can do the
> same with weewx.
>
> Cheers
> Michael
>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to