Code Monkey home page Code Monkey logo

airthingswave-mqtt's Introduction

Get Readings from an Airthings Wave and publish to MQTT server

Airthings makes a BTLE Radon detector called "Wave". This is an executable intended to be called periodically from Cron or some other scheduler to publish readings to an MQTT server.

Limitations

This application doesn't implement 'find' as provided in the example at https://airthings.com/raspberry-pi/

This is just a python API with a main loop that I happen to use in my own Home-Assistant setup. If you're looking for a plug and play solution, consider balena-airthingswave - @renemarc has created his appliance package using airthingswave-mqtt.

API

class AirthingsWave:
    def __init__(self, config_file):

Class instantiation requires a path to a config file in YAML format.

mqtt:
  broker: 192.168.30.18
  port: 1883
  username: 
  password: 

waves:
  - name: "basement-radon"
    addr: 98:07:2d:43:4d:ff

Before taking a reading, you should:

def ble_connect(self, addr):

Then you can:

def get_readings(self, p):
def publish_readings(self, name, readings):

Example

From _main_.py:

c = sys.argv[1]

atw = airthingswave.AirthingsWave_mqtt(c)

count = len(atw.waves)
if count > 0:
    i = 0
    while i < count:
        handle = atw.ble_connect(atw.waves[i]["addr"])
        r = atw.get_readings(handle)
        atw.ble_disconnect(handle)
        atw.publish_readings(atw.waves[i]["name"], r)
        i = i+1

return True

airthingswave-mqtt's People

Contributors

hpeyerl avatar renemarc avatar servis 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.