renemarc / home-assistant-config

🏠 Fully documented Home Assistant configuration for a smart-looking place. 😎 Be sure to ⭐️ my repo and copy ideas!
Apache License 2.0
342 stars 57 forks source link

Component: Airthings Wave integration #9

Open renemarc opened 6 years ago

renemarc commented 6 years ago

As a user, I want to access the output of an Airthings Wave radon detector so that I can get a overview of indoor radiation hazards.

Acceptance criteria

  1. It's done when Airthings Wave Bluetooth data can be read accurately within Home Assistant.
  2. It's done when alerts are set when Radon levels are too high.

References

hpeyerl commented 6 years ago

Probably not exactly what you want but my HA server is not within BTLE range of my Airthings Wave nor does it have bluetooth, so I'm running this on a Pi0w and publishing to HA's MQTT server:

https://github.com/hpeyerl/airthingswave-mqtt

  - platform: mqtt
    state_topic: basement-radon/Radon-Day
    name: "Radon Daily"
  - platform: mqtt
    state_topic: basement-radon/Radon-Long-Term
    name: "Radon Long Term"
  - platform: mqtt
    state_topic: basement-radon/Temperature
    name: "Basement Temperature"
  - platform: mqtt
    state_topic: basement-radon/Humidity
    name: "Basement Humidity"

How many story points do I get?

Cavemanz commented 6 years ago

hpeyerl: Can this be adapted to include the upcoming Wave Plus due this month? It adds CO2, VOC and Pressure. I might order one tomorrow.

hpeyerl commented 6 years ago

I don't know. I'm guessing probably but I don't have one nor have I ordered one.

On July 12, 2018 2:43:57 PM MDT, Cavemanz notifications@github.com wrote:

hpeyerl: Can this be adapted to include the upcoming Wave Plus due this month? It adds CO2, VOC and Pressure. I might order one tomorrow.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/renemarc/home-assistant-config/issues/9#issuecomment-404644532

Cavemanz commented 6 years ago

Ok, is the integration you made working as it should? How have you presented the data in Home Assistant?

hpeyerl commented 6 years ago

It publishes to MQTT.

On July 12, 2018 3:37:01 PM MDT, Cavemanz notifications@github.com wrote:

Ok, is the integration you made working as it should? How have you presented the data in Home Assistant?

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/renemarc/home-assistant-config/issues/9#issuecomment-404658628

renemarc commented 6 years ago

Ooh, I like! Very nice job, thanks for sharing, you definitely deserve a 🍺 at the retro! 😃

Indeed, having such a dedicated bridge that can be located closer to the AirThings Wave looks like a much better idea than trying to rely on a sometimes less ideally placed Home Assistant Pi host. And it's mode modular to boot. I am definitely trying out your code ...and updating my documentation to link to your repo. 👍

Cavemanz commented 6 years ago

I just put in an order for the Wave Plus which is supposed to ship 19th of July. Please report back on your experiences. According to Wave Plus specs it requires minimum BT 4.2. Only the Pi 3 B+ meets this, but Ill test with my regular 3B first..

hpeyerl commented 6 years ago

Airthings is not an open source friendly company. I asked for documentation so I could implement a python API and was told they don't have any documentation but pointed me at their two example scripts. I just wrapped a simple API around one of those and added some MQTT publishing. Unfortunately, all of my readings are coming in with a date stamp of 2010 because I've never installed their Android app and mated it with my phone. So I subsequently contacted them to see if they could tell me what UUID and format so I could set the date from my API and was told they wouldn't release that information.

So I wouldn't hold my breath hoping to get any information on the Wave Plus out of them unless they decide to get around to updating their example script.

Cavemanz commented 6 years ago

Indeed, I dont have very high hopes that they will somehow open up very much. HeatIt (Norwegian company selling various Z-Wave products) were cooperating with Airthings on a Z-Wave version of the Wave. That was supposed to launch right about now but was cancelled entirely in May. The likelyhood of Airthings being the one to say no is 99%.

If theres no way to get any meaningful data out of this Wave Plus, I have a deal to sell the unit on to a friend who has real issues with radon.

hpeyerl commented 6 years ago

I would encourage you to ask them to be more open-sourcey... I sent mail to their sales channel.

Cavemanz commented 6 years ago

Several Norwegians into home automation have tried, but they dont seem to care at the moment. I can understand their take with a hub in a commercial setting. However, being based on BT is a bad design decision to begin with.

Cavemanz commented 6 years ago

I ended up cancelling my order. It was pushed back to september, so I didnt wanna wait.

grangemd commented 5 years ago

class AirthingsWave: def init(self, config_file): Class instantiation requires a path to a config file in YAML format.

How do i set the path to the config file?

renemarc commented 5 years ago

@grangemd You can set the path as a command-line argument, for example:

python -m airthingswave-mqtt ~/config.yaml
grangemd commented 5 years ago

maybe i am doing this wrong because i am getting an error of

Unable to find component waves and Setup failed for waves: Component not found.

Not sure if I put the file in the wrong location or if I have done something else wrong

hpeyerl commented 5 years ago

From the instructions: https://github.com/hpeyerl/airthingswave-mqtt

waves:

grangemd commented 5 years ago

I guess what I am trying to do may not be correct. I am trying run this directly from a python file from HA from my Unraid server using the custom components. I am sure I am doing this wrong but not sure how to do this or if I can do it this way.

hpeyerl commented 5 years ago

Oh, that's different. I can't help you with that because I have no experience with the HA custom components mechanism.

Sorry, you're on your own.

On December 7, 2018 1:26:10 PM MST, grangemd notifications@github.com wrote:

I guess what I am trying to do may not be correct. I am trying run this directly from a python file from HA from my Unraid server using the custom components. I am sure I am doing this wrong but not sure how to do this or if I can do it this way.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/renemarc/home-assistant-config/issues/9#issuecomment-445355334

grangemd commented 5 years ago

Maybe this is the wrong place to put this but I can't find anywhere else to direct message so I will see if I can get help here. I set up a pi to do this. What exactly do I need to do? I can download the zip file and extract it to a folder. Then do I need to setup a cron job and call what file? Also do I need to create a conf.yaml file and how or where do I put the path to this conf.yaml file? Does it get called out in airthingswave.py? Sorry this is new to me.

renemarc commented 5 years ago

@grangemd: A quick and easy way to install airthingswave-mqtt on a Raspberry Pi is to use this project I've uploaded lately. It uses @hpeyerl's code, is based on balena (an open-source Docker-compatible stack for IoT) and creates a stand-alone, plug-in, secure bridge that's easy to manage:

https://github.com/renemarc/balena-airthingswave

I've been using this solution for a few months now and it's clicking along fine. Hopefully the included README.md should be useful to get you going, and your you prefer to go the manual route then the Dockerfiles and simple shell scripts should help you in any case. It is Alpine-based for simplicity and has a relatively small size; a Debian-based alternative is also available here for reference, but I've done fewer tests on it and am no longer using it.

If you prefer a more manual approach:

  1. Assuming that you have Python, PIP and Bluez installed, you still need to install the Python packages:

    pip install --no-cache-dir airthingswave-mqtt==0.2 PyYAML
  2. Once set, you first scan for your Airthings Wave MAC accress like described here: https://airthings.com/raspberry-pi/

  3. Then you create a configuration file like so with the MAC address(es) of your wave(s) and place it wherever you want, like in your home directory (~).

    mqtt:
     broker: 192.168.1.5
     port: 1883
     username: user
     password: super-secret-password
    
    waves:
     - name: "basement/radon"
       addr: "cc:78:ab:00:00:00"
  4. And finally, you create cron or systemd job that runs the following line:

    python -m airthingswave-mqtt /path/to/your/config.yaml

Each project above uses either cron (Alpine) or systemd (Debian).

Enjoy! 😃

grangemd commented 5 years ago

@renemarc I am trying to follow the readme and I get to the Installation Section. When I enter the line

git push balena master

I end up getting an error

mgranger@Millennium-Falcon MINGW64 /c/git/balena-airthingswave (master)
$ git push balena master
Enumerating objects: 15, done.
Counting objects: 100% (15/15), done.
Delta compression using up to 8 threads
Compressing objects: 100% (12/12), done.
Writing objects: 100% (15/15), 13.39 KiB \| 4.46 MiB/s, done.
Total 15 (delta 1), reused 15 (delta 1)
[Info]     Starting build for airthings-mqtt, user grangemd
[Info]     Dashboard link: https://dashboard.balena-cloud.com/apps/1320241/devices
[Info]     Building on arm02
[Info]     Pulling previous images for caching purposes...
[Success]  Successfully pulled cache images
[main]     Step 1/12 : FROM balenalib/raspberrypi3-alpine-python:2
[main]      ---> db31fd961548
[main]     Step 2/12 : ENV AIRTHINGSWAVE_VERSION 0.2
[main]     Using cache
[main]      ---> fd22eedfcb9f
[main]     Step 3/12 : ENV VERSION 0.2
[main]     Using cache
[main]      ---> 4fc32ee0257d
[main]     Step 4/12 : ENV CRON_PERIOD hourly
[main]     Using cache
[main]      ---> 50026ee9452c
[main]     Step 5/12 : LABEL org.label-schema.name "balena AirthingsWave" org.label-schema.description
"Airthings Wave radon detector bridge for single-board computers." org.label-schema.vcs-url
"https://github.com/renemarc/balena-airthingswave" org.label-schema.url "htt ps://airthings.com/wave/"
org.label-schema.version ${VERSION} org.label-schema.schema-version "1.0"
[main]     Using cache
[main]      ---> 3cf7678d66cd
[main]     Step 6/12 : WORKDIR /usr/src/app
[main]     Using cache
[main]      ---> cca174e69ea7
[main]     Step 7/12 : RUN apk add       bluez       g++       glib-dev       make       py-setuptools  && pip
install --no-cache-dir       airthingswave-mqtt==${AIRTHINGSWAVE_VERSION}       PyYAML  && wget
airthings.com/tech/find_wave.py  && find /usr/local       \( -ty pe d -a -name test -o -name tests \)       -o
\( -type f -a -name '*.pyc' -o -name '*.pyo' \)       -exec rm -rf '{}' +  && apk del       g++       glib-dev
make       py-setuptools
[main]      ---> Running in 38143235bd8c
[main]     fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/armhf/APKINDEX.tar.gz
[main]     fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/armhf/APKINDEX.tar.gz
[main]     (1/44) Installing libintl (0.19.8.1-r2)
[main]     (2/44) Installing libmount (2.32-r0)
[main]     (3/44) Installing pcre (8.42-r0)
[main]     (4/44) Installing glib (2.56.1-r0)
[main]     (5/44) Installing polkit (0.105-r8)
[main]     (6/44) Installing libxau (1.0.8-r2)
[main]     (7/44) Installing libbsd (0.8.6-r2)
[main]     (8/44) Installing libxdmcp (1.1.2-r4)
[main]     (9/44) Installing libxcb (1.13-r2)
[main]     (10/44) Installing libx11 (1.6.6-r0)
[main]     (11/44) Installing consolekit2 (1.2.1-r0)
[main]     (12/44) Installing bluez (5.49-r2)
[main]     (13/44) Installing libstdc++ (6.4.0-r9)
[main]     (14/44) Installing binutils (2.30-r5)
[main]     (15/44) Installing isl (0.18-r0)
[main]     (16/44) Installing libgomp (6.4.0-r9)
[main]     (17/44) Installing libatomic (6.4.0-r9)
[main]     (18/44) Installing mpfr3 (3.1.5-r1)
[main]     (19/44) Installing mpc1 (1.0.3-r1)
[main]     (20/44) Installing gcc (6.4.0-r9)
[main]     (21/44) Installing musl-dev (1.1.19-r10)
[main]     (22/44) Installing libc-dev (0.7.1-r0)
[main]     (23/44) Installing g++ (6.4.0-r9)
[main]     (24/44) Installing perl (5.26.3-r0)
[main]     (25/44) Installing gdbm (1.13-r1)
[main]     (26/44) Installing python2 (2.7.15-r1)
[main]     (27/44) Installing gettext-asprintf (0.19.8.1-r2)
[main]     (28/44) Installing gettext-libs (0.19.8.1-r2)
[main]     (29/44) Installing libxml2 (2.9.8-r1)
[main]     (30/44) Installing gettext (0.19.8.1-r2)
[main]     (31/44) Installing gettext-dev (0.19.8.1-r2)
[main]     (32/44) Installing zlib-dev (1.2.11-r1)
[main]     (33/44) Installing bzip2-dev (1.0.6-r6)
[main]     (34/44) Installing libffi-dev (3.2.1-r4)
[main]     (35/44) Installing libfdisk (2.32-r0)
[main]     (36/44) Installing libsmartcols (2.32-r0)
[main]     (37/44) Installing util-linux-dev (2.32-r0)
[main]     (38/44) Installing libpcre16 (8.42-r0)
[main]     (39/44) Installing libpcre32 (8.42-r0)
[main]     (40/44) Installing libpcrecpp (8.42-r0)
[main]     (41/44) Installing pcre-dev (8.42-r0)
[main]     (42/44) Installing glib-dev (2.56.1-r0)
[main]     (43/44) Installing make (4.2.1-r2)
[main]     (44/44) Installing py-setuptools (39.1.0-r0)
[main]     Executing busybox-1.28.4-r1.trigger
[main]     Executing glib-2.56.1-r0.trigger
[main]     No schema files found: doing nothing.
[main]     Executing dbus-1.10.24-r1.trigger
[main]     OK: 260 MiB in 112 packages
[main]     Collecting airthingswave-mqtt==0.2
[main]       Downloading
https://files.pythonhosted.org/packages/93/2b/450fede825f25fcccefcbb05f1fd3cb15b15a8393c743811
2182e26baaa/airthingswave-mqtt-0.2.tar.gz
[main]     Collecting PyYAML
[main]       Downloading
https://files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz (270kB)
[main]     Collecting bluepy>=1.1.4 (from airthingswave-mqtt==0.2)
[main]       Downloading
https://files.pythonhosted.org/packages/27/91/6cfca10bee9862f93015413cf9e6a52c3081a71f1518963396a055128f8e/bluepy-1.3.0.tar.gz (217kB)
[main]     Collecting paho-mqtt>=1.3.1 (from airthingswave-mqtt==0.2)
[main]       Downloading
https://files.pythonhosted.org/packages/25/63/db25e62979c2a716a74950c9ed658dce431b5cb01fde29eb6cba9489a904/paho-mqtt-1.4.0.tar.gz (88kB)
[main]     Installing collected packages: bluepy, paho-mqtt, airthingswave-mqtt, PyYAML
[main]       Running setup.py install for bluepy: started
[main]         Running setup.py install for bluepy: finished with status 'error'
[main]         Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-4XeoOx/bluepy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__,  'exec'))" install --record /tmp/pip-record-SJWK6g/install-record.txt --single-version-externally-managed --compile:
[main]         running install
[main]         running build
[main]         running build_py
[main]         Working dir is /tmp/pip-install-4XeoOx/bluepy
[main]         execute make -C ./bluepy clean
[main]         execute make -C bluepy -j1
[main]         Failed to compile bluepy-helper. Exiting install.
[main]         Command was 'make -C bluepy -j1' in /tmp/pip-install-4XeoOx/bluepy
[main]         Return code was 2
[main]         Output was:
[main]         make: Entering directory '/tmp/pip-install-4XeoOx/bluepy/bluepy'
[main]         tar xzf bluez-src.tgz
[main]         touch ./bluez-5.47/lib/bluetooth.c ./bluez-5.47/lib/hci.c ./bluez-5.47/lib/sdp.c ./bluez-5.47/lib/uuid.c ./bluez-5.47/attrib/att.c ./bluez-5.47/attrib/gatt.c ./bluez-5.47/attrib/gattrib.c ./bluez-5.47/attrib/utils.c ./bluez-5.47/btio/btio.c ./bluez-5.47/sr c/log.c ./bluez-5.47/src/shared/mgmt.c ./bluez-5.47/src/shared/crypto.c ./bluez-5.47/src/shared/att.c ./bluez-5.47/src/shared/queue.c ./bluez-5.47/src/shared/util.c ./bluez-5.47/src/shared/io-glib.c ./bluez-5.47/src/shared/timeout-glib.c
[main]         cc -L. -g -Wall  -Os -DHAVE_CONFIG_H -I./bluez-5.47/attrib -I./bluez-5.47 -I./bluez-5.47/lib -I./bluez-5.47/src -I./bluez-5.47/gdbus -I./bluez-5.47/btio -I./bluez-5.47/sys -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -o bluepy-helper bluepy-helper. c ./bluez-5.47/lib/bluetooth.c ./bluez-5.47/lib/hci.c ./bluez-5.47/lib/sdp.c ./bluez-5.47/lib/uuid.c ./bluez-5.47/attrib/att.c ./bluez-5.47/attrib/gatt.c ./bluez-5.47/attrib/gattrib.c ./bluez-5.47/attrib/utils.c ./bluez-5.47/btio/btio.c ./bluez-5.47/src/log.c ./bluez-5.4 7/src/shared/mgmt.c ./bluez-5.47/src/shared/crypto.c ./bluez-5.47/src/shared/att.c ./bluez-5.47/src/shared/queue.c ./bluez-5.47/src/shared/util.c ./bluez-5.47/src/shared/io-glib.c ./bluez-5.47/src/shared/timeout-glib.c -lglib-2.0 -lintl
[main]         ./bluez-5.47/src/shared/crypto.c:68:26: fatal error: linux/if_alg.h: No such file or directory
[main]          #include
[main]                                   ^
[main]         compilation terminated.
[main]         make: *** [Makefile:30: bluepy-helper] Error 1
[main]         make: Leaving directory '/tmp/pip-install-4XeoOx/bluepy/bluepy'
[main]         ----------------------------------------
[main]     Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-4XeoOx/bluepy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --reco rd /tmp/pip-record-SJWK6g/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-4XeoOx/bluepy/                                                                                                                        
[main]
[main]     You are using pip version 10.0.1, however version 18.1 is available.
[main]     You should consider upgrading via the 'pip install --upgrade pip' command.
[main]
[main]     Removing intermediate container 38143235bd8c
[main]     The command '/bin/sh -c apk add       bluez       g++       glib-dev       make       py-setuptools && pip install --no-cache-dir       airthingswave-mqtt==${AIRTHINGSWAVE_VERSION}       PyYAML  && wget airthings.com/tech/find_wave.py  && find /usr/local        \( -type d -a -name test -o -name tests \)
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \)       -exec rm -rf '{}' +  && apk del       g++       glib-dev
make       py-setuptools' returned a non-zero code: 1                                                
[Info]     Uploading images
[Success]  Successfully uploaded images
[Error]    Some services failed to build:
[Error]      Service: main
[Error]        Error: The command '/bin/sh -c apk add       bluez       g++       glib-dev       make       py-setuptools  && pip install --no-cache-dir       airthingswave-mqtt==${AIRTHINGSWAVE_VERSION}       PyYAML  && wget airthings.com/tech/find_wave.py  && find /usr /local       \( -type d -a -name test -o -name tests \)       -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \)       -exec rm -rf '{}' +  && apk del       g++       glib-dev       make       py-setuptools' returned a non-zero code: 1
[Error]    Not deploying release.
remote: error: hook declined to update refs/heads/master
To git.balena-cloud.com:grangemd/Airthings-MQTT.git
! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'grangemd@git.balena-cloud.com:grangemd/Airthings-MQTT.git'
--

Any advice would be appreciated.

grangemd commented 5 years ago

@renemarc

Sorry i just updated the file as I noticed it was hard to read. I ended up trying a different docker that I wasn't planning on using and it seemed to push correctly so I don't know what is wrong with this one.

renemarc commented 5 years ago

@grangemd: That was a weird bluez compilation bug. Which Pi were you using?

grangemd commented 5 years ago

@renemarc I am using a Raspberry Pi 3 Model B+

soinipe commented 5 years ago

Indeed, I dont have very high hopes that they will somehow open up very much. HeatIt (Norwegian company selling various Z-Wave products) were cooperating with Airthings on a Z-Wave version of the Wave. That was supposed to launch right about now but was cancelled entirely in May. The likelyhood of Airthings being the one to say no is 99%.

If theres no way to get any meaningful data out of this Wave Plus, I have a deal to sell the unit on to a friend who has real issues with radon.

Regarding Airthings Wave Plus: I'm integrating the sensor into my Domoticz, still testing but it seems that it is possible to read meaningful data with RPi from the device. I'll post the BluePy script here is somebody is interested. Need still a b it time to check if the script works ok.

grangemd commented 5 years ago

@renemarc Any thoughts on the bluez compilation bug?

hpeyerl commented 5 years ago

@renemarc I am trying to follow the readme and I get to the Installation Section. When I enter the line

git push balena master

I end up getting an error


mgranger@Millennium-Falcon MINGW64 /c/git/balena-airthingswave (master)

Forgive my intrusion but are you really trying to compile this under Windows?

grangemd commented 5 years ago

Yes. Sorry this is new to me. Should i be doing it somewhere else?

hpeyerl commented 5 years ago

The balena-airthingswave package is for a RaspberryPi3 which is an ARM processor running Linux and Bluez is the Linux Bluetooth stack. Your windows machine is almost sure to be an x86 machine. So, unless you're cross-compiling, you are almost certainly doing the wrong thing.

Based on your comments, your expertise level may not be sufficient to undertake this project. Maybe this isn't the project for you? I'm just a spectator here.

grangemd commented 5 years ago

Based on your comments, your expertise level may not be sufficient to undertake this project. Maybe this isn't the project for you? I'm just a spectator here.

I agree my knowledge may not be sufficient enough but I am trying to learn.

So I get the image loaded on my raspberry pi then where do I need to run the git commands for installation. Is the done on the pi? Because if I run them from the terminal window within Balena Cloud I get an error

bash: git: command not found

This is why i tried compiling it on a Windows PC but obviously that is wrong as was pointed out

grangemd commented 5 years ago

I also tried to run this on a Mac and I get a very similar error.

renemarc commented 5 years ago

I can take a Pi 3 B (not B+) offline to test the build on it, but likely not before tomorrow at the earliest.

grangemd commented 5 years ago

That sounds good. I appreciate it. I tried putting it on a Raspberry Pi 2 B+ but i couldn't get balena working for some reason. It was most likely my issue

grangemd commented 5 years ago

@renemarc Just for completeness I got a raspberry pi 2 B+ up and running and I get the same error. I don't know if I am compiling it the wrong way or what. I am know using the Mac to compile the code.

renemarc commented 5 years ago

Got some free time to test earlier than anticipated. Compilation was actually skipped on Raspberry Pi (used an existing binary I presume), and I had not tested the Alpine version on a RPi 3B where it needed to be compiled. Oops!

I've added the missing package and pushed the update. I've only tested the balena Dockerfile. Just do a git pull to get the updated master and it should compile properly now. 😃

grangemd commented 5 years ago

@renemarc That seemed to work perfectly. I will try to connect to my airthings device tonight. I don't know if you would know but is there a way to get this docker image to work with unraid? My server is right next to the airthings device so it would allow me to cut out the raspberry pi if I was able to do this.

grangemd commented 5 years ago

@renemarc So it appears to be working at least for the first run however I never seem to get a second message to send. I am getting this error...

19.12.18 20:15:00 (-0500)  main  crond: USER root pid  24 cmd run-parts /etc/periodic/15min
19.12.18 20:21:04 (-0500)  main  /usr/local/bin/docker-entrypoint.sh: line 10: /usr/src/app/airthingswave-mqtt.yaml: cannot overwrite existing file

Update: Everything seems to be working now. I rebooted the device and all seems well right now. Thanks for all the help.

sabeechen commented 5 years ago

If you're comfortable compiling in the Arduino IDE and have a spare ESP32 board lying around, I wrote a sketch you could use to read data from the Airthings and publish it to an MQTT server. I'm using this to get my radon levels into the HA instance. https://github.com/sabeechen/AirthingsMQTT

renemarc commented 5 years ago

@sabeechen Cool project! I like your approach of using simple, power-sipping dedicated hardware. 😃

I've added it to the list of community projects on balena-airthingswave.

curt7000 commented 5 years ago

Hey Everyone! I ran into a bunch of issues trying to setup a RPi Zero W as a hub for my AirthingsWave. @renemarc had some great instructions for the manual method, but it still failed for me. I couldn't seem to find a simple how to guide anywhere. I've updated @renemarc instructions below with my observations and tips. Hope this helps for whoever is trying to figure this out.

This is the "Manual Approach" running Raspbian Stretch on a Raspberry Pi Zero W

  1. Setup your RPi Zero W w/ Raspbian Stretch Lite

    Note: Python 2.7, PIP and Bluez are pre-installed

  2. Follow the instructions at Airthings ( https://airthings.com/raspberry-pi/ ) to be able to "find" & "read" your Airthings Wave with your RPi Zero W. Make sure you can "find" and then "read" your Airthings Wave. Keep the MAC address you use to "read", you'll need it later.

  3. Install airthingswave-mqtt on the RPi Zero W, more information on this gem is available at https://github.com/hpeyerl/airthingswave-mqtt

    pip install airthingswave-mqtt
    pip install pyyaml
  4. Create a yaml configuration file for airthingswave-mqtt on the RPi Zero W, we'll call it airthingsconfig.yaml

    nano /home/pi/airthingsconfig.yaml

Note: This is in Raspbian's Home Directory (~), but you can place this wherever you want. Include the config below with your details and the MAC address recorded in Step 2.

mqtt:
  broker: xxx.xxx.xxx.xxx
  port: 1883
  username: "YOURMQTTUSERNAME"
  password: "YOURMQTTPASSWORD"

waves:
  - name: "radon"
    addr: "cc:78:ab:00:00:00"

Note:

Username: Keep the quotes used above for "YOURMQTTUSERNAME", otherwise it will error out with "has no len ()"

Password: Keep the quotes used above for "YOURMQTTPASSWORD", otherwise it will error out with "has no Len ()"

Name: Keep the quotes used above, "name it whatever you want", for this example, I used "radon"

Addr: This is the MAC recorded earlier. It shouldn't matter, but I still had problems, keep the letters lowercase. Again, keep the quotes!

  1. Try running it with the command

     python -m airthingswave-mqtt /home/pi/airthingsconfig.yaml

If you are successful, you'll see it search and find your Airthings Wave, and report Radon, Radon Long Term, Temperature, Humidity.

  1. Now to make sure Home Assistant is setup properly to receive these MQTT messages, add the following to your HA configuration.yaml
sensor 1:
  platform: mqtt
  name: "Radon 24HRS"
  state_topic: "radon/Radon-Day"
  unit_of_measurement: "pCi/L"

sensor 2:
  platform: mqtt
  name: "Radon LifeTime"
  state_topic: "radon/Radon-Long-Term"
  unit_of_measurement: "pCi/L"

sensor 3:
  platform: mqtt
  name: "Temperature"
  state_topic: "radon/Temperature"
  unit_of_measurement: "°C"

sensor 4:
  platform: mqtt
  name: "Humidity"
  state_topic: "radon/Humidity"
  unit_of_measurement: "%"

Note: replace "radon/ " with whatever you chose to name it.

  1. Before restarting your HA, I recommend you watch Home Assistant and make sure the MQTT messages are properly received by enabling the following in your HA configuration.yaml. Once you've validated everything is working, you can Disable/Remove this from your config.
logger:
  default: warning
  logs:
    homeassistant.components.mqtt: debug
  1. tail your HA log file

     tail -f home-assistant.log
  2. Restart your HA

  3. Issue the command in Step 5 on your RPi Zero W, if all is working you should see HA listening on the MQTT instances you created and successful reports coming in from your RPi Zero W

  4. Once everything is working, set the Step 5 command as a cron job

hpeyerl commented 5 years ago

Hey that's terrific. Do you feel like modifying the README.md for airthingswave-mqtt and send a merge request.

On February 12, 2019 1:08:33 PM MST, curt7000 notifications@github.com wrote:

Hey Everyone! I ran into a bunch of issues trying to setup a RPi Zero W as a hub for my AirthingsWave. @renemarc had some great instructions for the manual method, but it still failed for me. I couldn't seem to find a simple how to guide anywhere. I've updated @renemarc instructions below with my observations and tips. Hope this helps for whoever is trying to figure this out.>

This is the "Manual Approach" running Raspbian Stretch on a Raspberry Pi Zero W>

  1. Setup your RPi Zero W w/ Raspbian Stretch Lite>

Note: Python 2.7, PIP and Bluez are pre-installed>

  1. Follow the instructions at Airthings ( https://airthings.com/raspberry-pi/ ) to be able to "find" & "read" your Airthings Wave with your RPi Zero W. Make sure you can "find" and then "read" your Airthings Wave. Keep the MAC address you use to "read", you'll need it later.>

  2. Install airthingswave-mqtt on the RPi Zero W, more information on this gem is available at https://github.com/hpeyerl/airthingswave-mqtt>


pip install airthingswave-mqtt>
pip install pyyaml>
```>

4. Create a yaml configuration file for airthingswave-mqtt on the RPi
Zero W, we'll call it airthingsconfig.yaml>

```shell>
nano /home/pi/airthingsconfig.yaml>
```>

**Note:** This is in Raspbian's Home Directory (~), but you can place
this wherever you want.  Include the config below with your details and
the MAC address recorded in Step 2.>

mqtt:>
broker: xxx.xxx.xxx.xxx>
port: 1883>
username: "YOURMQTTUSERNAME">
password: "YOURMQTTPASSWORD">

waves:>
- name: "radon">
addr: "cc:78:ab:00:00:00">

Note:>

**Username:**  Keep the quotes used above for "YOURMQTTUSERNAME",
otherwise it will error out with "has no len ()">

**Password:**  Keep the quotes used above for "YOURMQTTPASSWORD",
otherwise it will error out with "has no Len ()">

**Name:** Keep the quotes used above, "name it whatever you want", for
this example, I used "radon">

**Addr:** This is the MAC recorded earlier. It shouldn't matter, but I
still had problems, keep the letters lowercase.  Again, keep the
quotes!>

5. Try running it with the command>

```shell>
python -m airthingswave-mqtt /home/pi/airthingsconfig.yaml>
```>

If you are successful, you'll see it search and find your Airthings
Wave, and report Radon, Radon Long Term, Temperature, Humidity.>

6. Now to make sure Home Assistant is setup properly to receive these
MQTT messages, add the following to your HA configuration.yaml>

```>
sensor 1:>
  platform: mqtt>
  name: "Radon 24HRS">
  state_topic: "radon/Radon-Day">
  unit_of_measurement: "pCi/L">

sensor 2:>
  platform: mqtt>
  name: "Radon LifeTime">
  state_topic: "radon/Radon-Long-Term">
  unit_of_measurement: "pCi/L">

sensor 3:>
  platform: mqtt>
  name: "Temperature">
  state_topic: "radon/Temperature">
  unit_of_measurement: "°C">

sensor 4:>
  platform: mqtt>
  name: "Humidity">
  state_topic: "radon/Humidity">
  unit_of_measurement: "%">

```>
Note: replace "radon/ " with whatever you chose to name it.>

7.  Before restarting your HA, I recommend you watch Home Assistant and
make sure the MQTT messages are properly received by enabling the
following in your HA configuration.yaml.  Once you've validated
everything is working, you can Disable/Remove this from your config.>

```>
logger:>
default: warning>
logs:>
homeassistant.components.mqtt: debug>
```>

8. tail your HA log file>

```shell>
tail -f home-assistant.log>
```>

8. Restart your HA>

9. Issue the command in Step 5 on your RPi Zero W, if all is working
you should see HA listening on the MQTT instances you created and
successful reports coming in from your RPi Zero W>

5. Once everything is working, set the Step 5 command as a cron job>

-- >
You are receiving this because you were mentioned.>
Reply to this email directly or view it on GitHub:>
https://github.com/renemarc/home-assistant-config/issues/9#issuecomment-462914581
curt7000 commented 5 years ago

Hey that's terrific. Do you feel like modifying the README.md for airthingswave-mqtt and send a merge request.

Thanks! Yea, I’ll give it a try.