Giter Site home page Giter Site logo

iskalchev / thermobeacon-pyhap Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 86 KB

HAP-python Bridge for Brifit/Oria bluetooth thermometer/hygrometer devices

License: MIT License

Python 100.00%
python raspberry-pi iot hap bluetooth-low-energy homekit thermobeacon ble brifit brifit-bluetooth-thermometer hygrometer oria hap-python

thermobeacon-pyhap's Introduction

ThermoBeacon-pyhap

HAP-python Bridge for Brifit bluetooth thermometer/hygrometer devices

Table of Contents

  1. Requirements
  2. Usage
  3. Tools
  4. Supported devices
  5. Useful Links

Requirements

$ sudo apt-get install libglib2.0-dev
$ sudo pip3 install bluepy

Note:

If you do not want to run your BT scripts as root (or under sudo), you may also give the required capabilities to the bluepy-helper binary, that comes with bluepy. More details...

$ sudo setcap 'cap_net_raw,cap_net_admin+eip' /usr/local/lib/python3.7/dist-packages/bluepy/bluepy-helper

2. Install HAP-python

$ pip3 install HAP-python

Usage

Here you can find more details on how to start your service.

Below is an example hap-python.py script:

import logging
import os, signal

from pyhap.accessory_driver import AccessoryDriver
from ThermoBeacon import ThermoBeaconBridge

logging.basicConfig(level=logging.INFO, format="[%(module)s] %(message)s")

service_dir = '~/.hap-python/'

# Start the accessory on port 51826
driver = AccessoryDriver(port=51826,
                         persist_file = service_dir + '.accessory.state',
                         pincode=b'123-12-123')

bridge = ThermoBeaconBridge(driver,
                            config_file = os.path.expanduser(service_dir + 'beacons.json'))

#Run a Bridge
driver.add_accessory(accessory=bridge)

# We want SIGTERM (terminate) to be handled by the driver itself,
# so that it can gracefully stop the accessory, server and advertising.
signal.signal(signal.SIGTERM, driver.signal_handler)

# Start it!
driver.start()

Config file

JSON encoded list of devices:

[
    {
        "mac": "fa:ac:00:00:11:33",
        "name": "garage",
    },
    {
        "mac": "fa:ac:00:00:11:55",
        "name": "living room",
    }
]

Tools

scan-tool.py

This tool scans for ThermoBeacon BLE devices and displays useful information about them (mac addrss, current temperature and hummidity, ...)

mybeacons.py

Command line interface to HAP-python service.

$ ./mybeacons.py -h
usage: mybeacons.py [-h] {list,add,remove,identify,config,discover} ...

positional arguments:
  {list,add,remove,identify,config,discover}
                        action
    list                List devices
    add                 Add device
    remove              Remove device
    identify            Identify a device
    config              Save configuration
    discover            Listen for device

optional arguments:
  -h, --help            show this help message and exit

Supported devices

Brifit Bluetooth thermometer and hygrometer, wireless

ORIA Wireless Thermometer Hygrometer

Useful Links

Python script to scan temperatures and humidity from a Thermobeacon

Raspberry pi forum thread

bluepy Python library

thermobeacon-pyhap's People

Contributors

iskalchev avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

pavolgaj

thermobeacon-pyhap's Issues

TBAdvertisingMessage is 0x15 on new devices

Hi!

Thanks for your excellent library which has been brilliant for my home heat-loss monitoring project; many thanks!

I've just added a few more ThermoBeacons to my project, and have discovered that they're issuing their data message using message id 0x15 instead of 0x10 or 0x11 as expected.

Happy to gather any evidence you need to support making changes to the library, although please note I'm a novice when it comes to python code development.

Many thanks,
David

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.