Pat,

$current has never covered aggregates so nothing unusual in that, for 
aggregates you need to bring a time span and an aggregate into the 
equation, eg $day, $week etc. Can still be done in a similar manner but 
instead of returning a CurrentObj object you now need to start looking at 
the interrelated TimeBinder, TimeSpanBinder and ObservationBinder classes.

Gary

On Tuesday, 23 April 2019 10:57:19 UTC+10, Pat wrote:
>
> I guess Option 2 doesn't cover aggregation types like min, max, sum 
> though. Guess I need to figure that out.
>
> On Monday, April 22, 2019 at 3:54:41 PM UTC-4, Pat wrote:
>>
>> After a couple of hours of trial and error, I may have solved this in 2 
>> ways:
>>
>> 1. Using the $current tag like below works.
>>
>>         #for $obs in $Extras.station_observations
>>             "$obs": "#echo getattr($current, $obs) #",
>>         #end for
>>
>> 2. Within an SLE
>>
>>         station_observations = self.generator.skin_dict['Extras'][
>> 'station_observations']
>>         binding = self.generator.config_dict['StdReport'].get(
>> 'data_binding', 'wx_binding')
>>         manager = self.generator.db_binder.get_manager(binding)
>>         currentStamp = manager.lastGoodStamp()
>>         current = weewx.tags.CurrentObj(db_lookup, None, currentStamp, 
>> self.generator.formatter, self.generator.converter)
>>         for obs in self.generator.skin_dict['Extras'][
>> 'station_observations']:
>>             obs_output = getattr(current, obs)
>>         
>>         Then add obs_output to the SLE return and use in the tmpl. 
>>
>> Option 2 allows me to be a little more flexible (like adding in DarkSky 
>> visibility API data if obs == "visibility" for example, or a custom rain 
>> and rainRate concat output). Hopefully I'm not re-inventing the wheel too 
>> much here.
>>
>>
>> On Monday, April 22, 2019 at 12:58:00 PM UTC-4, Pat wrote:
>>>
>>> I'm trying to see if it's possible to get the $current value from a 
>>> dynamic list. Take this example:
>>>
>>> skin.conf contains:
>>>
>>>     station_observations = "barometer", "visibility", "cloudbase", 
>>> "dewpoint", "humidity", "rain", "UV", "radiation"
>>>
>>>
>>> Within a skin tmpl file, I have this:
>>>
>>>             #for $obs in $Extras.station_observations
>>>             "$obs": "$current.$obs",
>>>             #end for
>>>
>>>
>>> It returns this:
>>>
>>> "barometer": "<weewx.tags.CurrentObj object at 0x7f140ec75350>.barometer", 
>>> "visibility": "<weewx.tags.CurrentObj object at 
>>> 0x7f140ec75790>.visibility", 
>>> "cloudbase": "<weewx.tags.CurrentObj object at 0x7f140ec75350>.cloudbase", 
>>> "dewpoint": "<weewx.tags.CurrentObj object at 0x7f140ec75790>.dewpoint", 
>>> "humidity": "<weewx.tags.CurrentObj object at 0x7f140ec75350>.humidity", 
>>> "rain": "<weewx.tags.CurrentObj object at 0x7f140ec75790>.rain",
>>> "UV": "<weewx.tags.CurrentObj object at 0x7f140ec75350>.UV", 
>>> "radiation": "<weewx.tags.CurrentObj object at 0x7f140ec75790>.radiation",
>>>
>>>
>>> Not the expected output. Is it possible to have this type of dynamic 
>>> lookup with $current?
>>>
>>> Thanks
>>>
>>

Reply via email to