On Monday, 18 March 2019 08:36:24 UTC+10, engolling wrote:
>
> Hi Gary,
>
> maybe I have found my problem after looking at my code and your advices 
> again.
> Because it seems that I have bound my additional signals to the archive 
> record and not to the LOOP packet
>

There is nothing wrong with augmenting archive records. As I pointed out in 
my first post there are two ways to add additional sensor data to WeeWX. 
One approach is to augment the archive record and to do this your would 
bind to NEW_ARCHIVE_RECORD. If you augment archive records you will not see 
any of your data in loop packets, this is normal expected behaviour. The 
other approach is to augment loop packets, to do this you must bind to 
NEW_LOOP_PACKET. If you augment loop packets your should see your data in 
loop packets and archive records. Note that if augmenting loop packets you 
may not necessarily see your data in every loop packet, it depends on how 
you implement your service. Neither approach is right or wrong, the 
approach you use is what best suits you or your setup.
 

> class WeeWxService(StdService):
>     def __init__(self, engine, config_dict):
>         super(WeeWxService, self).__init__(engine, config_dict)      
>         d = config_dict.get('WeatherDuino_logger_service', {})
>         self.filename = d.get('filename', 
> '/home/pi/WeatherDuino/WeeWx_Exp.txt')
>         syslog.syslog(syslog.LOG_INFO, "WeatherDuino: using %s" % self.
> filename)
>         self.bind(weewx.NEW_ARCHIVE_RECORD, self.read_file)
>         self.last_rain = []
>
>
>
> But the logfile tells me my plugin is executed in a frequency like the 
> loop packets:
> Mar 17 23:22:19 WeatherDuinoPi weewx[7972]: WeatherDuino: Valid values 
> found
> Mar 17 23:22:23 WeatherDuinoPi weewx[7972]: manager: Added record 
> 2019-03-17 23:21:00 CET (1552861260) to database 'weewx.sdb'
> Mar 17 23:22:23 WeatherDuinoPi weewx[7972]: manager: Added record 
> 2019-03-17 23:21:00 CET (1552861260) to daily summary in 'weewx.sdb'
> Mar 17 23:22:24 WeatherDuinoPi weewx[7972]: WeatherDuino: Valid values 
> found
> Mar 17 23:22:27 WeatherDuinoPi weewx[7972]: manager: Unable to add record 
> 2019-03-17 23:17:00 CET (1552861020) to database 'weewx.sdb': UNIQUE 
> constraint failed: archive.dateTime
> Mar 17 23:22:27 WeatherDuinoPi weewx[7972]: WeatherDuino: Valid values 
> found
> Mar 17 23:22:30 WeatherDuinoPi weewx[7972]: manager: Unable to add record 
> 2019-03-17 23:18:00 CET (1552861080) to database 'weewx.sdb': UNIQUE 
> constraint failed: archive.dateTime
> Mar 17 23:22:30 WeatherDuinoPi weewx[7972]: WeatherDuino: Valid values 
> found
> Mar 17 23:22:33 WeatherDuinoPi weewx[7972]: manager: Unable to add record 
> 2019-03-17 23:19:00 CET (1552861140) to database 'weewx.sdb': UNIQUE 
> constraint failed: archive.dateTime
> Mar 17 23:22:33 WeatherDuinoPi weewx[7972]: WeatherDuino: Valid values 
> found
>
> According to your answers this should be the problem because in this case 
> I have to take care that the rain is only augmented once each minute, right?
>

I am not sure what is going on with your system but the log extract above 
shows that WeeWX is attempting to save an archive record every few seconds 
- refer to the following entries:

Mar 17 23:22:27 WeatherDuinoPi weewx[7972]: manager: Unable to add record 
2019-03-17 23:17:00 CET (1552861020) to database 'weewx.sdb': UNIQUE 
constraint failed: archive.dateTime
Mar 17 23:22:30 WeatherDuinoPi weewx[7972]: manager: Unable to add record 
2019-03-17 23:18:00 CET (1552861080) to database 'weewx.sdb': UNIQUE 
constraint failed: archive.dateTime
Mar 17 23:22:33 WeatherDuinoPi weewx[7972]: manager: Unable to add record 
2019-03-17 23:19:00 CET (1552861140) to database 'weewx.sdb': UNIQUE 
constraint failed: archive.dateTime

This is not normal operation. Because something it triggering an archive 
record to be saved every few seconds the NEW_ARCHIVE_RECORD event is also 
triggered which causes your service to fire as well. The issue here is not 
your service but whatever is causing this archive record to be written 
every few seconds. I suggest we step back a bit and get a clear picture of 
how your system is configured and what it is running. I suggest you:

1. stop WeeWX
2. run the wee_debug utility 
<http://weewx.com/docs/utilities.htm#wee_debug_utility> and post a copy of 
the wee_debug output. Make sure any sensitive info is obscured before 
posting the wee_debug output, wee_debug will obscure most sensitive info 
but it is not perfect. 
3. post a copy of your service file 
(bin/user/WeeWx_WeatherDuino_Logger_plugin.py ?) from your RPi, it is 
important we know exactly what software you are running rather than looking 
at a github repo that may or may not be the same as on your machine.
 

>
> Should I change the binding to
>         self.bind(weewx.NEW_LOOP_PACKET, self.read_file)
>
>
> ?
>
> Moreover I try to simplify my code as you have proposed, so I added the 
> last line in the init function (is it a function ?) of the class.
> My idea was to make a empty list, which I can expand as I want because 
> there can be up to 4 rain values - is this a reasonable solution or do I 
> have to make a list with 4 entries at the beginning?
>

I would suggest not doing too much else as until the issue with the 
frequent archive records is solved your service will not operate correctly 
irrespective.

Gary

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to