TypeError: a float is required

978 views
Skip to first unread message

Hugo Valentim

unread,
Apr 12, 2013, 6:43:42 PM4/12/13
to weewx...@googlegroups.com
Hello,

I am trying to use Weewx 2.30 in Ubuntu 12.04 with a Fine Offset WH3080 (a.k.a W-8681-Solar) and I am getting this (the program aborts): TypeError: a float is required

Traceback (most recent call last):
 
File "./bin/weewxd", line 68, in <module>
    weewx
.wxengine.main(options, args)
 
File "/home/weewx/bin/weewx/wxengine.py", line 866, in main
    engine
.run()
 
File "/home/weewx/bin/weewx/wxengine.py", line 142, in run
   
self.dispatchEvent(weewx.Event(weewx.STARTUP))
 
File "/home/weewx/bin/weewx/wxengine.py", line 192, in dispatchEvent
    callback
(event)
 
File "/home/weewx/bin/weewx/wxengine.py", line 443, in startup
   
self._catchup()
 
File "/home/weewx/bin/weewx/wxengine.py", line 554, in _catchup
   
for record in self.engine.console.genArchiveRecords(lastgood_ts):
 
File "/home/weewx/bin/weewx/drivers/fousb.py", line 786, in genArchiveRecords
    records
= self.get_records(since_ts)
 
File "/home/weewx/bin/weewx/drivers/fousb.py", line 974, in get_records
    dt
= datetime.datetime.utcfromtimestamp(since_ts)
TypeError: a float is required



Lines 973 to 975 of drivers/fousb.py read:


               
if since_ts != 0:
                    dt
= datetime.datetime.utcfromtimestamp(since_ts)
                    dt
+= datetime.timedelta(seconds=fixed_block['read_period']*30)


Can anyone please poin the way out of this? Same behaviour with the deb package and the python installation.

Thanks in advance,



Thomas Keffer

unread,
Apr 12, 2013, 7:01:22 PM4/12/13
to weewx-user
Hi, Hugo

I'm not the author of this driver, so I may be getting myself into trouble, but can you try the following patch?

-tk

===================================================================
--- bin/weewx/drivers/fousb.py (revision 1164)
+++ bin/weewx/drivers/fousb.py (revision )
@@ -970,7 +970,7 @@
                     raise weewx.WeeWxIOError('invalid read_period in get_records')
                 if fixed_block['data_count'] is None:
                     raise weewx.WeeWxIOError('invalid data_count in get_records')
-                if since_ts != 0:
+                if since_ts:
                     dt = datetime.datetime.utcfromtimestamp(since_ts)
                     dt += datetime.timedelta(seconds=fixed_block['read_period']*30)
                 else:






--
You received this message because you are subscribed to the Google Groups "Weewx user's group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Tom Keffer
kef...@threefools.org
+1 541-386-8891 (h)
+1 541-490-9507 (c)
Skype: tkeffer

mwall

unread,
Apr 12, 2013, 7:12:12 PM4/12/13
to weewx...@googlegroups.com
it looks like utcfromtimestamp wants a float, not whatever it is getting.  so try replacing this:

    dt = datetime.datetime.utcfromtimestamp(since_ts)


with this:

    logerr('type of since_ts is %s' % type(since_ts))
    dt = datetime.datetime.utcfromtimestamp(float(since_ts))


Thomas Keffer

unread,
Apr 12, 2013, 7:17:37 PM4/12/13
to weewx-user
I could be wrong, but I think the problem is that the function genArchiveRecords(self, since_ts) is passed 'None' for the value of since_ts if all records are needed. The causes the test

if since_ts!=0

to evaluate True, when it should be False. Just replacing the test with a simple

if since_ts:

cures the problem.

-tk


--
You received this message because you are subscribed to the Google Groups "Weewx user's group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Hugo Valentim

unread,
Apr 12, 2013, 7:18:57 PM4/12/13
to weewx...@googlegroups.com
Indeed Tom. Your solution seems to have solved it. It is reading data right now.

Thanks a lot for the prompt reply.

Kirk Bressler

unread,
Apr 13, 2013, 1:12:23 PM4/13/13
to weewx...@googlegroups.com
I am having the same problem on a new install using the newest DEB. I know nota about python.
Where does this file reside in Ubuntu 12.10? I can't seem to find it. And is it a file that I can modify?

tks, Kirk

mwall

unread,
Apr 13, 2013, 1:23:08 PM4/13/13
to weewx...@googlegroups.com
On Saturday, April 13, 2013 1:12:23 PM UTC-4, Kirk Bressler wrote:
I am having the same problem on a new install using the newest DEB. I know nota about python.
Where does this file reside in Ubuntu 12.10? I can't seem to find it. And is it a file that I can modify?

hi kirk,

the file is /usr/share/weewx/weewx/drivers/fousb.py

m

Kirk Bressler

unread,
Apr 16, 2013, 6:09:40 AM4/16/13
to weewx...@googlegroups.com
That worked for me. Thanks
Reply all
Reply to author
Forward
0 new messages