Fixes for new BOM_rrd python
This commit is contained in:
parent
89ac550635
commit
52e456f13d
15
bom_rrd2.py
15
bom_rrd2.py
|
@ -28,10 +28,10 @@ bedroom_temp = 0
|
|||
|
||||
lounge = rrdtool.fetch("/media/media/mqtt/ESP_4c7682/temp.rrd", "AVERAGE")
|
||||
rows = lounge[2][::-1]
|
||||
for data in rows:
|
||||
if data[0] is not None:
|
||||
lounge_temp = int(data[0])
|
||||
break
|
||||
try:
|
||||
lounge_temp = int(rows[1][0])
|
||||
except TypeError:
|
||||
lounge_temp = int(rows[2][0])
|
||||
|
||||
bom_icons = {
|
||||
'sunny': 'SUNNY.JPG',
|
||||
|
@ -85,8 +85,8 @@ if night:
|
|||
new[day]['icon'] = bom_icons[weather['today']['icon_descriptor']]
|
||||
else:
|
||||
new[day]['day'] = datetime.datetime.strptime(weather[day]['date'], "%Y-%m-%dT%H:%M:%S%z").strftime("%A")
|
||||
new[day]['icon'] = bom_icons[weather['today']['icon_descriptor']]
|
||||
new[day]['max'] = weather['today']['temp_max']
|
||||
new[day]['icon'] = bom_icons[weather[day]['icon_descriptor']]
|
||||
new[day]['max'] = weather[day]['temp_max']
|
||||
|
||||
else:
|
||||
|
||||
|
@ -103,6 +103,7 @@ new['current']['outside'] = outside_temp
|
|||
new['current']['bedroom'] = bedroom_temp
|
||||
new['current']['lounge'] = lounge_temp
|
||||
|
||||
with open('bom.json', 'w') as output:
|
||||
with open('/var/www/darksky/bom.json', 'w') as output:
|
||||
output.write(json.dumps(new))
|
||||
output.close()
|
||||
|
||||
|
|
Loading…
Reference in New Issue