I'm not sure if this is the problem or not Jim (I presume you mean the service since you are using the
wxMeshService rather than the
wxMesh driver though both have the same line). I am more inclined to think that having the
wxMeshService update
dateTime and usUnits is more likely to cause a problem. That being said I think it may be prudent to make a few changes to the
wxMeshService, I'll come back to that later. First a bit of background as to what should be happening, then we can see what is happening and hopefully work out where the issue is. As you are no doubt aware weeWX is designed to work with a single driver (specified in
weewx.conf through the
station_type config option and the subsequent driver config option in the 'station_type' stanza. To allow data to be added to loop packets and archive records from additional sensors/sources, weeWX allows any number of services to be run as 'data services' where, ideally, these data services add observational data to the loop packet or archive record. The remaining weeWX services that act on the augmented loop packets and archive records as if the packet and record data had come from a single driver.
A driver should be emitting packets and/or records with a number of set fields and any number of observational data fields. The set fields are
dateTime (which holds the timestamp of the packet/record) and usUnits (which holds unit system info for the packet/record). The observational data fields can really be anything, they do not have to be part of the db schema (though only fields in the db schema will be saved to db) nor do they have to be numeric. Data services normally augment these packets/records. Whilst there is no technical reason why a service cannot alter fields already in the packet/record (just as
StdCalibrate does), data services normally just add fields to the existing packet/record. Ideally data services should not alter the packet/record
dateTime field, nor would they normally alter the packet/record
usUnits field. Strictly speaking there is nothing wrong with altering the
usUnits field but unless the data service also takes care of converting the existing packet/record observational data to the new unit system you run a very high chance of getting mixed units. The normal convention is for the data service to take note of the existing packet/record
usUnits value, convert the data generated by the data service to the correct unit system (if required) and then augment the packet/record with this converted data.
If there is more than one data service then each is run sequentially and the resulting packet/record is then passed onto the remaining services for processing. So the likes of
StdConvert,
StdCalibrate etc get to work on the augmented packet/record with
StdArchive accumulating loop packet data and ultimately saving archive records to db.
So in your case we should see the OWFS driver emit a loop packet, data service
wxMeshService should then add some additional fields from the MQTT broker and
StdCalibrate should adjust the UV value as per your formula. At the moment you have found the REC data (ie the archive record) UV value is uncalibrated. To get a better picture of what is going on I would suggest running weeWX directly with
debug set to 1. This will give us visibility of the data coming from
wxMeshService as well as showing us the resulting loop packets and archive records. To run weeWX directly with debug set to 1:
- edit weewx.conf and set debug=1
- save weewx.conf
- stop weeWX if it is running and then run it directly
- let weeWX run for at least 5 minutes
- stop weeWX
- weeWX should have been outputting LOOP and REC data to screen, LOOP is the resulting LOOP packet after all the services have done with it, REC is the archive record once everyone is done with it. Capture the last REC and a handful of LOOP packets leading up to the REC (more if you want) and post it back here
- weeWX should also have been logging the data it obtained from your MQTT broker. Have a look at the log and take an extract covering the same time period as the captured LOOP and REC data. Post the log extract here.
- Go back through the log to when you started weeWX directly and capture and post the entire startup sequence.
We should now be able to see exactly what is coming out of the wxMeshService as well as the resulting loop packets and archive records. Hopefully this will add to the picture.
I said I would come back to a few changes to wxMeshService. I would look at the following:
- avoid overwriting dateTime in event.packet or event.record. Either don't include them in the dictionary you use to update event.packet or event.record or update event.packet/event.record manually.
- make sure wxMeshService is usUnits aware. At the moment wxMeshService obtains a dictionary from the MQTT broker and the usUnits value is set to METRIC, presumably the MQTT broker emits data in weeWX METRIC units. Nothing wrong with that, but before the wxMeshService data is added to event.packet or event.record you should make sure event.packet/event.record and the wxMeshService data dictionary have the same usUnits values. If they are different I would convert the wxMeshService data to the same units as event.packet/event.record and then add the data. You may be fortunate and your OWFS may emit weeWX METRIC data but there is no guarantee that will be the case for others.
You have a complex setup and I guess the 'updating' of the dateTime field by wxMeshService could be causing some odd effect. I would try change 1. Change 2 is unlikely to have any effect on your current
issue as UV index is unitless (or the same UV units are used in all
weeWX unit systems), it just good coding to make the wxMeshService usable by a wider audience.
Somewhat long winded, sorry, but yours is a complex setup.
Gary