jim-easterbrook / pywws

Python software for USB Wireless WeatherStations
https://pywws.readthedocs.io/
GNU General Public License v2.0
204 stars 62 forks source link

mqtt is missing records #107

Open MaxRower opened 1 year ago

MaxRower commented 1 year ago

The WS1080 is set to log data every five minutes, the cron job does run every five minutes to collect data, due to known USB troubles jobs often fail, so next time there will be two records to collect, but mqtt only transmits only one record instead. Only the last record seems to be sent. I think the cause is the missing time stamp fields in mqtt, but those could be added so all records are properly forwarded via mosquitto mqtt to telegraf and finally to influxdb?

python -m pywws.hourly -v /tmp/weather/ 03:00:01:pywws.logger:pywws version 22.9.0, build 1696 (e9ef20a) 03:00:01:pywws.logger:Python version 3.10.7 (main, Oct 10 2022, 16:14:30) [GCC 11.2.0] 03:00:01:pywws.weatherstation:using pywws.device_libusb1 03:00:03:pywws.logdata:Unrecognised 'magic number' 37 00 03:00:03:pywws.logdata:Synchronising to weather station 03:00:39:pywws.weatherstation:status {'lost_connection': False, 'rain_overflow': False} 03:00:45:pywws.logdata:Fetching data 03:00:45:pywws.logdata:2 catchup records 03:00:45:pywws.process:Generating summary data 03:00:45:pywws.calib:Using default calibration 03:00:45:pywws.regulartasks:doing task sections ['logged', 'hourly'] 03:00:46:pywws.service.mqtt:OK 03:00:46:pywws.service.mqtt:1 record sent

jim-easterbrook commented 1 year ago

Don't run a cron job every five minutes. As you've discovered it won't work correctly as one run may still be synchronising to the station when the next run starts. There's a reason why the module is called pywws.hourly. If you need data more frequently then use "live" logging.

service.mqtt is a pywws.service.LiveDataService - it only ever sends the most recent data. If you want to send complete data to a database you need to use something else.