master |
develop |
---|---|
This is a very simple gateway service to a collection of HT sensors. The server offers a simple REST API to the sensors. The responses follow the the suggestions of the {json:api} specification.
The service is regularly reading the sensors. The time interval is defined by the server.sensorReadTime
configuration item. When reading a sensor through this service, the service returns the last reading of the sensor or a 504
if the last reading is too old or if the sensor is unreachable.
The API of the server is defined by the api/server.yml
Swagger specification. There are basically two endpoints:
GET /sensors
: provides the list of sensors that the gateway is aware of.GET /sernsors/{sensor-id}
: provides the latest reading of the sensor identified by the given id. It returns a504
error if the reading is older than the defined period inserver.sensorTimeout
configuration, or if the sensor has been unreachablethe.GET /sernsors/{sensor-id}/raw
: provides the latest reading of the sensor identified by the given id in a very simple JSON with only two fields (temperature
andhumidity
). This is useful in connection with other services, such as Homebridge HTTP Temp/Humidity plugin.
The configs/config-template.yml
offers a template for the service configuration.
Make sure you that
- you have
dep
installed. Visit https://github.com/golang/dep - your
GOPATH
andGOROOT
environments are set properly.
There is a Makefile
provided that offers a number of targets for preparing, building and running the service. To build and run the service against the configs/test.yml
configuration, simply call the run
target:
make clean dep run
I currently have a very basic systemd unit file defined under init/jupiter.service
. This can be later improved.
Before using the service definition, make sure that you go through the file and update the WorkingDirectory
and ExecStart
to match your installation.
The sensors are expected to expose their readings as a JSON response to a simple HTTP GET endpoint defined by the api/client.yml
Swagger specficitiaon.
The home-IoT/esp-dht22-mock projects offers a mock sensor service. You can run a number of instances on your local network and test/play with the Jupiter service against the mock sensors.
To run the server with the configuration provided in config/test.yml, run one mock sensor on port 8081
of your machine:
dht22-mock --port 8081
The code is published under an MIT license.
Please report issues or feature requests using Github issues. Code contributions can be done using pull requests.