--
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/AvOx55kq49g/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/0c672f89-b119-4566-be10-141abb358058n%40googlegroups.com.
![]() | |
On Sep 29, 2024, at 3:44 PM, matthew wall <mwall...@gmail.com> wrote:
its not a moving average, but if you have an archive interval of 5 minutes and you post both loop and archive to MQTT then you'll get 5 minute averages as well as near-real-time values.
--
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/35efa133-9f08-45dc-bc65-fd959065aebbn%40googlegroups.com.
<tide-loop+archive.png>
That's a good idea. My Python skills aren't brilliant (I still write scripts like I'm in the 1990s) but I had considered writing a script totally outside of WeeWX to subscribe to the MQTT topics, perform this calculation, and emit the average. Doing with a WeeWX service would be a more elegant solution, so I will take a look at some examples.
class YourService(StdService):
def __init__(self, engine, conf_dict):
super(YourService,self).__init__(engine, conf_dict)
self.wind_readings_cache = []
self.bind(weewx.NEW_LOOP_PACKET, self.new_loop_packet)
def new_loop_packet(self, event):
wind = event.packet.get('windSpeed')
if wind is not None:
# do some calculations involving self.wind_readings_cache
event.packet['windSpeedAvg'] = ...

Such a service would look like this:class YourService(StdService):
def __init__(self, engine, conf_dict):
super(YourService,self).__init__(engine, conf_dict)
self.wind_readings_cache = []
self.bind(weewx.NEW_LOOP_PACKET, self.new_loop_packet)
def new_loop_packet(self, event):
wind = event.packet.get('windSpeed')
if wind is not None:
# do some calculations involving self.wind_readings_cache
event.packet['windSpeedAvg'] = ...
This is a rough sketch. There are more details to consider to complete it.
I've tested this out. I am not exactly sure if I understand this correctly, but it looks like that the loop and archive data is getting intermingled somehow.