Coder Social home page Coder Social logo

tilt2mqtt's Introduction

Tilt2MQTT - Stream the Tilt Hydrometer to MQTT

Table of Contents
  1. Inroduction
  2. How to run
  3. Running as a service
  4. Integrate with Home Assistant
  5. Integrate with Brewers Friend

Note: This package requires a MQTT server. To get one read here.

Wrapper for reading messages from Tilt wireless hydrometer and forwarding them to MQTT topics.

The device acts as a simple Bluetooth IBeacon sending the following two values,

  • major: Temperature in Farenheit
  • minor: Specific gravity

The raw values read from the Tilt are uncalibrated and should be calibrated before use. The script works a follows,

  1. Listen for local IBeacon devices
  2. If found the callback is triggered
  • Translate the UUID to a Tilt color
  • Extract and convert measurements from the device
  • Construct a JSON payload
  • Send payload to the MQTT server
  1. Stop listening and sleep for X minutes before getting a new measurement

This script has been tested on Linux. By default the script will create a log file in the path /tmp/tilt.log.

If you are on Linux first install the bluetooth packages,

sudo apt-get install libbluetooth-dev

Then install Python dependencies

pip install beacontools paho-mqtt requests pybluez

Run the script,

python tilt2mqtt.py

Note: If you get a permission error try running the script as root.

The code should now listen for your Tilt device and report values on the MQTT topic that matches your Tilt color.

You can use the mosquitto commandline tool (on Linux) to listen for colors or the build-in MQTT client in Home Assistant,

mosquitto_sub -t 'tilt/#'

To listen for measurements only from Orange devices run,

mosquitto_sub -t 'tilt/Orange/#'

If your MQTT server is not running on the localhost you can set the following environmental variables,

Varable name Default value
MQTT_IP 127.0.0.1
MQTT_PORT 1883
MQTT_AUTH NONE
MQTT_DEBUG TRUE

If you would like to run tilt2MQTT as a service on Linux using systemd add this file to a systemd path (Normally /lib/systemd/system/tilt2mqtt.service or /etc/systemd/system/tilt2mqtt.service)

# On debian Linux add this file to /lib/systemd/system/tilt2mqtt.service

[Unit]
Description=Tilt Hydrometer Service
After=multi-user.target
[email protected]

[Service]
Type=simple
ExecStart=/usr/bin/python3 <PATH TO YOUR FILE>/tilt2mqtt.py
StandardInput=tty-force

[Install]
WantedBy=multi-user.target

Remember to change the PATH variable in the script above. Then update your service,

sudo systemctl reload-daemon

Using the MQTT sensor in home assistant you can now listen for new values and create automations rules based on the values (e.g. start a heater if the temperature is too low).

  - platform: mqtt
    name: "Tilt Orange - Temperature"
    state_topic: "tilt/Orange"
    value_template: "{{ value_json.temperature_celsius_uncali | float + 0.5 | float | round(2) }}"
    unit_of_measurement: "\u2103"

  - platform: mqtt
    name: "Tilt Orange - Gravity"
    state_topic: "tilt/Orange"
    value_template: "{{ value_json.specific_gravity_uncali | float + 0.002 | float | round(3) }}"

Notice that here the calibration value is added directly to the value template in home assistant. The calibration parameters are estimated following the Tilt guide.

Home Assistant - Brewing

Using the following gist it is possible to stream the calibrated values from home assistant to the brewers friend API via a simple Python script. After this you can add the tilt2mqtt.service to

Brewers Friend fermentation overview

tilt2mqtt's People

Contributors

linuxchristian avatar michaelwoods avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.