commitmaster 2021.11.055ecf3f1173
Author: Craig Oates <craig@craigoates.net> Date: Fri Nov 5 18:35:56 2021 +0000 update README. commitf2aa373418
Author: Craig Oates <craig@craigoates.net> Date: Mon Jan 13 00:58:01 2020 +0000 make git ignore readings.db. commit9c1a023ab4
Author: Craig Oates <craig@craigoates.net> Date: Mon Jan 13 00:33:23 2020 +0000 make home page refresh every 60 seconds. commitb3efcc73c8
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 16:18:16 2020 +0000 add comment to device_check_token. commit747f6b847c
Merge:bf21990
ba85b56
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 16:00:02 2020 +0000 merge of unstable into stable commitba85b560ea
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 15:44:41 2020 +0000 add tim e of request info. to home. commit427d263812
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 15:21:36 2020 +0000 fix typo in YAML file. commite7e4923330
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 15:18:40 2020 +0000 add get latest (all) device status to YAML (A.P.I.) file. commitb4d9ca04fa
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 15:09:06 2020 +0000 reset database. commit3e80738d32
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 15:08:33 2020 +0000 add 400-error responses to GET requests in YAML file. commit13e2f5d3ba
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 15:03:27 2020 +0000 add 400-error info. to PUT request in YAML file. commitb01178a711
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 14:57:21 2020 +0000 add try-blocks to post requests. commitd377ef4eca
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 14:44:07 2020 +0000 add secirity token checks to status change A.P.I. call. commit95cb475428
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 14:35:26 2020 +0000 add security token checks when adding new reading. commitbf2199012e
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 00:17:39 2020 +0000 reset database. commitc24981a0e3
Author: Craig Oates <craig@craigoates.net> Date: Thu Jan 9 00:04:50 2020 +0000 reset database. commit0bb4ed4be8
Merge:bd20f7b
f32e4ae
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 23:56:26 2020 +0000 Merge branch 'unstable' of return-to-ritherdon/midpoint into stable commitf32e4aec4a
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 23:52:50 2020 +0000 update A.P.I. version to 1.0.0 - Alpha. commit1008d3e2e4
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 23:51:16 2020 +0000 implement home page status report feature. commit6394009f40
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 22:39:15 2020 +0000 implement get all status changes (all devices) A.P.I. call. commitfc3fe18b0e
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 22:30:25 2020 +0000 implement get all status changes (per device) A.P.I. call. commit65464fae54
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 21:59:35 2020 +0000 implement get device status latest A.P.I. call. commit641fe8f604
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 21:08:07 2020 +0000 add device status-update logging. commit312bcd70a6
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 19:04:38 2020 +0000 remove in-mem readings and refactor related items. commitc4590b906c
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 03:30:47 2020 +0000 add website info. section to home. commit1ded49cfcf
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 03:20:48 2020 +0000 add artwork status bar to home page. commit628ea5a9a2
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 02:28:56 2020 +0000 add styling and content to home page. commit400c0f0310
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 00:25:16 2020 +0000 add route for robots.txt. commitbb05c5e151
Author: Craig Oates <craig@craigoates.net> Date: Wed Jan 8 00:10:12 2020 +0000 create robot.txt file. commit5bdd448b7e
Author: Craig Oates <craig@craigoates.net> Date: Tue Jan 7 23:58:55 2020 +0000 add favicons. commitbd20f7be7d
Merge:1975e6e
2d6ba68
Author: Craig Oates <craig@craigoates.net> Date: Tue Jan 7 23:46:14 2020 +0000 Merge branch 'unstable' of return-to-ritherdon/midpoint into stable commit2d6ba68682
Author: Craig Oates <craig@craigoates.net> Date: Tue Jan 7 23:43:37 2020 +0000 update requirements in proj-env. commit1975e6ecbf
Author: Craig Oates <craig@craigoates.net> Date: Tue Jan 7 23:24:52 2020 +0000 create v-env. for server and update requirements. commit373b6686ad
Author: Craig Oates <craig@craigoates.net> Date: Mon Jan 6 01:18:35 2020 +0000 create html templates. commit9f0c71ada2
Author: Craig Oates <craig@craigoates.net> Date: Sun Jan 5 23:51:37 2020 +0000 port code over from test proj. commitc1f174f828
Author: Craig Oates <craig@craigoates.net> Date: Sun Jan 5 22:52:51 2020 +0000 create virtual environment.
@ -1,3 +1,14 @@
|
||||
# midpoint |
||||
# Return to Ritherdon: Midpoint |
||||
|
||||
A web A.P.I. built with Flask and Python. Its main purpose is to receive the readings from the light meters welding booths in the Ritherdon factory and make them available for consumption by the relay-controllers in the gallery. |
||||
This is a web REST-APIbuilt with Flask and Python. Its main purpose is |
||||
to receive the readings from the light meters welding booths in the |
||||
Ritherdon factory and make them available for consumption by the |
||||
relay-controllers in the gallery. Midpoint is one of three projects |
||||
which combine to form the 'Personal Flash in Real-Time' artwork -- |
||||
which is one of several artworks created as part of the 'Return to |
||||
Ritherdon' project. For more information on this repository and |
||||
'Return to Ritherdon', please use the links below: |
||||
|
||||
- [Return to Ritherdon Overview](https://git.abbether.net/return-to-ritherdon/rtr-docs) |
||||
- [Midpoint Documentation](https://git.abbether.net/return-to-ritherdon/rtr-docs/src/branch/master/midpoint/rtr-midpoint.md) |
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
from services import post_services, get_services |
||||
|
||||
''' |
||||
API Functions |
||||
====================================================================== |
||||
These functions are what are exposed/referenced in the swagger.yml |
||||
file -- they are essentially wrapper functions. The main work is done |
||||
in the files in the /services/ folder. |
||||
These functions are acting as very light controllers essentially. |
||||
''' |
||||
|
||||
def post_a_reading(light_meter, the_reading): |
||||
return post_services.add_latest_reading(light_meter, the_reading) |
||||
|
||||
def post_a_status_change(device, the_status_change): |
||||
return post_services.log_status_change(device, the_status_change) |
||||
|
||||
def get_latest(light_meter): |
||||
return get_services.get_latest_reading(light_meter) |
||||
|
||||
def get_all_readings(light_meter): |
||||
return get_services.get_all_readings_from_table(light_meter) |
||||
|
||||
def get_all_readings_for_every_meter(): |
||||
return get_services.get_all_readings_from_database() |
||||
|
||||
def get_latest_device_status(device): |
||||
return get_services.get_latest_status(device) |
||||
|
||||
def get_all_status_log(device): |
||||
return get_services.get_all_status_logs_from_table(device) |
||||
|
||||
def get_all_status_logs_for_every_device(): |
||||
return get_services.get_all_status_changes_from_database() |
||||
|
||||
def get_current_status_for_all_devices(): |
||||
return get_services.get_latest_status_for_all_devices() |
@ -0,0 +1,25 @@
|
||||
from flask import Flask, render_template |
||||
from datetime import datetime |
||||
import connexion |
||||
import config |
||||
from services import get_services |
||||
|
||||
# The application instance. |
||||
app = config.connex_app |
||||
|
||||
# The yml file configures the app's endpoints. |
||||
app.add_api("swagger.yml") |
||||
|
||||
@app.route("/") |
||||
def home (): |
||||
data = get_services.get_latest_status_for_all_devices() |
||||
time = datetime.now() |
||||
return render_template("home.html", data=data, time=time) |
||||
|
||||
@app.route("/robots.txt") |
||||
@app.route("/robots") |
||||
def robots(): |
||||
return render_template("robots.txt") |
||||
|
||||
if __name__ == "__main__": |
||||
app.run(host="0.0.0.0", debug=False) |
@ -0,0 +1,69 @@
|
||||
import os |
||||
from datetime import datetime |
||||
from config import db |
||||
from models.meters import Meter1, Meter2, Meter3 |
||||
from models.devices import Device1, Device2, Device3, Device4, Device5, Device6 |
||||
|
||||
def get_timestamp(): |
||||
return datetime.now().strftime(("%Y-%m-%d %H:%M:%S")) |
||||
|
||||
# The initialisation data for the database |
||||
READINGS1 =[ {"time":datetime.now(), "reading": 0} ] |
||||
READINGS2 =[ {"time":datetime.now(), "reading": 0} ] |
||||
READINGS3 =[ {"time":datetime.now(), "reading": 0} ] |
||||
DEVICE1 = [ {"time":datetime.now(), "status": "off"} ] |
||||
DEVICE2 = [ {"time":datetime.now(), "status": "off"} ] |
||||
DEVICE3 = [ {"time":datetime.now(), "status": "off"} ] |
||||
DEVICE4 = [ {"time":datetime.now(), "status": "off"} ] |
||||
DEVICE5 = [ {"time":datetime.now(), "status": "off"} ] |
||||
DEVICE6 = [ {"time":datetime.now(), "status": "off"} ] |
||||
|
||||
# Deletes the database if it already exists |
||||
if os.path.exists("readings.db"): |
||||
os.remove("readings.db") |
||||
|
||||
# Creates the database |
||||
db.create_all() |
||||
|
||||
# Iterates over the READINGS1 structure and populates the database |
||||
for info in READINGS1: |
||||
r = Meter1(time=info.get("time"), reading=info.get("reading")) |
||||
db.session.add(r) |
||||
|
||||
# Iterates over the READINGS2 structure and populates the datebase |
||||
for info in READINGS2: |
||||
r = Meter2(time=info.get("time"), reading=info.get("reading")) |
||||
db.session.add(r) |
||||
|
||||
# Iterates over the READINGS3 structure and populates the datebase. |
||||
for info in READINGS3: |
||||
r = Meter3(time=info.get("time"), reading=info.get("reading")) |
||||
db.session.add(r) |
||||
|
||||
# These are the light-meters in Ritherdon. |
||||
for info in DEVICE1: |
||||
r = Device1(time=info.get("time"), status=info.get("status")) |
||||
db.session.add(r) |
||||
|
||||
for info in DEVICE2: |
||||
r = Device2(time=info.get("time"), status=info.get("status")) |
||||
db.session.add(r) |
||||
|
||||
for info in DEVICE3: |
||||
r = Device3(time=info.get("time"), status=info.get("status")) |
||||
db.session.add(r) |
||||
|
||||
# These are the relays in the gallery. |
||||
for info in DEVICE4: |
||||
r = Device4(time=info.get("time"), status=info.get("status")) |
||||
db.session.add(r) |
||||
|
||||
for info in DEVICE5: |
||||
r = Device5(time=info.get("time"), status=info.get("status")) |
||||
db.session.add(r) |
||||
|
||||
for info in DEVICE6: |
||||
r = Device6(time=info.get("time"), status=info.get("status")) |
||||
db.session.add(r) |
||||
|
||||
db.session.commit() |
@ -0,0 +1,24 @@
|
||||
import os |
||||
import connexion |
||||
from flask_sqlalchemy import SQLAlchemy |
||||
from flask_marshmallow import Marshmallow |
||||
|
||||
basedir = os.path.abspath(os.path.dirname(__file__)) |
||||
|
||||
# Creates the Connexion application instance |
||||
connex_app = connexion.App(__name__, specification_dir=basedir) |
||||
|
||||
# Gets the underlying Flask app instance |
||||
app = connex_app.app |
||||
database_uri = "sqlite:////" + os.path.join(basedir, "readings.db") |
||||
|
||||
# Configures the SQLAlchemy part of the app instance |
||||
app.config["SQLALCHEMY_ECHO"] = True # Set to false in prod. |
||||
app.config["SQLALCHEMY_DATABASE_URI"] = database_uri |
||||
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False |
||||
|
||||
# Creates the SQLAlchemy db instance |
||||
db = SQLAlchemy(app) |
||||
|
||||
# Initialises Marshmallow |
||||
ma = Marshmallow(app) |
@ -0,0 +1,82 @@
|
||||
from datetime import datetime |
||||
from config import db, ma |
||||
|
||||
''' |
||||
Note on Duplication Levels |
||||
====================================================================== |
||||
While the code in this file seems very duplicated, it is just the |
||||
result of using SQL-Alchemy (ORM) and the repetitive nature of the |
||||
project as a whole. At the time of writing, the expected amount of |
||||
devices is six. They must keep their info. separate from each other. |
||||
This means a table in the database for each device. This is the main |
||||
cause for the repetitive/duplicated code. Because this project has |
||||
fixed requirements, the hard-coded nature is a trade-off because of |
||||
this. If the project increases the amount of devices it uses, this |
||||
will probably need to be refactored. |
||||
''' |
||||
|
||||
class Device1(db.Model): |
||||
__tablename__ = "device1" |
||||
id = db.Column(db.Integer, primary_key=True) |
||||
time = db.Column(db.DateTime, default=datetime.utcnow) |
||||
status = db.Column(db.String) |
||||
|
||||
class Device1Schema(ma.ModelSchema): |
||||
class Meta: |
||||
model = Device1 |
||||
sqla_session = db.session |
||||
|
||||
class Device2(db.Model): |
||||
__tablename__ = "device2" |
||||
id = db.Column(db.Integer, primary_key=True) |
||||
time = db.Column(db.DateTime, default=datetime.utcnow) |
||||
status = db.Column(db.String) |
||||
|
||||
class Device2Schema(ma.ModelSchema): |
||||
class Meta: |
||||
model = Device2 |
||||
sqla_session = db.session |
||||
|
||||
class Device3(db.Model): |
||||
__tablename__ = "device3" |
||||
id = db.Column(db.Integer, primary_key=True) |
||||
time = db.Column(db.DateTime, default=datetime.utcnow) |
||||
status = db.Column(db.String) |
||||
|
||||
class Device3Schema(ma.ModelSchema): |
||||
class Meta: |
||||
model = Device3 |
||||
sqla_session = db.session |
||||
|
||||
class Device4(db.Model): |
||||
__tablename__ = "device4" |
||||
id = db.Column(db.Integer, primary_key=True) |
||||
time = db.Column(db.DateTime, default=datetime.utcnow) |
||||
status = db.Column(db.String) |
||||
|
||||
class Device4Schema(ma.ModelSchema): |
||||
class Meta: |
||||
model = Device4 |
||||
sqla_session = db.session |
||||
|
||||
class Device5(db.Model): |
||||
__tablename__ = "device5" |
||||
id = db.Column(db.Integer, primary_key=True) |
||||
time = db.Column(db.DateTime, default=datetime.utcnow) |
||||
status = db.Column(db.String) |
||||
|
||||
class Device5Schema(ma.ModelSchema): |
||||
class Meta: |
||||
model = Device5 |
||||
sqla_session = db.session |
||||
|
||||
class Device6(db.Model): |
||||
__tablename__ = "device6" |
||||
id = db.Column(db.Integer, primary_key=True) |
||||
time = db.Column(db.DateTime, default=datetime.utcnow) |
||||
status = db.Column(db.String) |
||||
|
||||
class Device6Schema(ma.ModelSchema): |
||||
class Meta: |
||||
model = Device6 |
||||
sqla_session = db.session |
@ -0,0 +1,50 @@
|
||||
from datetime import datetime |
||||
from config import db, ma |
||||
|
||||
''' |
||||
Note on Duplication Levels |
||||
====================================================================== |
||||
While the code in this file seems very duplicated, it is just the |
||||
result of using SQL-Alchemy (ORM) and the repetitive nature of the |
||||
project as a whole. At the time of writing, the expected amount of |
||||
light meters is three and each one must take their own readings. |
||||
But, they must keep their readings separate from each other. This |
||||
means a table in the database for each meter. This is the main cause |
||||
for the repetitive/duplicated code. |
||||
Because this project has fixed requirements, the hard-coded nature is |
||||
a trade-off because of this. If the project increases the amount of |
||||
light meters it uses, this will probably need to be refactored. |
||||
''' |
||||
|
||||
class Meter1(db.Model): |
||||
__tablename__ = "meter1" |
||||
id = db.Column(db.Integer, primary_key=True) |
||||
time = db.Column(db.DateTime, default=datetime.utcnow) |
||||
reading = db.Column(db.Integer) |
||||
|
||||
class Meter1Schema(ma.ModelSchema): |
||||
class Meta: |
||||
model = Meter1 |
||||
sqla_session = db.session |
||||
|
||||
class Meter2(db.Model): |
||||
__tablename__ = "meter2" |
||||
id = db.Column(db.Integer, primary_key=True) |
||||
time = db.Column(db.DateTime) |
||||
reading = db.Column(db.Integer) |
||||
|
||||
class Meter2Schema(ma.ModelSchema): |
||||
class Meta: |
||||
model = Meter2 |
||||
sqla_session = db.session |
||||
|
||||
class Meter3(db.Model): |
||||
__tablename__ = "meter3" |
||||
id = db.Column(db.Integer, primary_key=True) |
||||
time = db.Column(db.DateTime) |
||||
reading = db.Column(db.Integer) |
||||
|
||||
class Meter3Schema(ma.ModelSchema): |
||||
class Meta: |
||||
model = Meter3 |
||||
sqla_session = db.session |
@ -0,0 +1,214 @@
|
||||
from flask import make_response, abort |
||||
from config import db |
||||
from models.meters import (Meter1, Meter1Schema, Meter2, Meter2Schema, |
||||
Meter3, Meter3Schema) |
||||
from models.devices import (Device1, Device1Schema, Device2, Device2Schema, |
||||
Device3, Device3Schema, Device4, Device4Schema, |
||||
Device5, Device5Schema, Device6, Device6Schema) |
||||
|
||||
''' |
||||
Get Services Note |
||||
====================================================================== |
||||
The functions in this file are for retrieving data stored at the (this) |
||||
server. If you want to store any readings taken with the light meters |
||||
at Ritherdon, you will need to head to the /post_services.py/ file. |
||||
It should be in the same directory at this: /services/. |
||||
''' |
||||
|
||||
bad_meter_id_message = "Meter Id. not recognised. Must be between 1 and 3." |
||||
bad_device_id_message = "Device Id. not recognised. Must be between 1 and 6." |
||||
|
||||
def get_latest_reading(meter): |
||||
if meter == 1: |
||||
return get_m1_latest() |
||||
elif meter == 2: |
||||
return get_m2_latest() |
||||
elif meter == 3: |
||||
return get_m3_latest() |
||||
return make_response(bad_meter_id_message, 400) |
||||
|
||||
def get_all_readings_from_table(name): |
||||
if name == 1: |
||||
return get_all_readings_for_meter1() |
||||
elif name == 2: |
||||
return get_all_readings_for_meter2() |
||||
elif name == 3: |
||||
return get_all_readings_for_meter3() |
||||
return make_response(bad_meter_id_message, 400) |
||||
|
||||
def get_all_readings_from_database(): |
||||
return get_all_readings() |
||||
|
||||
def get_latest_status(device): |
||||
if device == 1: |
||||
return get_d1_latest() |
||||
elif device == 2: |
||||
return get_d2_latest() |
||||
elif device == 3: |
||||
return get_d3_latest() |
||||
elif device == 4: |
||||
return get_d4_latest() |
||||
elif device == 5: |
||||
return get_d5_latest() |
||||
elif device == 6: |
||||
return get_d6_latest() |
||||
return make_response(bad_device_id_message, 400) |
||||
|
||||
def get_all_status_logs_from_table(device): |
||||
if device == 1: |
||||
return get_all_status_logs_for_d1() |
||||
elif device == 2: |
||||
return get_all_status_logs_for_d2() |
||||
elif device == 3: |
||||
return get_all_status_logs_for_d3() |
||||
elif device == 4: |
||||
return get_all_status_logs_for_d4() |
||||
elif device == 5: |
||||
return get_all_status_logs_for_d5() |
||||
elif device == 6: |
||||
return get_all_status_logs_for_d6() |
||||
return make_response(bad_device_id_message, 400) |
||||
|
||||
def get_all_status_changes_from_database(): |
||||
return get_all_status_logs() |
||||
|
||||
def get_latest_status_for_all_devices(): |
||||
return get_all_latest_logs() |
||||
|
||||
''' |
||||
The Nitty-Gritty Functions |
||||
====================================================================== |
||||
The functions below are the main functions within this file. The files |
||||
above act as "header functions" to be called by the functions in /api.py/. |
||||
I find it easier to see what the method names are when this file and |
||||
/api.py/ are open side-by-side. At the very least it reduces the amount |
||||
I need to scroll up and down the file to find what I am after. |
||||
''' |
||||
|
||||
def get_m1_latest(): |
||||
reading = Meter1.query.order_by(Meter1.id.desc()).first() |
||||
meter_schema = Meter1Schema() |
||||
return meter_schema.dump(reading) |
||||
|
||||
def get_m2_latest(): |
||||
reading = Meter2.query.order_by(Meter2.id.desc()).first() |
||||
meter_schema = Meter2Schema() |
||||
return meter_schema.dump(reading) |
||||
|
||||
def get_m3_latest(): |
||||
reading = Meter3.query.order_by(Meter3.id.desc()).first() |
||||
meter_schema = Meter3Schema() |
||||
return meter_schema.dump(reading) |
||||
|
||||
def get_all_readings_for_meter1(): |
||||
readings = Meter1.query.order_by(Meter1.id.desc()).all() |
||||
schema = Meter1Schema(many=True) |
||||
data = schema.dump(readings) |
||||
return data |
||||
|
||||
def get_all_readings_for_meter2(): |
||||
readings = Meter2.query.order_by(Meter2.id.desc()).all() |
||||
schema = Meter2Schema(many=True) |
||||
data = schema.dump(readings) |
||||
return data |
||||
|
||||
def get_all_readings_for_meter3(): |
||||
readings = Meter3.query.order_by(Meter3.id.desc()).all() |
||||
schema = Meter3Schema(many=True) |
||||
data = schema.dump(readings) |
||||
return data |
||||
|
||||
def get_all_readings(): |
||||
m1 = get_all_readings_for_meter1() |
||||
m2 = get_all_readings_for_meter2() |
||||
m3 = get_all_readings_for_meter3() |
||||
readings = {"meter1": m1, "meter2": m2, "meter3": m3} |
||||
return readings |
||||
|
||||
def get_d1_latest(): |
||||
status = Device1.query.order_by(Device1.id.desc()).first() |
||||
device_schema = Device1Schema() |
||||
return device_schema.dump(status) |
||||
|
||||
def get_d2_latest(): |
||||
status = Device2.query.order_by(Device2.id.desc()).first() |
||||
device_schema = Device2Schema() |
||||
return device_schema.dump(status) |
||||
|
||||
def get_d3_latest(): |
||||
status = Device3.query.order_by(Device3.id.desc()).first() |
||||
device_schema = Device3Schema() |
||||
return device_schema.dump(status) |
||||
|
||||
def get_d4_latest(): |
||||
status = Device4.query.order_by(Device4.id.desc()).first() |
||||
device_schema = Device4Schema() |
||||
return device_schema.dump(status) |
||||
|
||||
def get_d5_latest(): |
||||
status = Device5.query.order_by(Device5.id.desc()).first() |
||||
device_schema = Device5Schema() |
||||
return device_schema.dump(status) |
||||
|
||||
def get_d6_latest(): |
||||
status = Device6.query.order_by(Device6.id.desc()).first() |
||||
device_schema = Device6Schema() |
||||
return device_schema.dump(status) |
||||
|
||||
def get_all_status_logs_for_d1(): |
||||
status_logs = Device1.query.order_by(Device1.id.desc()).all() |
||||
schema = Device1Schema(many=True) |
||||
data = schema.dump(status_logs) |
||||
return data |
||||
|
||||
def get_all_status_logs_for_d2(): |
||||
status_logs = Device2.query.order_by(Device2.id.desc()).all() |
||||
schema = Device2Schema(many=True) |
||||
data = schema.dump(status_logs) |
||||
return data |
||||
|
||||
def get_all_status_logs_for_d3(): |
||||
status_logs = Device3.query.order_by(Device3.id.desc()).all() |
||||
schema = Device3Schema(many=True) |
||||
data = schema.dump(status_logs) |
||||
return data |
||||
|
||||
def get_all_status_logs_for_d4(): |
||||
status_logs = Device4.query.order_by(Device4.id.desc()).all() |
||||
schema = Device4Schema(many=True) |
||||
data = schema.dump(status_logs) |
||||
return data |
||||
|
||||
def get_all_status_logs_for_d5(): |
||||
status_logs = Device5.query.order_by(Device5.id.desc()).all() |
||||
schema = Device5Schema(many=True) |
||||
data = schema.dump(status_logs) |
||||
return data |
||||
|
||||
def get_all_status_logs_for_d6(): |
||||
status_logs = Device6.query.order_by(Device6.id.desc()).all() |
||||
schema = Device6Schema(many=True) |
||||
data = schema.dump(status_logs) |
||||
return data |
||||
|
||||
def get_all_status_changes_from_database(): |
||||
d1 = get_all_status_logs_for_d1() |
||||
d2 = get_all_status_logs_for_d2() |
||||
d3 = get_all_status_logs_for_d3() |
||||
d4 = get_all_status_logs_for_d4() |
||||
d5 = get_all_status_logs_for_d5() |
||||
d6 = get_all_status_logs_for_d6() |
||||
logs = {"device 1": d1, "device 2": d2, "device 3": d3, |
||||
"device 4": d4, "device 5": d5, "device 6": d6} |
||||
return logs |
||||
|
||||
def get_all_latest_logs(): |
||||
d1 = get_d1_latest() |
||||
d2 = get_d2_latest() |
||||
d3 = get_d3_latest() |
||||
d4 = get_d4_latest() |
||||
d5 = get_d5_latest() |
||||
d6 = get_d6_latest() |
||||
logs = {"device 1": d1, "device 2": d2, "device 3": d3, |
||||
"device 4": d4, "device 5": d5, "device 6": d6} |
||||
return logs |
@ -0,0 +1,134 @@
|
||||
from flask import make_response, abort |
||||
from config import db |
||||
from models.meters import (Meter1, Meter1Schema, Meter2, Meter2Schema, |
||||
Meter3, Meter3Schema) |
||||
from models.devices import (Device1, Device1Schema, Device2, Device2Schema, |
||||
Device3, Device3Schema, Device4, Device4Schema, |
||||
Device5, Device5Schema, Device6, Device6Schema) |
||||
|
||||
''' |
||||
Post Services Note |
||||
====================================================================== |
||||
The functions in this file are for storing the readings taken from the |
||||
light meters in Ritherdon, and log changes in state for any of the |
||||
devices. It you are wanting to retrieve data from the (this) server, |
||||
you will need to head to the /get_services.py/ file. It should be in |
||||
the same directory as this: /services/. |
||||
''' |
||||
|
||||
# This will need to change if this repo. was cloned and used for |
||||
# something outside the realm of the "Return to Ritherdon" project. |
||||
device_check_token = "QWERTYuiopasdfghjklzxcvbnm_1234567890" |
||||
|
||||
def add_latest_reading(meter, info): |
||||
try: |
||||
if info["token"] == device_check_token: |
||||
reading = {"reading":info["reading"], "time":info["time"]} |
||||
if meter == 1: |
||||
return add_reading_to_meter1(reading) |
||||
elif meter == 2: |
||||
return add_reading_to_meter2(reading) |
||||
elif meter == 3: |
||||
return add_reading_to_meter3(reading) |
||||
return make_response("Meter Id. not recognised. Must be between 1 and 3.", 400) |
||||
return make_response("Invalid token.", 400) |
||||
except: |
||||
return make_response("The data you sent was invalid or incorrectly formatted.", 400) |
||||
|
||||
def log_status_change(device, info): |
||||
try: |
||||
if info["token"] == device_check_token: |
||||
status = {"time":info["time"], "status":info["status"]} |
||||
if device == 1: |
||||
return add_status_change_to_device1(status) |
||||
elif device == 2: |
||||
return add_status_change_to_device2(status) |
||||
elif device == 3: |
||||
return add_status_change_to_device3(status) |
||||
elif device == 4: |
||||
return add_status_change_to_device4(status) |
||||
elif device == 5: |
||||
return add_status_change_to_device5(status) |
||||
elif device == 6: |
||||
return add_status_change_to_device6(status) |
||||
return make_response("Device Id. not recognised. Must be between 1 and 6.", 400) |
||||
return make_response("Invalid token.", 400) |
||||
except: |
||||
return make_response("The data you sent was invalid or incorrectly formatted.", 400) |
||||
|
||||
''' |
||||
Nitty-Gritty Functions |
||||
====================================================================== |
||||
The functions above are basically "header" functions. It makes it |
||||
easier to have multiple files open at once and see what this module |
||||
provides function-wise. The functions below do the real work in this |
||||
file. Please keep the "public" functions about this comment and defer |
||||
the main work to here. The "public" functions should be as thin as |
||||
possible to make them as scanable as possible. |
||||
''' |
||||
|
||||
reading_message = "Reading successfully stored in database." |
||||
status_message = "Status change successfully logged in database." |
||||
|
||||
def add_reading_to_meter1(the_reading): |
||||
schema = Meter1Schema() |
||||
new_reading = schema.load(the_reading, session=db.session) |
||||
db.session.add(new_reading) |
||||
db.session.commit() |
||||
return make_response(reading_message, 201) |
||||
|
||||
def add_reading_to_meter2(the_reading): |
||||
schema = Meter2Schema() |
||||
new_reading = schema.load(the_reading, session=db.session) |
||||
db.session.add(new_reading) |
||||
db.session.commit() |
||||
return make_response(reading_message, 201) |
||||
|
||||
def add_reading_to_meter3(the_reading): |
||||
schema = Meter3Schema() |
||||
new_reading = schema.load(the_reading, session=db.session) |
||||
db.session.add(new_reading) |
||||
db.session.commit() |
||||
return make_response(reading_message, 201) |
||||
|
||||
def add_status_change_to_device1(status): |
||||
schema = Device1Schema() |
||||
new_status = schema.load(status, session=db.session) |
||||
db.session.add(new_status) |
||||
db.session.commit() |
||||
return make_response(status_message, 201) |
||||
|
||||
def add_status_change_to_device2(status): |
||||
schema = Device2Schema() |
||||
new_status = schema.load(status, session=db.session) |
||||
db.session.add(new_status) |
||||
db.session.commit() |
||||
return make_response(status_message, 201) |
||||
|
||||
def add_status_change_to_device3(status): |
||||
schema = Device3Schema() |
||||
new_status = schema.load(status, session=db.session) |
||||
db.session.add(new_status) |
||||
db.session.commit() |
||||
return make_response(status_message, 201) |
||||
|
||||
def add_status_change_to_device4(status): |
||||
schema = Device4Schema() |
||||
new_status = schema.load(status, session=db.session) |
||||
db.session.add(new_status) |
||||
db.session.commit() |
||||
return make_response(status_message, 201) |
||||
|
||||
def add_status_change_to_device5(status): |
||||
schema = Device5Schema() |
||||
new_status = schema.load(status, session=db.session) |
||||
db.session.add(new_status) |
||||
db.session.commit() |
||||
return make_response(status_message, 201) |
||||
|
||||
def add_status_change_to_device6(status): |
||||
schema = Device6Schema() |
||||
new_status = schema.load(status, session=db.session) |
||||
db.session.add(new_status) |
||||
db.session.commit() |
||||
return make_response(status_message, 201) |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 8.4 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 8.9 KiB |
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<browserconfig><msapplication><tile><square70x70logo src="/ms-icon-70x70.png"/><square150x150logo src="/ms-icon-150x150.png"/><square310x310logo src="/ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig> |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,41 @@
|
||||
{ |
||||
"name": "App", |
||||
"icons": [ |
||||
{ |
||||
"src": "\/android-icon-36x36.png", |
||||
"sizes": "36x36", |
||||
"type": "image\/png", |
||||
"density": "0.75" |
||||
}, |
||||
{ |
||||
"src": "\/android-icon-48x48.png", |
||||
"sizes": "48x48", |
||||
"type": "image\/png", |
||||
"density": "1.0" |
||||
}, |
||||
{ |
||||
"src": "\/android-icon-72x72.png", |
||||
"sizes": "72x72", |
||||
"type": "image\/png", |
||||
"density": "1.5" |
||||
}, |
||||
{ |
||||
"src": "\/android-icon-96x96.png", |
||||
"sizes": "96x96", |
||||
"type": "image\/png", |
||||
"density": "2.0" |
||||
}, |
||||
{ |
||||
"src": "\/android-icon-144x144.png", |
||||
"sizes": "144x144", |
||||
"type": "image\/png", |
||||
"density": "3.0" |
||||
}, |
||||
{ |
||||
"src": "\/android-icon-192x192.png", |
||||
"sizes": "192x192", |
||||
"type": "image\/png", |
||||
"density": "4.0" |
||||
} |
||||
] |
||||
} |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,71 @@
|
||||
html { |
||||
font-family: arial, sans-serif; |
||||
background: #f5f5f5; |
||||
color: #424242; |
||||
} |
||||
|
||||
main { |
||||
display: flex; |
||||
justify-content: center; |
||||
padding: 20px; |
||||
} |
||||
|
||||
main div { |
||||
max-width: 800px; |
||||
left-margin: auto; |
||||
right-margin: auto; |
||||
} |
||||
|
||||
main div .header { |
||||
display: flex; |
||||
justify-content: center; |
||||
flex-direction: column; |
||||
align-items: center; |
||||
} |
||||
|
||||
main div .header img { |
||||
width: 50px; |
||||
} |
||||
|
||||
main div .header h1 { |
||||
text-align: center; |
||||
font-size: 20px; |
||||
} |
||||
|
||||
main div .status-bar { |
||||
display: flex; |
||||
margin: 5px; |
||||
flex-wrap: wrap; |
||||
justify-content: space-evenly; |
||||
padding: 20px; |
||||
border-top: 2px solid #424242; |
||||
border-bottom: 2px solid #424242; |
||||
margin: 5px 0; |
||||
} |
||||
|
||||
.meter { |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
flex-direction: column; |
||||
} |
||||
|
||||
main div .status-bar .meter img { |
||||
width: 30px; |
||||
height: 30px; |
||||
} |
||||
|
||||
.meter p { |
||||
padding: 0px; |
||||
margin: 0px; |
||||
} |
||||
|
||||
|
||||
main div .server-header, |
||||
main div .server-time { |
||||
margin: 0; |
||||
} |
||||
|
||||
main div .server-time { |
||||
font-size: 12px; |
||||
} |
@ -0,0 +1,440 @@
|
||||
swagger: "2.0" |
||||
info: |
||||
description: >- |
||||
The 'Return to Ritherdon' project, by Nicola Ellis, is a two year art residency at Ritherdon & Co Ltd, a manufacturer of metal enclosures based in Darwen, Lancashire U.K. This website is part of the many outcomes produced throughout the duration of project. |
||||
version: "1.0.0 - Beta" |
||||
title: Return to Ritherdon Project A.P.I. |
||||
consumes: |
||||
- application/json |
||||
produces: |
||||
- application/json |
||||
|
||||
basePath: /api |
||||
|
||||
paths: |
||||
# Light-Meter A.P.I. Calls |
||||
# ==================================================================== |
||||
/readings/add/{light_meter}: |
||||
post: |
||||
operationId: api.post_a_reading |
||||
tags: |
||||
- Log Light-Meter Readings |
||||
summary: >- |
||||
Posts a reading from one of the project's light meters and store |
||||
it in the database. |
||||
description: >- |
||||
Use this U.R.L. to post a new reading from of the light meters |
||||
used in the project. At the time of writing, there are three |
||||
light meters taking readings in the Ritherdon factory. |
||||
It is important to note which light meter is posting the |
||||
reading. Each light meter has its own table in the database |
||||
and it will corrupt the data integrity if you post a reading |
||||
from a meter into the wrong table. At the time of writing, |
||||
there are three meters taking light reading and posting them |
||||
to here. |
||||
parameters: |
||||
- name: light_meter |
||||
in: path |
||||
description: >- |
||||
The Id. of the light meter which has taken the reading. At |
||||
the time of writing, it should be a number between 1-3. |
||||
type: integer |
||||
required: True |
||||
- name: the_reading |
||||
in: body |
||||
description: >- |
||||
The data object which represents a single light reading |
||||
from light meter 1. It conveys the time the reading was |
||||
taken and the light value it recorded. Remember, each light |
||||
has their own table in the database so make sure you do not |
||||
post the light meter reading to the wrong URL. It will |
||||
corrupt the data integrity. |
||||
required: True |
||||
schema: |
||||
type: object |
||||
properties: |
||||
time: |
||||
type: string |
||||
format: date-time |
||||
example: 2019-10-19 17:04:57 |
||||
description: >- |
||||
The date and time the reading was taken. Make sure |
||||
you use the UTC time format. This is because the |
||||
A.P.I. has made a design decision to standardise on |
||||
it. |
||||
reading: |
||||
type: integer |
||||
example: 23 |
||||
description: >- |
||||
This represents the amount of light the light meter |
||||
recorded. This is the most important piece of data |
||||
you will post in this data-object. |
||||
token: |
||||
type: string |
||||
example: it-is-not-password-if-you-are-wondering |
||||
description: >- |
||||
This is basically a token to check the info. sent to |
||||
the server is from a valid machine. |
||||
responses: |
||||
201: |
||||
description: >- |
||||
The reading was successfully added to the database. |
||||
400: |
||||
description: >- |
||||
The data sent to the sever was invalid or incorrectly |
||||
formatted. The most likely reasons are invalid light-meter |
||||
Id. specified and incorrect datetime format used. |
||||
|
||||
/readings/latest/{light_meter}: |
||||
get: |
||||
operationId: api.get_latest |
||||
tags: |
||||
- Request Light-Meter Readings |
||||
summary: >- |
||||
Returns the latest reading from the specified light meter. |
||||
description: >- |
||||
Use this U.R.L. to retrieve the latest reading from the |
||||
light meter you specified (in the U.R.L.). At the time of |
||||
writing, the project has only three light meters and are |
||||
labelled 1-3. |
||||
parameters: |
||||
- name: light_meter |
||||
in: path |
||||
description: >- |
||||
This is the Id. of the light meter which you are retrieving |
||||
the reading for. The Id. consists of a number between 1-3 |
||||
at the time of writing. |
||||
type: integer |
||||
required: True |
||||
responses: |
||||
200: |
||||
description: >- |
||||
If the server can successfully retrieve the latest reading |
||||
for the specified light meter, you should receive a JSON |
||||
object like the one below. It should include the Id. of |
||||
the light meter it was taken with, the time the reading |
||||
was taken and the reading itself. |
||||
schema: |
||||
type: object |
||||
properties: |
||||
id: |
||||
type: integer |
||||
example: 2 |
||||
description: >- |
||||
This is the Id. of the light meter which took the |
||||
reading. It should be between 1-3 at the time of |
||||
writing. |
||||
time: |
||||
type: string |
||||
example: 2019-10-19 17:04:57 |
||||
description: >- |
||||
The time and date the reading was taken. The A.P.I. |
||||
has standardised on the U.T.C. format. |
||||
reading: |
||||
type: integer |
||||
example: 34 |
||||
description: >- |
||||
This is the actual reading taken from the specified |
||||
light meter, at the time specified in this response |
||||
body (I.E. JSON object). |
||||
400: |
||||
description: >- |
||||
The light-meter Id. specified in invalid. |
||||
|
||||
/readings/all/{light_meter}: |
||||
get: |
||||
operationId: api.get_all_readings |
||||
tags: |
||||
- Request Light-Meter Readings |
||||
summary: >- |
||||
Returns every reading taken by the specified light meter. |
||||
description: >- |
||||
Use this U.R.L. to retrieve all the reading from the |
||||
light meter you specified (in the U.R.L.). At the time of |
||||
writing, the project has only three light meters and are |
||||
labelled 1-3. |
||||
parameters: |
||||
- name: light_meter |
||||
in: path |
||||
description: >- |
||||
This is the Id. of the light meter which you are retrieving |
||||
the readings for. The Id. consists of a number between 1-3 |
||||
at the time of writing. |
||||
type: integer |
||||
required: True |
||||
responses: |
||||
200: |
||||
description: >- |
||||
If the server can successfully retrieve all the readings |
||||
for the specified light meter, you should receive an array |
||||
of JSON objects like the one below. It should include the |
||||
database Id. of the reading, the time the reading was |
||||
taken and the reading itself. |
||||
schema: |
||||
type: object |
||||
properties: |
||||
id: |
||||
type: integer |
||||
example: 2 |
||||
description: >- |
||||
This is the database Id. of the reading. |
||||
time: |
||||
type: string |
||||
example: 2019-10-19 17:04:57 |
||||
description: >- |
||||
This is the time and date the reading was taken. |
||||
The A.P.I. has standardised on the U.T.C. format. |
||||
reading: |
||||
type: integer |
||||
example: 34 |
||||
description: >- |
||||
This is the actual reading taken from the specified |
||||
light meter, at the time specified in this response |
||||
body (I.E. JSON object). |
||||
400: |
||||
description: >- |
||||
The light-meter Id. specified in invalid. |
||||
|
||||
/readings/all: |
||||
get: |
||||
operationId: api.get_all_readings_for_every_meter |
||||
tags: |
||||
- Request Light-Meter Readings |
||||
summary: >- |
||||
Returns every reading taken by every light meter in the |
||||
project. |
||||
description: >- |
||||
Use this U.R.L. to retrieve all the readings from every light |
||||
meter in the project. There is no example of the data returned |
||||
because I can't seem to replicate it as a YAML schema which |
||||
is understood by Swagger. Because of this, it is registered as |
||||
a free-form object. To see what the data looks like when it is |
||||
returned, I recommend you use the "Try it out!" button to see a |
||||
working example. |
||||
responses: |
||||
200: |
||||
description: >- |
||||
All the readings were successfully retrieved from the |
||||
database and delivered. |
||||
schema: |
||||
type: object |
||||
additionalProperties: True |
||||
|
||||
# Device A.P.I. Calls |
||||
# ==================================================================== |
||||
/status/update/{device}: |
||||
post: |
||||
operationId: api.post_a_status_change |
||||
tags: |
||||
- Log Device Status Change |
||||
summary: >- |
||||
Logs a change in the status of the specified device. |
||||
description: >- |
||||
This is mostly to check if the devices included in this project |
||||
are turned on, off or an error has occured and they are |
||||
unreachable/crashed. |
||||
parameters: |
||||
- name: device |
||||
in: path |
||||
description: >- |
||||
The Id. of the device with the change in status. 1, 2 and 3 |
||||
refer to the light-meters in Ritherdon and 4, 5 and 6 |
||||
refer to the relays in the gallery. The pairing of each |
||||
meter and relay is as follows: 1->4, 2->5 and 3->6. |
||||
type: integer |
||||
required: True |
||||
- name: the_status_change |
||||
in: body |
||||
description: >- |
||||
The status change and the time the change occurred. |
||||
required: True |
||||
schema: |
||||
type: object |
||||
properties: |
||||
time: |
||||
type: string |
||||
format: date-time |
||||
example: 2019-10-19 17:04:57 |
||||
description: >- |
||||
The date and time the change in status occurred. Make |
||||
sure to use the U.T.C. time format. This is because |
||||
the A.P.I. has made a design decision to standardise |
||||
on it. |
||||
status: |
||||
type: string |
||||
example: "on" |
||||
description: >- |
||||
The current status of the device you would like to log. |
||||
The two status types are "on" and "off". |
||||
token: |
||||
type: string |
||||
example: it-is-not-password-if-you-are-wondering |
||||
description: >- |
||||
This is basically a token to check the info. sent to |
||||
the server is from a valid machine. |
||||
responses: |
||||
201: |
||||
description: >- |
||||
The status update was successfully added to the database. |
||||
400: |
||||
description: >- |
||||
The data sent to the sever was invalid or incorrectly |
||||
formatted. The most likely reasons are invalid device Id. |
||||
specified and incorrect datetime format used. |
||||
|
||||
/status/latest/{device}: |
||||
get: |
||||
operationId: api.get_latest_device_status |
||||
tags: |
||||
- Request Device Status |
||||
summary: >- |
||||
Returns the current status of the specified device. |
||||
description: >- |
||||
Use this U.R.L. to retrieve the current status of the device |
||||
you specified (in the U.R.L.). At the time of writing, the |
||||
project has six devices in total which are split equally |
||||
between Ritherdon and the gallery. Devices 1 to 3 (light-meters) |
||||
refer to the devices in Ritherdon and 4 to 6 (relays) are in |
||||
the gallery. Each light-meter and relay should pair up in the |
||||
following ways: 1->4, 2->5 and 3->6. |
||||
parameters: |
||||
- name: device |
||||
in: path |
||||
description: >- |
||||
This is the Id. of the device which you are retrieving the |
||||
current status for. The Id. should consist of a number |
||||
between 1 and 6, at the time of writing. |
||||
type: integer |
||||
required: True |
||||
responses: |
||||
200: |
||||
description: >- |
||||
If the server can successfully retrieve the current status |
||||
for the specified device, you should receive a JSON object |
||||
like the one below. It should include the Id. of the |
||||
device, the current status and the time it was logged. |
||||
schema: |
||||
type: object |
||||
properties: |
||||
id: |
||||
type: integer |
||||
example: 2 |
||||
description: >- |
||||
The is the Id. of the device. |
||||
time: |
||||
type: string |
||||
example: 2019-10-19 17:04:57 |
||||
description: >- |
||||
The time the status change was logged in the |
||||
database. The A.P.I. has standardised on the |
||||
U.T.C. format. |
||||
status: |
||||
type: string |
||||
example: on |
||||
description: The current status of the device. |
||||
400: |
||||
description: >- |
||||
The device Id. specified in invalid. |
||||
|
||||
/status/all/{device}: |
||||
get: |
||||
operationId: api.get_all_status_log |
||||
tags: |
||||
- Request Device Status |
||||
summary: >- |
||||
Returns every status change logged by the specified device. |
||||
description: >- |
||||
Use this U.R.L. to retrieve every change in the specified |
||||
devices state. At the time of writing, the project has six |
||||
devices and are labelled 1 to 6. Devices (light-meters) 1 to 3 |
||||
are located in the Ritherdon factory and 4 to 6 (relays) in the |
||||
gallery. The light-meters and relays are paired like so, 1->4, |
||||
2->5 and 3->6. |
||||
parameters: |
||||
- name: device |
||||
in: path |
||||
description: >- |
||||
The Id. of the device you are retrieving the status change |
||||
log for. The Id. should be a number between 1 and 6. |
||||
type: integer |
||||
required: True |
||||
responses: |
||||