Hi there,
Update 8/12: fixed the icons for iOS so that they don’t cover the labels. Android was already ok. Please check the newest Master versions of my github.
Update 5/5: solved Mitchell issue: needed to pass the mac address to python script in lowercase, not uppercase. Also use now external dongle.
IMPORTANT: use pollster smartapp to candence the polling (every 5min) otherwise, Smartthing known issue will let the DTH stoping the polling after 24h or so.
I bought 2 years ago this excellent device called “Air Mentor Pro 2” (https://www.amazon.com/Mentor-Indoor-Quality-Monitor-8096-AP/dp/B0114LE05O) which is an Air Quality autonomous device.
It allows to monitor different hazards for health like CO2, PM2.5, PM10, VOC, temperature and humidity. It also provides an easy to ready index of air quality (IAQ) and shines various colors according to the IAQ. Really great stuff except on one aspect: it connects to a smartphone by Bluetooth LE which basically makes it useful when you are in the same room. I had discussed with CoAsia guys last year at Computex in Taipei and they were to deliver a wifi access to it via a kind of dongle. Unfortunately, this is a proprietary setup. So I decided to create a device handler to integrate it in ST.
The original app page is like ths picture:
First step was to get a BT LE sniffer and spy the traffic, then identify the data inside the packets and mimic that with a Raspberry PI. The PI was the solution I found after checking what python library allows to manipulate Bluetooth LE GATT information.
The PI allows that easily and is also hosting a webpage I use to store and give external access to the device handler.
On the picture, the below path is the standard Air Mentor way, above one is my implementation.
What you need:
Raspberry PI 3 with Apach2 and PHP installed properly
Raspberry Pi PHP and Apache installation instructions
Assign a static IP address to your raspberry on your local network. This project works only if your Hub and raspberry are on same network(otherwise the HubAction won’t work and you need to implement external HTTPrequest instead)
[Optional:]1 USB dongle BT-LE (Plugable Dual-Mode BT-LE/BT model USB-BT4LE)
I didn’t make it with the internal BT-LE of the Pi initially so I used this external one. But then, I managed since to make the internal one working too.
Additional installation on Raspberry::
Put in Raspberry /var/www/html folder the file : airmentorpro2.php airmentorpro2.php
Put in /home/pi/Documents the python script airmentorpro2.py
You will launch this first python script by:
sudo python airmentorpro2.py [your AirMentor MAC] [your hci port #]&
Example:
sudo python airmentorpro2.py fe:ed:be:ef:fa:ce 0 &
As this script runs an infinit loop, better to fork it with &
Put in /home/pi/Documents the python script undergroundweather.py
This requires you to get a Weather UnderGround API key from https://www.wunderground.com/weather/api/
The information is used to provide more data about outside conditions.
Example: python undergroundweather 183aaabbbcccc ca Sunnyvale &
In Smartthing IDE: Create a Device Handler (then save and publish for yourself) from AirMentorDTH.groovy
In Smartthing IDE: Create a SmartApp (then save and publish for yourself) from SmartApp.groovy
The Smartapp is here to allow the alerting on high and very high pollution. You can tweak the smartappto also get alerts on medium pollution.
Create a device in Smartthings web page based on this device handler. Put anything as Device Network Id as the Device Handler will overwrite it at first run. Don’t ever change it after if your raspberry doesn’t change its static IP address otherwise, the parse method is sent for some reason to the former device despite the HubAction is sent by the new instance…
Configure the Smarthing device with the IP, port of the Raspberry and URL of the webpage and self-refreshing regularly.
You can also access the web page directly by a http://[yourraspberry IP]/airmentorpro2.php?Action=get
Hope you like it.