-
Notifications
You must be signed in to change notification settings - Fork 1
API Overview
The API is designed to be as RESTful as possible. The interfaces accept GET as well as POST requests to the endpoints.
curl http://host:5000/api/state/<name>
name has to be replaced with a name configured in config.yaml. Sensors return their current values converted to reasonable metric values. This means temperature is displayed in °C and humidity is displayed in %-rH.
curl http://host:5000/api/state[?FILTER=<regexp>&NAME_ONLY=<True/False>]
This returns all states. Param FILTER
accepts any valid regex expression and param NAME_ONLY
will flatten the array to just the names of the sensors.
This is quite useful for the UI to client side request available sensors.
curl \
-F "switch=<anyvalue>" \
http://host:5000/api/state/<name>
name has to be replaced with a name configured in config.yaml. anyvalue can be set to whatever you like.
curl \
-F "state=<newstate>" \
http://host:5000/api/state/<name>
name has to be replaced with a name configured in config.yaml. newstate can be set to change the sensor to the specified state.
For On
it accepts true
, yes
, on
, 1
(case insensitive) anything else is considered Off
.
name can not only be filled with one name from config.yaml. It is also possible to provide multiple names separated by comma.
i.e. requesting multiple sensor outputs:
curl http://host:5000/api/state/SENSOR_TEMP,SENSOR_HUMID
i.e. switching multiple hardware actors to On
state
curl \
-F "switch=1" \
http://host:5000/api/state/HEATING,UV
curl http://host:5000/api/data/<sensor>/<minutes>
As always sensor can be a comma separated list of sensors defined in config.yaml
I don't know (yet?) why this would be a good idea - but I wanted this endpoint to support post too.
curl \
-F "value=<value>" \
-F "timestamp=<epoch timestamp> \
http://host:5000/api/data/<sensor>
This could be useful if you have external sensors maybe built on esp8266 you could aggregate data on this endpoint. As it would make no sense at all to submit the same datapoint to multiple sensors at once - this sensor does not support a comma separated list of sensors.
This should yield a very responsive graph that can be embedded on almost any device at almost any resolution. The chart refreshes every 10 seconds.
The endpoint /api/graphs/<sensor>/<minutes>
returns HTML page with charts powered by chart.js.
The sensor parameter takes a comma separated list of sensors to be rendered within the chart.
This endpoint accepts HTTP GET parameters to set the color of the lines (defaults to random colors).
curl http://host:5000/api/graphs/<sensor>/<minutes>?<sensor_name>=<color>&<sensor_name_n>=<color>&refresh=<refresh_miliseconds>
sensor_name has to match one of the sensor requested in sensor. color can be either (HTML color names)[https://www.w3schools.com/colors/colors_names.asp] or rgb(0-255,0-255,0-255)
or rgba(0-255,0-255,0-255,0-1)
or hsl(0-100%,0-100%,0-100%)
or hex(#34ebae)
PiCure operates 230/120V main circuits. Do not attempt anything without proper training AND certification. Please make yourself familiar with local regulations and if required contact an electrician. This project can be a fire and safety hazard, may cause bodily harm, injuries and or death if improperly installed!
PROCEDE WITH THE UTMOST CAUTION
This does not alter the conditions of the projects license in any way, shape or form so please read them too.