jaume-nualart
90f0410c60
|
2 months ago | |
---|---|---|
.. | ||
Boards/Charlie | 2 months ago | |
README.md | 6 months ago | |
import.py | 6 months ago | |
main.py | 6 months ago | |
output_import.txt | 2 months ago |
README.md
Data: https://lnu.box.com/s/5whjdw6f5mft0h62676h30g24kx6xagg
Instructions
All the lines below should be run inside the 'py' subdirectory.
- Run 'python import.py' to create the database.
- Run 'python -m flask --app main run' to start the API server.
By default the API will be available at http://localhost:5000.
Notes on the sensors
- Every sensor is (physically) in a "bridge". A bridge can have up to 12 sensors.
- The bridge is connected to the card via inputs. The inputs are named S1, S2, .. V1, etc.
- For example: a column named V1:5 contains the values measured by the 5th sensor of whatever bridge was connected to the input V1 at that point in time.
- The only way to identify the bridge is to read a hex value that it sends in its last sensor (12th) immediately after a reset.
- A reset can be identified by the fact that the headers show up again in the middle of a file.
- However, not every time the headers show up it is a reset... the headers can be manually forced to show for whatever reason.
- So, a reset is when the headers show up AND the 12th sensor gives a hex value, then starts to count uptime from 0.
- A "family" is a logical organization of sensors that may or may not have anything to do with a bridge.
- We can assume families and bridges are unrelated, for all practical reasons.
Database input format
- Each house in its own subfolder of 'Data'. The name of the subfolder will be used as the ID of the house.
- Inside the subfolder, the .TXT files with the sensor data should be name as "CARD-YEAR-MONTH.TXT"
- For example: 1-2022-10.TXT for October 2022, card 1.
- It does not matter if the TXT files are organized into subfolders. The import script will find them.
API Endpoints
All endpoints have two mandatory parameters:
- hus
Parallel
/parallel/daily
Returns data formatted for the 'daily' parallel coordinates view.
URL parameters:
- 'day' [Mandatory]: in the format YYYY-MM-DD.
- 'family' [Optional; default: 'S1']: name of family of sensors.
- 'type' [Optional; default: 'celsius']: type of sensor.
/parallel/weekly
Returns data formatted for the 'weekly' parallel coordinates view.
- 'week' [Optional; default: 1]: week number, 1-52.
- 'year' [Optional; default: 2023]: year.
- 'family' [Optional; default: 'S1']: name of family of sensors.
- 'type' [Optional; default: 'celsius']: type of sensor.
- 'hour' [Optional; default: 00]: hour of the day.
/parallel/monthly
Returns data formatted for the 'monthly' parallel coordinates view.
- 'month' [Optional; default: 1]: month number, 1-12.
- 'year' [Optional; default: 2023]: year.
- 'family' [Optional; default: 'S1']: name of family of sensors.
- 'type' [Optional; default: 'celsius']: type of sensor.
- 'hour' [Optional; default: 00]: hour of the day.
- 'weekday' [Optional; default: 1]: weekday, 1 (sun) to 7 (sat)
/parallel/yearly
Returns data formatted for the 'yearly' parallel coordinates view.
- 'year' [Optional; default: 2023]: year.
- 'family' [Optional; default: 'S1']: name of family of sensors.
- 'type' [Optional; default: 'celsius']: type of sensor.
- 'hour' [Optional; default: 00]: hour of the day.
- 'day' [Optional; default: 1]: day of the month (1 to 28)
Grid
/grid/weekly
Returns data formatted for the 'weekly' grid view.
- 'week' [Optional; default: 1]: week number, 1-52.
- 'year' [Optional; default: 2023]: year.
- 'sensor' [Optional; default: 'S1:1']: name of the sensor.
- 'type' [Optional; default: 'celsius']: type of sensor.
/grid/monthly
Returns data formatted for the 'monthly' grid view.
- 'month' [Optional; default: 1]: month number, 1-12.
- 'year' [Optional; default: 2023]: year.
- 'sensor' [Optional; default: 'S1:1']: name of the sensor.
- 'type' [Optional; default: 'celsius']: type of sensor.
/grid/yearly
Returns data formatted for the 'yearly' grid view.
- 'year' [Optional; default: 2023]: year.
- 'sensor' [Optional; default: 'S1:1']: name of the sensor.
- 'type' [Optional; default: 'celsius']: type of sensor.
Horizon
/horizon/daily
Returns data formatted for the 'daily' horizon view.
- 'day' [Optional; default: '2023-01-01']: in the format YYYY-MM-DD.
- 'family' [Optional; default: 'S1']: name of family of sensors.
- 'type' [Optional; default: 'celsius']: type of sensor.
/horizon/weekly
Returns data formatted for the 'weekly' horizon view.
- 'week' [Optional; default: 1]: week number, 1-52.
- 'year' [Optional; default: 2023]: year.
- 'family' [Optional; default: 'S1']: name of family of sensors.
- 'type' [Optional; default: 'celsius']: type of sensor.
/horizon/monthly
Returns data formatted for the 'monthly' horizon view.
- 'month' [Optional; default: 1]: month number, 1-12.
- 'year' [Optional; default: 2023]: year.
- 'family' [Optional; default: 'S1']: name of family of sensors.
- 'type' [Optional; default: 'celsius']: type of sensor.
/horizon/yearly
Returns data formatted for the 'yearly' horizon view.
- 'year' [Optional; default: 2023]: year.
- 'family' [Optional; default: 'S1']: name of family of sensors.
- 'type' [Optional; default: 'celsius']: type of sensor.
NOTE: For 2023 the data goes only up to August (8 months).
Saved Flexiboards
/boards
A short summary of all the boards that are saved.
- 'hus' [Mandatory]: the house for which you want the boards listed.
[ { Filename [String], Name [String], Desc [String] } ]
/boards/save
Method: POST
IMPORTANT: You need to send the Header: 'Content-Type: application/json'
Every time we call save, it creates a new board.
- ID is auto generated. // name -> replace all non-alphanumeric characters with -
- Name must be unique, or else the board will be overwritten.
{ Name [String], Description [String], Hus [String], col-left: [ { order [int], id [String], text [String], api_url [int] }, { ... } ], col-center: [ ... ], // same as above col-right: [ ... ] // same as above }
/boards/load
Loads a saved board.
- filename [String]: To know the filename, check the list in "/boards".
The format is the same that was provided in "/boards/save" (above).
Todo
- Define the desired time for some of the plots instead of taking the first one available.
- Use the hour only as a filter; take the first available measurement on that hour.
- Instead of returning an actual measurement, return a modified value: min/max/avg.