Command line ruuvitag (ruu.vi) reader that returns predefined measurement value from specified ruuvitag. Integrates into homeassistant (hass.io).
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
ruuvi-hass.py

README.md

ruuvi-hass

Command line ruuvitag (ruu.vi) reader that returns predefined measurement value from specified ruuvitag. Integrates into homeassistant (hass.io). Requires ruuvi-sensor https://github.com/ttu/ruuvitag-sensor Requires sudo permissions for homeassistant user (due to ruuvitag-sensor, using bluez, ...

Disclaimer: YMMV. Written to Raspberry Pi 3 model B that has homeassistant installed according to instructions found at: https://www.home-assistant.io/docs/installation/raspberry-pi/

Username: homeassistant, path to python file: /home/homeassistant/
Homeassistant environment: /srv/homeassistant/
Homeassistant configs: /home/homeassistant/.homeassistant/

How I did this

  1. Install Python3.6, see https://gist.github.com/dschep/24aa61672a2092246eaca2824400d37f

  2. Install hass (use python 3.6!)

2.1 Make sure it works like it is supposed to

  1. Install ruuvi-sensor (use python 3.6!)
pip3.6 install ruuvitag_sensor
  1. Add permissions to homeassistant user with "sudo visudo":
homeassistant   ALL = (ALL) NOPASSWD: /bin/hciconfig, /usr/bin/hcitool, /usr/bin/hciattach, /usr/bin/hcidump, /usr/bin/hcitool, /bin/kill
  1. Edit /home/homeassistant/.homeassistant/configuration.yaml

Major improvement: define all beacon macs, get dump of all data as single sensor which is split into multiple different values within homeassistant.


sensor:
  -  platform: command_line
     name: ruuvitags
     command: "/home/homeassistant/ruuvi-hass/ruuvi-hass.py batch AA:AA:BB:BB:CC:CC CC:CC:BB:BB:AA:AA"



  -  platform: template
     sensors:
       temperature:
         value_template: "{% set list = states.sensor.ruuvitags.state.split(':') %} {{ list[0] }}"
         friendly_name: "Outside temp"
         unit_of_measurement: "°C"
       humidity:
         value_template: "{% set list = states.sensor.ruuvitags.state.split(':') %} {{ list[1] }}"
         friendly_name: "Outside humidity"
         unit_of_measurement: "%"
       pressure:
         value_template: "{% set list = states.sensor.ruuvitags.state.split(':') %} {{ list[2] }}"
         friendly_name: "Outside pressure"
         unit_of_measurement: "hPa"
       temperature2:
         value_template: "{% set list = states.sensor.ruuvitags.state.split(':') %} {{ list[3] }}"
         friendly_name: "Inside temp"
         unit_of_measurement: "°C"
       humidity2:
         value_template: "{% set list = states.sensor.ruuvitags.state.split(':') %} {{ list[4] }}"
         friendly_name: "Inside humidity"
         unit_of_measurement: "%"
       pressure2:
         value_template: "{% set list = states.sensor.ruuvitags.state.split(':') %} {{ list[5] }}"
         friendly_name: "Inside pressure"
         unit_of_measurement: "hPa"

  1. Restart homeassistant

  2. Fingers crossed that it works

You can also run the script from command line. ruuvi-hass.py MA:CA:DD:RE:SS [optional: temp/humid/press] If you specify value to be read, you get it. If you do not, you'll get all of them separated with : temp:humid:press