Determine archive interval from within weewx

162 views
Skip to first unread message

Peter Fletcher

unread,
Jun 9, 2022, 3:40:03 PM6/9/22
to weewx-user
This may seem like a very stupid question, but I have not been able to google an answer. Is there a method or parameter that is accessible from within (e.g.) a user extension which gives the current archive interval?

Peter Fletcher

unread,
Jun 9, 2022, 4:54:30 PM6/9/22
to weewx-user
Approaching the search from a different angle, I have now found that, within an archive event handler (which is where I needed it), you can get it from the event record as ['interval'], but is there another and/or more general way?

Rainer Lang

unread,
Jun 9, 2022, 4:55:36 PM6/9/22
to weewx...@googlegroups.com

Not sure what you are exactly looking for,
but you can see your current archive interval in the syslog (usually in /var/log/syslog - just see two subsequent archiving log items)

or

in your weewx.conf (/etc/weewx/weewx.conf or /home/weewx/weewx.conf)

[StdArchive]

    # If the station hardware supports data logging then the archive interval
    # will be downloaded from the station. Otherwise, specify it (in seconds).
    archive_interval = 300  #example

Am 09.06.2022 um 21:40 schrieb 'Peter Fletcher' via weewx-user:
This may seem like a very stupid question, but I have not been able to google an answer. Is there a method or parameter that is accessible from within (e.g.) a user extension which gives the current archive interval?
--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/7ac93a73-ba27-4599-b30b-ff20d26e6970n%40googlegroups.com.
Message has been deleted

Glenn McKechnie

unread,
Jun 9, 2022, 7:18:38 PM6/9/22
to weewx...@googlegroups.com
On 10/06/2022, 'Peter Fletcher' via weewx-user
<weewx...@googlegroups.com> wrote:
> I know what my current archive interval is (Davis's default of 5 minutes)
> and I don't have any plans to change it, but, in writing user
> services/extensions, which others may conceivably use in the future, I
> don't like to hard-code a value which may be different in a different
> setup. I am sure that the current value of the parameter is accessible to
> code running 'within' weewx (but not within an archive record handler), but
>
> I couldn't find how to access it.

If you are using StdService then config_dict is available.

In UradMon I've used that to fetch the default value along the lines of

sf_int = to_int(config_dict['StdArchive'].get('archive_interval', 300))

Full code from line 292. Adjust to fit.

(Hopefully the following link can be recreated if it gets mangled)

https://github.com/glennmckechnie/weewx-uradmon/blob/73fc63371944d3b5480c1cca0e9fa35feb68c649/bin/user/uradmon.py#L292


--


Cheers
Glenn

rorpi - read only raspberry pi & various weewx addons
https://github.com/glennmckechnie

gjr80

unread,
Jun 9, 2022, 11:04:45 PM6/9/22
to weewx-user
Whilst in almost all cases the archive interval used by WeeWX will match the archive_interval config option in weewx.conf [StdArchive] this is not always the case. Installs that use software record generation always use an archive interval that matches the archive_interval config option; however, when using hardware record generation if the archive interval set in the station hardware is different to the archive_interval config option the archive_interval config option is ignored and the station hardware archive interval is used instead. This is most commonly seen with Davis stations used with a default WeeWX install. The Davis station uses an out-of-the-box 30 minute archive interval and that value overrides the default WeeWX archive interval of five minutes.

Using the interval field from the current archive record should always give the correct value.

Gary

jterr...@gmail.com

unread,
Jun 10, 2022, 9:04:06 AM6/10/22
to weewx-user
"Using the interval field from the current archive record should always give the correct value.".

I use it in my extension and it works very well: event.record['interval'] 

Peter Fletcher

unread,
Jun 10, 2022, 9:52:46 AM6/10/22
to weewx-user
Thanks to all! Granted that you are most likely to need to know the archive interval in the context of an archive interrupt service, where it is easily available and the returned value is reliable, it would be nice if the actual working value (rather than just the value from weewx.conf) were readily available in other contexts.

Karen K

unread,
Jun 10, 2022, 10:02:48 AM6/10/22
to weewx-user
In website templates you can use $current.interval to access or display the interval.

Jacques Terrettaz

unread,
Jun 10, 2022, 10:40:09 AM6/10/22
to weewx...@googlegroups.com
The Davis VP2 archive are recorded in the datalogger at the exact archive interval. 
So even if for any reason a service bound to NEW_ARCHIVE_RECORD is running a little bit later that the time the record was captured by the VP2, the data will still be valid, and the "event.record['interval'] " will be the interval between the two last recors received from the VP2.

Concerning our context of doing sunshine duration measurements based  on LOOP packets, these loop packets may be not always in phase with the archive  at the time an archive record is processed by weewx for our service
So for instance, I saw initially  with my archive interval of 5 min and during  a period of full sunshine, that the sunshine duration derived from loop packets during  an "archive" interval"  was a little bit higher that 5 min, or sometimes a little bit lower :

2022-06-06 11:30:19  weewx[4501] INFO user.sunduration: Sunshine duration from loop packets = 5.016667 min, last radiation = 828.000000, and last threshold = 639.982068

Given the context of "slow" update of solar radiation of the VP2 compared to the LOOP interval, I decided to round up the sunshine duration to full minutes

--
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/W0jG1kElJ1k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/87e7270c-2cbf-4438-a60b-638be2005049n%40googlegroups.com.

Peter Fletcher

unread,
Jun 10, 2022, 2:07:05 PM6/10/22
to weewx-user
Yes. This is potentially even more of a problem if you only determine whether the sun is shining when the radiation value changes, which is what I now do (with a timeout to deal with the instances when the 'gap' is a multiple of 50+ seconds). I have addressed it slightly differently - I accumulate seconds of sunshine and the total seconds elapsed between computations in the LOOP code and use the ratio of these (for each archive interval) to determine sunshine time for that interval.

Tom Keffer

unread,
Jun 14, 2022, 3:19:48 PM6/14/22
to weewx-user
When you instantiate a service, one of the parameters is the engine instance:

    def __init__(self, engine, config_dict):

The archive interval used by the engine can be obtained from it as

engine.console.archive_interval

-tk



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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/d030a216-4cfd-4df3-ad3c-55ae8df63cf8n%40googlegroups.com.

Peter Fletcher

unread,
Jun 14, 2022, 4:13:48 PM6/14/22
to weewx-user
Thanks! I take it that the interval returned by the engine in this way is the same as that in the archive packet - i.e. the hardware interval, if it is longer that that specified in weewx.conf.

Tom Keffer

unread,
Jun 14, 2022, 5:04:42 PM6/14/22
to weewx-user
Generally, yes they are the same.

Formally, the archive interval returned by the engine is the length of time it waits before attempting to create an archive record, whether via hardware, or via software.

The value 'interval' in a record is the aggregation time of the values in the record. 

Off hand, I can't imagine a scenario where they don't match, but I suppose it's possible.

Reply all
Reply to author
Forward
0 new messages