How to get a the previous outTemp value in a driver

35 views
Skip to first unread message

peterq...@gmail.com

unread,
Jul 2, 2023, 3:50:14 PM7/2/23
to weewx-user
I have a customized Acurite driver where I've replaced the temperature reading with a reading from a different sensor. My sensor is placed so that I occasionally get temperature spikes in the late afternoon when the sun hits it. I've tried to shield it without complete success. I'm looking for a software solution where I can remove the bad values for the 10 minutes a day where it can jump up 5 degrees.

I think I know how to do this, but I'm stuck on getting the previous temperature value in the driver. Is there an easy way to do this? 

The docs suggest  weewx.manager.open_manager_with_config with the appropriate SQL query is the way to go. Is it?

Tom Keffer

unread,
Jul 2, 2023, 4:51:11 PM7/2/23
to weewx...@googlegroups.com
The problem with using open_manager_with_config is that you have to make assumptions about which database binding is being used.

Off the top of my head, here are 3 alternative solutions:
1. You could cache the previous value.
2. You could fix the problem downstream by using a weewx service.
3. You could use multiple inheritance, so your driver inherits both from weewx.drivers.AbstractDevice and from weewx.engine.StdService. Getting a database manager is then easy:
dbmanager = self.engine.db_binder.get_manager(self.data_binding)
See the Vantage driver for an example of using multiple inheritance (although it does not access the database).
But, really, you should relocate the sensor!
-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/9d0abdbe-8cf6-4d8b-b809-c295df20e564n%40googlegroups.com.

peterq...@gmail.com

unread,
Jul 2, 2023, 8:14:16 PM7/2/23
to weewx-user
Thanks!

Now that you mention it, it would be super easy to cache the old value. But, I took your advice and moved the sensor. 

Reply all
Reply to author
Forward
0 new messages