Bob,
When weeWX v3 was released there were a lot of changes (the big one was the
database structure - but that thas no effect on your driver). A lot of the
other changes were more subtle; some functions were renamed, others moved
and others reworked. One significant change was the move of the calculation
of so called derived observations (eg heatindex) out of the drivers and
into the service StdWXCalculate.
So what, well knowing this and given that your driver is fairly basic, it
is not too hard to rework your driver to be v3 compatible. I sat down this
morning and worked through it, did not take long. Have a look at the
attached Raspberry_Pi.txt (can't attach .py). The changes were:
1. use weewx.drivers rather than weewx.abstractstation
2. base class for your driver is now weewx.drivers.AbstractDevice
3. remove the heatindex, altimeter etc calcs from the driver, StdWXCalculate
will take care of this
4. due to 2. we can remove the altitude stuff from the loader() method
Left the heating and cooling degree stuff there, that is not covered by the
StdWXCalculate
service. This revised driver loads OK under 3.7.1, I didn't go as far as
setting up the data file to test it fully, that bit is up to you!
Gary
On Wednesday, 21 June 2017 22:45:21 UTC+10, Bob Snyder wrote:
>
> Awesome, Gary. That did it. Thank you! Now time to chase down driver
> bugs. Seems this one is from 2.x and has issues. Thanks again!
>
> On Tuesday, June 20, 2017 at 10:23:31 PM UTC-5, gjr80 wrote:
>>
>> Jun 20 21:17:30 wx-rpi weewx[24467]: engine: Using configuration file /
>>> etc/weewx/weewx.conf
>>>
>>
>> Ahah, my mistake, I assumed this was a setup.py instal
>> <http://weewx.com/docs/setup.htm>l but it appears it is not.
>>
>> No matter, do you have a directory /usr/share/weewx/user ? If so, try
>> putting Raspberry_Pi.py there, stop then start weeWX and see how that
>> goes. If it fails or if such a directory doesn't exist, it might be time to
>> post weewx.conf in its entirety (remove any passwords/sensitive info) as
>> well as a log extract from weewx start until it exits; often there are
>> clues in the leadup to, or the error trace after, the error occurs.
>>
>> Gary
>>
>> On Wednesday, 21 June 2017 13:03:24 UTC+10, Bob Snyder wrote:
>>>
>>> Thanks for the quick reply, Gary. Yes, /usr seemed odd to me. My mind
>>> went there instead of user when I read where to create the driver script.
>>>
>>> I implemented the changes you suggested but get the same error.
>>>
>>> pi@wx-rpi:/home/weewx/bin/user $ ls -l
>>> total 4
>>> -rw-r--r-- 1 pi pi 2664 Jun 20 21:17 Raspberry_Pi.py
>>>
>>> [Raspberry_Pi]
>>> loop_interval = 5
>>> driver = user.Raspberry_Pi
>>>
>>> Jun 20 21:53:16 wx-rpi weewx[24736]: engine: Loading station type
>>> Raspberry_Pi (user.Raspberry_Pi)
>>> Jun 20 21:53:16 wx-rpi weewx[24736]: engine: Caught unrecoverable
>>> exception in engine:
>>> Jun 20 21:53:16 wx-rpi weewx[24736]: **** No module named
>>> Raspberry_Pi
>>>
>>>
>>>
>>> On Tuesday, June 20, 2017 at 9:36:41 PM UTC-5, gjr80 wrote:
>>>>
>>>> Hi,
>>>>
>>>> I think you should be putting your Raspberry_Pi.py file in the
>>>> /home/weewx/bin/user
>>>> directory not /usr.
>>>>
>>>> Also, under [Raspberry_Pi] you should use
>>>>
>>>> driver = user.Raspberry_Pi
>>>>
>>>> not
>>>>
>>>> driver = usr.Raspberry_Pi
>>>>
>>>> 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.
#
# $Revision: 1 $
# $Author: Nickolas McColl $
# $Date: 2014-08-16 $
#
"""Raspberry Pi driver for the weewx weather system"""
from __future__ import with_statement
# import math
import time
#import weedb
#import weeutil.weeutil
import weewx.drivers
import weewx.wxformulas
def loader(config_dict, engine):
return Raspberry_Pi(**config_dict['Raspberry_Pi'])
class Raspberry_Pi(weewx.drivers.AbstractDevice):
"""Station using Raspberry Pi"""
def __init__(self, **stn_dict):
self.loop_interval = float(stn_dict.get('loop_interval'))
def genLoopPackets(self):
while True:
start_time = time.time()
# Create Loop packet
f = open('/var/tmp/weewx/bin/wxdata.csv')
input = f.readline()
f.close()
data = input.split(',')
if len(data) == 13: # data line is complete, process
for i in range(1, (len(data))):
try:
data[i] = float(data[i])
except ValueError:
data[i] = None
raw_time =time.strptime(data[0], "%Y-%m-%d %H:%M:%S")
_packet = {'dateTime': int(time.mktime(raw_time)),
'usUnits' : weewx.METRIC,
'pressure' : data[1],
'outTemp' : data[4],
'outHumidity' : data[5]}
_packet['heatdeg'] =
weewx.wxformulas.heating_degrees(_packet['outTemp'], 18.333)
_packet['cooldeg'] =
weewx.wxformulas.cooling_degrees(_packet['outTemp'], 18.333)
yield _packet
sleep_time = (start_time - time.time()) + self.loop_interval
if sleep_time > 0:
time.sleep(sleep_time)
def hardware_name(self):
return "Raspberry_Pi"