Page 20 of 37
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 6:18 am
by krambriw
New version uploaded
- Added action to create Wind Rose reports using captured direction and average strength data
- Added regular updates (re-read) of table names
Support for wind in the ComboReport is using the captured gust data
As example of the wind rose below (my neighbor must have a problem with his wind sensor since it is always just showing 'N'...)
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 7:44 am
by Mastiff
So a wildcard upload isn't possible? Well, it works like this, first defining the list:
Code: Select all
eg.globals.FTPliste = {
"1":"1",
"2":"2"}
And then running the upload:
Code: Select all
import time
from threading import Thread, Event
def fileTransfer(transferCommandThreadEvent, fname):
from ftplib import FTP
ftp = FTP('ftp.hobsyssel.no')
ftp.login('hobsyssel.no', '0bel1xG@ller')
f = open("D:\\EventGhost\\Webserver for EventGhost\\Rom\\"+fname+".html", 'r')
ftp.cwd('/EG')
try:
ftp.delete(fname)
except:
pass
ftp.storlines('STOR '+fname+".html", f)
ftp.quit()
f.close()
transferCommandThreadEvent.set()
rows = eg.globals.FTPliste
for row in rows:
transferCommandThreadEvent = Event()
transferCommandThread = Thread(
target=fileTransfer,
args=(transferCommandThreadEvent, row)
)
transferCommandThread.start()
I'm pretty proud of me, even if that only uploads the first file (which for some reason is 2.html)! Maybe you can tell mye how to get it looping?
I'm pretty sure that's not correct, but it's an attempt...

Was the attempt good enough for me to give me the code?
Btw, I can't get any data from the wind sensor file. I use this code:
Code: Select all
import sqlite3
def GetAllData(
dbName,
dbTableId
):
dbName = str(dbName)
conn = sqlite3.connect(dbName)
c = conn.cursor()
t = ((dbTableId),)
try:
c.execute('SELECT * FROM '+dbName.split('.')[0]+' WHERE tableId=?', t)
coll = c.fetchall()
conn.close()
return coll
except:
conn.close()
return None
rows = GetAllData('windData.db', 'Vindmåler')
for row in rows:
print row
At it says that:
Code: Select all
09:14:19 Traceback (most recent call last):
09:14:19 Python script "63", line 22, in <module>
09:14:19 for row in rows:
09:14:19 TypeError: 'NoneType' object is not iterable
From what I gather that means that it's empty. But it isn't, the file is 277 kb so far. My lightData is 0, so is my humData, so do you know what can be the problem?
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 7:57 am
by Mastiff
Sorry, didn't see your second message. Here's my wind rose (which works even though I can get no data from the database with the code over). Very nice!
But I have one thing (of course): Is it possible to replace the English directions with Norwegian? Or is that hardcoded in the graph?
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 9:53 am
by krambriw
Nice wind rose!!!
Btw, I can't get any data from the wind sensor file. I use this code:
This script works with my data
Code: Select all
import sqlite3
try:
conn = sqlite3.connect('windData.db')
dbTableId = 'WindSensor on roof'
t = ((dbTableId),)
c = conn.cursor()
q = 'SELECT * FROM windData WHERE tableId=?'
p = c.execute(q, t)
coll = c.fetchall()
for item in coll:
print item
del coll
except sqlite3.Error, e:
conn.rollback()
print "Error %s:" % e.args[0]
finally:
if conn:
conn.close()
I'm pretty sure that's not correct, but it's an attempt...
I think something like this ( not tested):
Code: Select all
import time
from threading import Thread, Event
def fileTransfer(transferCommandThreadEvent, rows):
from ftplib import FTP
ftp = FTP('ftp.hobsyssel.no')
ftp.login('hobsyssel.no', '0bel1xG@ller')
ftp.cwd('/EG')
for fname in rows:
f = open("D:\\EventGhost\\Webserver for EventGhost\\Rom\\"+fname+".html", 'r')
try:
ftp.delete(fname+".html")
except:
pass
ftp.storlines('STOR '+fname+".html", f)
f.close()
ftp.quit()
transferCommandThreadEvent.set()
#rows = eg.globals.FTPliste
rows = [
"1",
"2"
]
transferCommandThreadEvent = Event()
transferCommandThread = Thread(
target=fileTransfer,
args=(transferCommandThreadEvent, rows)
)
transferCommandThread.start()
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 10:04 am
by krambriw
Is it possible to replace the English directions with Norwegian?
Currently hardcoded in CreateWindRoseHtml.py but I could make a list in that file that you can translate into Norwegian. Format like below
Code: Select all
directions = [
'N',
'NNE',
'NE',
'ENE',
'E',
'ESE',
'SE',
'SSE',
'S',
'SSW',
'SW',
'WSW',
'W',
'WNW',
'NW',
'NNW'
]
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 10:22 am
by krambriw
Uploaded a new version of Currently CreateWindRoseHtml.py
Go to line 46, there is this list, translate to Norwegian and you are done (please always keep a copy of your translation to re-use for coming versions if needed):
Code: Select all
directions = [
'N',
'NNE',
'NE',
'ENE',
'E',
'ESE',
'SE',
'SSE',
'S',
'SSW',
'SW',
'WSW',
'W',
'WNW',
'NW',
'NNW'
]
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 10:50 am
by Mastiff
Thanks! I'll check out that FTP code later today. As for the wind, would it be possible to have the script call rose.txt if it excists and then parse the list from there? That way there's no need to change for new versions.
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 11:31 am
by krambriw
As for the wind, would it be possible to have the script call rose.txt
I put the list in a separate file rose.py that you can translate
Files updated and uploaded
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 11:36 am
by Mastiff
Brilliant, thank you!

Re: ClimateDataCalculation
Posted: Mon May 04, 2015 11:40 am
by Mastiff
Oops... crashed and burned badly. East is ├ÿ/├©st in Norwegian, and it didn't like the ├©!

Didn't like the Swedish Ö either...
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 11:42 am
by krambriw
Put your translated list here as ode and I will try to fix the utf-8 stuff
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 11:47 am
by Mastiff
Thanks! I saved it as UTF-8 and was able to start EG (which gave me only errors when it was saved as ANSI), but I'm still not able to do that report. Here it is:
Code: Select all
directions = [
'N',
'NN├ÿ',
'N├ÿ',
'├ÿN├ÿ',
'├ÿ',
'├ÿS├ÿ',
'S├ÿ',
'SS├ÿ',
'S',
'SSV',
'SV',
'VSV',
'V',
'VNV',
'NV',
'NNV'
]
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 1:40 pm
by krambriw
Finally...new version uploaded (CreateWindRoseHtml.py and rose.py)
Re: ClimateDataCalculation
Posted: Mon May 04, 2015 1:46 pm
by Mastiff
Great, thanks! Btw I wonder if there is a problem with my sensor, or if there's no northwesterne at my cabin!

Re: ClimateDataCalculation
Posted: Mon May 04, 2015 1:58 pm
by krambriw
Btw I wonder if there is a problem with my sensor, or if there's no northwesterne at my cabin!
Hard to say
1) Could be you had no wind in that direction
2) Check the database and see if you find any entry
3) Could be a bug in the RFXtrx plugin (I hope not...)
4) Could be a bug in RFXtrx firmware...
You have seen that I only get N from my neighbor so something must be wrong somewhere...