# Get Readings from an Airthings Wave and publish to MQTT server
[Airthings](http://airthings.com) 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/
## API
```Python
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
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:
```python
c = sys.argv[1]
atw=airthingswave.AirthingsWave_mqtt(c)
count=len(atw.waves)
if count > 0:
iter=0
while iter<count:
handle = atw.ble_connect(atw.waves[iter]["addr"])
r = atw.get_readings(handle)
atw.ble_disconnect(handle)
atw.publish_readings(atw.waves[iter]["name"], r)
iter = iter+1
return True
```
[Airthings](http://airthings.com) 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/
## API
```Python
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
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:
```python
c = sys.argv[1]
atw=airthingswave.AirthingsWave_mqtt(c)
count=len(atw.waves)
if count > 0:
iter=0
while iter<count:
handle = atw.ble_connect(atw.waves[iter]["addr"])
r = atw.get_readings(handle)
atw.ble_disconnect(handle)
atw.publish_readings(atw.waves[iter]["name"], r)
iter = iter+1
return True
```
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file airthingswave-mqtt-0.2.tar.gz.
File metadata
- Download URL: airthingswave-mqtt-0.2.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/36.3.0 requests-toolbelt/0.8.0 tqdm/4.15.0 CPython/3.5.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eb984a3f282e61784ab52d483a1025abd6c442812b35d3dafcc6b9f6e4f6659
|
|
| MD5 |
59e800dc0746e9daab91362646a495cf
|
|
| BLAKE2b-256 |
932b450fede825f25fcccefcbb05f1fd3cb15b15a8393c743811d2182e26baaa
|