All,
I'm trying to write a simple service that creates a new derived measurement 
based on values already in the weewx database. Ultimately, I want to get a 
running total of the rainfall, but I'm not there yet. Also, not a Python 
developer by trade, but I'm trying.

My issue is: when I try to do arithmetic, the variables have, of course, to 
be numbers, be it int or float. I'll take the 'pressure' measurement as an 
example. Looking into the database, it seems to be a float, but it could 
also be a string.
But trying to use it that way, or trying to convert the string into a 
float, always gives me errors (could not convert string to float). I've 
tried stripping invisible whitespaces from the string (if it is one), but 
the error remains.
Here's the relevant code, one of the many I've tried.

So how do I get a weewx-variable into usable form? I'm probably missing 
something pretty basic here.
Thanks!
BTW, is there a way to test-run a service file? Like have the python code 
run in the weewx-environment?

foo = (float('pressure') * 10)

or

pressure_trim = 'pressure'.strip()  
foo = (float(pressure_trim) * 10)

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/f08bf769-d2b2-4840-b0a3-2feeef33ea67n%40googlegroups.com.

Reply via email to