Package: brewblox-ispindel
BrewBlox Service for the iSpindel HydrometerTheiSpindelis a DIY wireless hydrometer and thermometer used to gather live readings of specific gravity and temperature when brewing beer.BrewBloxis a modular brewery control system design to work with the BrewPi controller.This brewblox service integrates the iSpindel hydrometer into BrewBlox.How does it work?The iSpindel is configured to send metrics using HTTP.When the iSpindel wake up (like every minute) it submits an HTTP POST request to the iSpindel BrewBlox service.The metrics are then published to the event-bus, the BrewBlox history service persists the metrics into the InfluxDB database.A Graph widget can be added in the BrewBlox UI to display the persisted metrics.UsageDeploy the iSpindel service in the BrewBlox stackYou need to add the service to your existing BrewBlox docker compose file:ispindel:image:bdelbosc/brewblox-ispindel:rpi-developrestart:unless-stoppeddepends_on:-historyports:-"5080:5000"labels:-"traefik.port=5000"-"traefik.frontend.rule=PathPrefix:/ispindel"Thebrewblox-ispindeldocker images are available onDocker Hub.The image tag to use is:rpi-developfor thearmarchitecture (when deploying on a RaspberryPi)developfor theamdarchitectureNote that the service expose anHTTPendpoint on port5080this is required because the iSpindel does not handleHTTPS.Start your BrewBlox stack usingbrewblox-ctl up.Check that the service is running:# Run the docker-compose command from the directory holding the brewblox docker-compose file$docker-composepsispindelNameCommandStatePorts
-----------------------------------------------------------------------------------
brewblox_ispindel_1python3-mbrewblox_ispindelUp0.0.0.0:5080->5000/tcp

$docker-composelogsispindel
...
ispindel_1|========Runningonhttp://0.0.0.0:5000========...Configure the iSpindelFirst find theIPaddress of your BrewBlox server then check that:http://IP:5080/ispindel/_service/statusreplies with a:{"status":"ok"}Note that the port must be set according to what is exposed in thedocker-compose.ymlfile (5080is our case).Then:Switch the iSpindel onPress the reset button 3-4 times which sets up an access pointConnect to the Wifi network "iSpindel"Open a browser onhttp://192.168.4.1From the "Configuration" menu, configure the Wifi access, thenService Type:HTTPToken:Server Address:<IP>Server Port:5080Server URL:/ispindel/ispindelDouble check that your are using anHTTPservice type (and not a TCP).Add a Graph to your dashboardFrom your dashboardACTIONS > New Widgetthen select and create aGraphwidget.Once the iSpindel has sent some data, you should see its metrics when configuring the widget:DevelopmentGet startedTo get started:# Add repository containing Python 3.8sudoadd-apt-repositoryppa:deadsnakes/ppa

sudoaptinstall-ypython3-pippython3.8python3.8-dev
pip3install--userpipenv# in the brewblox-ispindel directorypipenv--python3.8
pipenvsync-dRun testspipenvrunpytestBuild a docker imageInstall thebrewblox-toolsGo into the brewblox-ispindel directory and build therpi-latestimagebrewblox-devlocalbuild-rbdelbosc/brewblox-ispindel--tagslatest-aarmUse-a amdto build thelatestimage for amd architecture.Simulate iSpindel requestFrom the BrewBlox host:curl-XPOSThttp://localhost:5080/ispindel/ispindel-d'{"name":"iSpindel000","ID":4974097,"angle":83.49442,"temperature":21.4375,"temp_units":"C","battery":4.035453,"gravity":30.29128,"interval":60,"RSSI":-76}'# or using httpscurl--insecure-XPOSThttps://localhost/ispindel/ispindel-d'{"name":"iSpindel000","ID":4974097,"angle":83.49442,"temperature":21.4375,"temp_units":"C","battery":4.035453,"gravity":30.29128,"interval":60,"RSSI":-76}'Check iSpindel service logsEach time the service receive a request there is a log showing the temperature and gravity.
To run from the directory containing thedocker-compose.ymlfile.docker-composelogsispindel
...
ispindel_1|2019/04/1214:18:34INFO__main__iSpindeliSpindel000,temp:21.75,gravity:22.63023
ispindel_1|2019/04/1214:19:05INFO__main__iSpindeliSpindel000,temp:21.6875,gravity:22.69526View iSpindel metrics persisted in the influxdb databaseTo run from the directory containing thedocker-compose.ymlfile.docker-composeexecinfluxinflux>USEbrewblox>SHOWSERIESkey---iSpindel000-- This is the name given to the iSpindelsparkeyspock>SELECT*FROM"iSpindel000"name:iSpindel000timeanglebatterygravityrssitemperature----                -----    -------  -------   ---- -----------154612149162625700083.494424.03545330.29128-7621.4375154612153086193900084.416654.03545330.75696-7519.125>-- Latest metrics>PRECISIONrfc3339>SELECT*FROM"iSpindel000"WHEREtime>now()-5mORDERBYtimeDESCLIMIT10timeCombinedInfluxpointsanglebatterygravityrssitemperature----                        ----------------------- -----    -------  -------  ---- -----------2019-04-12T14:15:29.715678Z171.69474.23357722.67045-6821.93752019-04-12T14:14:58.997279Z171.584474.23357722.51496-6721.9375Continuous integration pipelineUsingAzure, thepipelineautomatically test and deploy all commits
pushed on the GitHub repository.This means that docker images forarmandamdare published onDocker Huband the python package is deployed onPyPi.TODODebug mode where the service subscribes to thebrewcastchannel to debug what is published.Support an HTTP token that can be set in the docker-compose file.LimitationsThere is no security on the iSpindel endpoint