Skip to main content

A pluggable system to receive and transmit bluetooth events from the Tilt Hydrometer

Project description

Tilty

Coverage Status PyPI version Docker Pulls

A python module and CLI to capture and emit events from your tilt hydrometer

I've been unhappy with the quality/inconsistency of what I've seen out there in terms of random scripts that capture. No tests, no pluggable emitters, hard to find, etc.

The tilt essentially broadcasts iBeacon packets to send out a uuid (which type of tilt it is), a major (the temp in F), and a minor (the specific gravity).

This will capture those whenever theyre transmitted and emit them to a backend of your choosing so that you can graph it over time asynchronously.

The Tilt supports writing to a google doc which you could use with something like IFTTT or Zapier, but this is much lighter and lets you decide how you want to push that out with a pluggable backend system.

Supported Emitters

  • stdout
  • Webhooks
    • Generic (Send to any endpoint with any type)
    • Brewstat.us (Example below)
    • BrewersFriend (Example below)
  • InfluxDB
  • Datadog (dogstatsd)
  • SQLite
  • Google Sheets (experimental/advanced)

Usage

Generate Config

$ cat <<EOF >config.ini
[general]
sleep_interval = 2 # defaults to 1
logging_level = DEBUG # defaults to INFO

# stdout example
[stdout]

[google]
# This is advanced. TODO: write up how to provide an access/refresh token
refresh_token = 11111111111111111111111111
client_id = 111111-1111.apps.googleusercontent.com
client_secret = 1111111111111111
spreadsheet_id = 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms

# SQLite example
[sqlite]
file = /etc/tilty/tilt.sqlite

# Generic application/json example
[webhook]
url = http://www.foo.com
headers = {"Content-Type": "application/json"}
payload_template = {"color": "{{ color }}", "gravity": {{ gravity }}, "mac": {{ mac }}, "temp": {{ temp }}, "timestamp": "{{ timestamp }}"}
method = POST

# Brewstat.us example
[webhook]
url = https://www.brewstat.us/tilt/0yjRbGd2/log
headers = {"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"}
payload_template = {"Color": "{{ color }}", "SG": {{ gravity }}, "Temp": {{ temp }}, "Timepoint": "{{ timestamp }}"}
method = POST

# Brewers Friend example
[webhook]
url = https://log.brewersfriend.com/stream/3009ec67c6d81276185c90824951bd32bg
headers = {"Content-Type": "application/json"}
payload_template = {"device_source": "Tilt","temp": {{ temp }}, "name": "{{ color }} ","temp_unit": "F","gravity": {{ gravity }},"gravity_unit": "G"}
method = POST

[influxdb]
url = influxdb.corp.com
port = 80
database = tilty
gravity_payload_template = {"measurement": "gravity", "tags": {"color": "{{ color }}", "mac": "{{ mac }}"}, "fields": {"value": {{ gravity }}}}
temperature_payload_template = {"measurement": "temperature", "tags": {"color": "{{ color }}", "mac": "{{ mac }}"}, "fields": {"value": {{ temp }}}}
# `% curl  -s -G 'http://influxdb.service.consul:8086/query?pretty=true' --data-urlencode "db=tilty" --data-urlencode 'q=SELECT "value", "mac", "color" FROM "autogen"."gravity"' | jq '.results[].series[].values[0]'`

[datadog]
# Note: make sure that the dd agent has DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
host = statsdhost.corp.com
port = 8125
EOF

Run

$ tilty
$ # Or from docker ( generate config into $cwd/config/config.ini )
$ docker run -it \
  -v $(pwd)/config:/etc/tilty \
  --net=host \
  myoung34/tilty:latest \
  -r --config-file /etc/tilty/config.ini

Installation

$ git clone https://github.com/myoung34/tilty
$ pip install -e .

Development

$ docker run -it -v $(pwd):/src -w /src --entrypoint /bin/sh python:3.7-alpine
$ apk add -U openssl-dev alpine-sdk libffi-dev python3-dev py3-bluez bluez-dev
$ pip3 install poetry
$ poetry install
$ poetry run tox

Functional Development

To test locally (and without using my tilty): I use iBeacon on android and set:

  • UUID to one of the ones listed in here
  • Major to a temperature in F
  • Minor to an SG*1000

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Tilty-0.6.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Tilty-0.6.2-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file Tilty-0.6.2.tar.gz.

File metadata

  • Download URL: Tilty-0.6.2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for Tilty-0.6.2.tar.gz
Algorithm Hash digest
SHA256 4661d473ccad3adeb3172baf7f67d65d71d30965daa14ca26272407de3534740
MD5 a86b5ff5516683de8536a54a085d658a
BLAKE2b-256 a76b075a8aee738a429a472d83a11402c9acb6bac90ddc9211bc84b35262fd8a

See more details on using hashes here.

File details

Details for the file Tilty-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: Tilty-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for Tilty-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 23827135e23f4bafc984398bfb55d4a1901043c116cd2fc1fa81a8502b717007
MD5 f24017927113258b7230602669016128
BLAKE2b-256 d40164f54a4e8ec94916607097b692fa8c3f951636369ae0e720189815827051

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page