Newer
Older
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''REST API to get Meteo data'''
# Third-party modules
###########################
# REST API
############################
api = Namespace(
'environment', description='Environment data from multiple devices')
@api.route("/status")
class Status(Resource):
"""Asks all the environment data"""
def get(self):
"""Downloads all the environment values available """
meteo = Meteo().get()
internal = Internal().get()
# meteo.update(internal)
res = {"external": meteo, "internal": internal}
return res
@api.route("/meteo")
class Meteo(Resource):
"""Asks all the meteo station data"""
@api.response(200, 'Success')
def get(self):
"""Downloads the current meteo station values"""
@api.route("/meteo/clock")
class MeteoClock(Resource):
"""Manages the meteo panel clock"""
@api.response(200, 'Success')
def get(self):
"""Retrieve the current date and time of the panel"""
@api.response(200, 'Success')
def put(self):
"""Syncronize the panel date and time with the pc calling this."""
@api.route("/internal")
class Internal(Resource):
"""Asks all the meteo station data"""
@api.response(200, 'Success')
def get(self):
"""Downloads the current meteo station values"""
if not telescope_temperatures:
print("telescope_temperatures device error!")
except Exception as e:
print("telescope_temperatures exception error:")
print(e)
# except Exception as e:
# log.debug(f"Environment camera_ambient error: {e}")
# camera_ambient = None
Davide Ricci
committed
"Temperature_M1": telescope_temperatures[0],
"Temperature_M2": telescope_temperatures[1],
"Temperature_cabinet": telescope_temperatures[2],
"Temperature_fork": devices.fork.temperature,
"Humidity_fork": devices.fork.humidity,
"Time_fork_data": devices.fork.last_update,
Davide Ricci
committed
"Temperature_rack": devices.rack.temperature,
"Humidity_rack": devices.rack.humidity,
"Time_rack_data": devices.rack.last_update,
Davide Ricci
committed
"Temperature_reception": devices.rec.temperature,
"Humidity_reception": devices.rec.humidity,
"Time_reception_data": devices.rec.last_update,