REST API
Requirements
General requirements
The API shall communicate with mobile apps and dynamic webpage.
For each request, the API shall validate the credentials (user, password).
The API shall provide the data in JSON format.
Timestamps shall have the format: YYYY-MM-DD hh:mm:ss
Placeholders in subsequent SQL queries are described in brackets: [placeholder]
Requirements for overview feature
The API shall provide an endpoint for informing the client about the validity of the credentials.
The API shall provide an endpoint communicating from the server to the client a set of floating point data read from a set of files:
| Signal name | Signal format | Signal source |
|---|---|---|
| timestamp | string | /var/local/aquarium-ctrl/aquarium-ctrl-ts |
| water temperature | floating point number | /var/local/aquarium-ctrl/atlsscntfc-temp |
| filtered water temperature | floating point number | /var/local/aquarium-ctrl/atlsscntfc-tempfltrd |
| pH value | floating point number | /var/local/aquarium-ctrl/atlsscntfc-ph |
| filtered pH value | floating point number | /var/local/aquarium-ctrl/atlsscntfc-phfltrd |
| conductivity | floating point number | /var/local/aquarium-ctrl/atlsscntfc-conduc |
| filtered water temperature | floating point number | /var/local/aquarium-ctrl/atlsscntfc-conducfltrd |
| tank level switch position | floating point number | /var/local/aquarium-ctrl/tnklvlsswtch |
| surface ventilation status | string | /var/local/aquarium-ctrl/srfcvntltn |
| ambient temperature | floating point number | /var/local/aquarium-ctrl/ambtemp |
| ambient humidity | floating point number | /var/local/aquarium-ctrl/ambhum |
| heating status | string | /var/local/aquarium-ctrl/htng |
Requirements for Balling feature
Balling dosing log
The API shall provide an endpoint communicating from the server to the client the Balling dosing events read from the table ballingdosinglog of either the last 24 hours or the last 7 days depending on parameter provided by the client.
The corresponding SQL query (for a period of one day) is:
SELECT ballingdosinglog.Timestamp, ballingdosinglog.pumpid, ballingdosinglog.dosingvolume, ballingsetvals.label FROM ballingdosinglog LEFT JOIN ballingsetvals ON ballingdosinglog.pumpid=ballingsetvals.pumpid WHERE Timestamp > (NOW() - INTERVAL 1 DAY) ORDER BY Timestamp
| Signal name | Signal format | Database column name |
|---|---|---|
| timestamp | string | ballingdosinglog.Timestamp |
| pump id | integer number | ballingdosinglog.pumpid |
| dosing volume | floating point number | ballingdosinglog.dosingvolume |
| label | string | ballingsetvals.label |
Balling set values
The API shall provide an endpoint communicating from the server to the client the Balling dosing set values read from the table ballingsetvals.
The corresponding SQL query is:
SELECT pumpid, dosingvolume, label FROM ballingsetvals;
| Signal name | Signal format | Database column name |
|---|---|---|
| pump id | integer number | ballingsetvals.pumpid |
| dosing volume | floating point number | ballingsetvals.dosingvolume |
| label | string | ballingsetvals.label |
The API shall provide an endpoint which allows the client to update the dosing volume of an existing dosing set value identified by the pump id. The corresponding SQL query is:
UPDATE ballingsetvals SET dosingvolume="[dosingvolume]" WHERE pumpid="[pumpid]";
Requirements for Feed feature
Feed profiles
A feed profile consists of general information (ID, name) and 10 groups of repetitive data where each group contains a pause section and a feed section.
The API shall provide an endpoint communicating from the server to the client the feed profiles read from the table feedprofiles.
| Signal name | Signal format | Database column name |
|---|---|---|
| profile id | integer number | feedprofiles.ProfileID |
| profile name | string | feedprofiles.ProfileName |
| pause 01 duration | integer | feedprofiles.Pause01Duration |
| pause 01 skimmer target state | boolean | feedprofiles.Pause01Skimmer |
| pause 01 main pump #1 target state | boolean | feedprofiles.Pause01MPmp1 |
| pause 01 main pump #2 target state | boolean | feedprofiles.Pause01MPmp2 |
| pause 01 aux. pump #1 target state | boolean | feedprofiles.Pause01APmp1 |
| pause 01 aux. pump #2 target state | boolean | feedprofiles.Pause01APmp2 |
| feed 01 duration | integer | feedprofiles.Feed01Duration |
| feed 01 skimmer target state | boolean | feedprofiles.Feed01Skimmer |
| feed 01 main pump #1 target state | boolean | feedprofiles.Feed01MPmp1 |
| feed 01 main pump #2 target state | boolean | feedprofiles.Feed01MPmp2 |
| feed 01 aux. pump #1 target state | boolean | feedprofiles.Feed01APmp1 |
| feed 01 aux. pump #2 target state | boolean | feedprofiles.Feed01APmp2 |
| ... | ... | ... |
| pause 10 duration | integer | feedprofiles.Pause10Duration |
| pause 10 skimmer target state | boolean | feedprofiles.Pause10Skimmer |
| pause 10 main pump #1 target state | boolean | feedprofiles.Pause10MPmp1 |
| pause 10 main pump #2 target state | boolean | feedprofiles.Pause10MPmp2 |
| pause 10 aux. pump #1 target state | boolean | feedprofiles.Pause10APmp1 |
| pause 10 aux. pump #2 target state | boolean | feedprofiles.Pause10APmp2 |
| feed 10 duration | integer | feedprofiles.Feed10Duration |
| feed 10 skimmer target state | boolean | feedprofiles.Feed10Skimmer |
| feed 10 main pump #1 target state | boolean | feedprofiles.Feed10MPmp1 |
| feed 10 main pump #2 target state | boolean | feedprofiles.Feed10MPmp2 |
| feed 10 aux. pump #1 target state | boolean | feedprofiles.Feed10APmp1 |
| feed 10 aux. pump #2 target state | boolean | feedprofiles.Feed10APmp2 |
The API shall provide an endpoint which allows the client to update an existing feed profile identified by the profile id.
The API shall provide an endpoint which allows the client to create a new profile.
The client shall only specify the name of the new profile.
If the feed profile already exists, the endpoint shall provide an error code and not overwrite any existing data in the database.
The related SQL query is:
INSERT INTO feedprofiles(ProfileName) VALUES("[profileName]");
The API shall provide an endpoint which allows the client to remove an existing profile.
The client shall only specify the ID of the feed profile.
The related SQL query is:
DELETE FROM feedprofiles WHERE ProfileID="[$profileName]";