Skip to content

Commit

Permalink
Code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcScott committed Jan 17, 2017
1 parent 51327de commit 4a8987d
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions code/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,29 @@ def getplace(lat, lon):
if 'id' in msg['sensor-update']:
id = msg['sensor-update']['id']
url = 'https://apex.oracle.com/pls/apex/raspberrypi/weatherstation/getlatestwsdata/' + id
weather = get(url).json()['items'][0]
try:
town, country = getplace(weather['weather_stn_lat'],weather['weather_stn_long'])
weather = get(url).json()['items'][0]
try:
town, country = getplace(weather['weather_stn_lat'],weather['weather_stn_long'])
except:
town = 'Unknown'
country = 'Unknown'
s.sensorupdate({'air_pressure':weather['air_pressure']})
s.sensorupdate({'wind_gust_speed':weather['wind_gust_speed']})
s.sensorupdate({'wind_direction':weather['wind_direction']})
s.sensorupdate({'reading_timestamp':weather['reading_timestamp']})
s.sensorupdate({'wind_speed':weather['wind_speed']})
s.sensorupdate({'air_quality':weather['air_quality']})
s.sensorupdate({'ground_temp':weather['ground_temp']})
s.sensorupdate({'humidity':weather['humidity']})
s.sensorupdate({'weather_stn_lat':weather['weather_stn_lat']})
s.sensorupdate({'weather_stn_long':weather['weather_stn_long']})
s.sensorupdate({'ambient_temp':weather['ambient_temp']})
s.sensorupdate({'rainfall':weather['rainfall']})
s.sensorupdate({'town':town.replace(' ','-')})
s.sensorupdate({'country':country.replace(' ','-')})
except:
town = 'Unknown'
country = 'Unknown'
s.sensorupdate({'air_pressure':weather['air_pressure']})
s.sensorupdate({'wind_gust_speed':weather['wind_gust_speed']})
s.sensorupdate({'wind_direction':weather['wind_direction']})
s.sensorupdate({'reading_timestamp':weather['reading_timestamp']})
s.sensorupdate({'wind_speed':weather['wind_speed']})
s.sensorupdate({'air_quality':weather['air_quality']})
s.sensorupdate({'ground_temp':weather['ground_temp']})
s.sensorupdate({'humidity':weather['humidity']})
s.sensorupdate({'weather_stn_lat':weather['weather_stn_lat']})
s.sensorupdate({'weather_stn_long':weather['weather_stn_long']})
s.sensorupdate({'ambient_temp':weather['ambient_temp']})
s.sensorupdate({'rainfall':weather['rainfall']})
s.sensorupdate({'town':town.replace(' ','-')})
s.sensorupdate({'country':country.replace(' ','-')})
print('Station data not found. Please choose another ID')
if 'new-station' in msg['broadcast']:
station_id = choice(station_list)['weather_stn_id']
# print(station_id)
Expand Down

0 comments on commit 4a8987d

Please sign in to comment.