diff --git a/bom_rrd2.py b/bom_rrd2.py index 878e351..2215d52 100755 --- a/bom_rrd2.py +++ b/bom_rrd2.py @@ -28,11 +28,11 @@ 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', 'clear': 'CLEAR.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() +