diff --git a/README.md b/README.md index 00223e8..6c90718 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,47 @@ -# AirMentorPro2_SmartThings - Overall Setup Icon -What you need: - -Raspberry PI 3 with Apache2 and PHP5 installed properly

- Raspberry Pi PHP and Apache installation instructions (https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md) -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 using the oringinal image on it, I used this external one then. Then recently, the Raspberry Pi internal BTLE works fine using Linux raspberrypi 4.4.50-v7+ #970 SMP Mon Feb 20 19:18:29 GMT 2017 armv7l GNU/Linux< image from the Raspberry website

-Additional installation on Raspberry:

-
  • Bluez (http://www.elinux.org/RPi_Bluetooth_LE)

  • -
  • BluePy (https://github.com/IanHarvey/bluepy)

  • -
  • requests (http://raspberrypi-aa.github.io/session4/requests.html)

  • -Put in Raspberry /var/www/html folder the file : airmentorpro2.php

    -Put in /home/pi/Documents the python script airmentorpro2.py

    -You will launch this first python script by: sudo /usr/bin/python /var/www/html/airmentorpro2.py [your AirMentor MAC] [your hci#] &

    Example: sudo /usr/bin/python /var/www/html/airmentorpro2.py fe:ed:fa:ce:be:ef 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. If you don't want to use this, check the previous versions of the DTH and html page on this GitHub.

    -

    You will launche this script by: sudo /usr/bin/python /var/www/html/undergroundweather.py [yourAPI key] [state] [city] & -

    As this script runs an infinit loop, better to fork it with & too

    -In Smartthings IDE: Create a Device Handler (then save and publish for yourself) from air-mentor-pro-2.groovy

    -In Smartthings IDE: Create a SmartApp (then save and publish for yourself) from SmartApp.groovy. The Smartapp is here to allow the alerting on pollution level and polluant. This is an optional app, if you don't want to be notified, you can ignore it.

    -In Smartthings IDE: Create a SmartApp (then save and publish for yourself) from iaq-vent.groovy. The Smartapp is here to allow piloting vents/swtiches based on selected levels of IAQ

    -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

    -IMPORTANT: use pollster smartapp to cadence the polling (every 5min) otherwise, Smartthing known issue will let the DTH stoping the polling after 24h or so.

    +

    Raspberry Pi 3 side: + +

    1. Apache2 and PHP5 properly installed (see here)

    +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 using the oringinal image on it, I used this external one then. Then recently, the Raspberry Pi internal BTLE works fine using Linux raspberrypi 4.4.50-v7+ #970 SMP Mon Feb 20 19:18:29 GMT 2017 armv7l GNU/Linux< image from the Raspberry website (or above)

    +

    2. Additional installation on Raspberry:

    +

    Bluez (http://www.elinux.org/RPi_Bluetooth_LE)

    +

    BluePy (https://github.com/IanHarvey/bluepy)

    +

    >requests (http://raspberrypi-aa.github.io/session4/requests.html)

    +

    3. This project files installation:

    +

  • Put in Raspberry /var/www/html folder the file : airmentorpro2.php
  • +
  • Put in /home/pi the python script airmentorpro2.py
  • +
  • Put in /home/pi the python script ssdp_server.py (this file uses wlan0 as interface. You can change the code to use eth0 or other)
  • +
  • Put in /home/pi 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. If you don't want to use this, check the previous versions of the DTH and html page on this GitHub. +
  • Create a folder "lib" in /home/pi
  • +
  • Put in /home/pi/lib the 2 files ssdp.py and upnp_http_server.py.
  • +This is mandatory the 2 files are in a lib folder and the lib folder at the same location as ssdp_server.py +
  • In /etc/rc.local, just before the exit 0 (last line):
  • +
  • add: sudo /usr/bin/python /home/pi/airmentorpro2.py [your AirMentor MAC] [your hci#] &

    Example: sudo /usr/bin/python /home/pi/airmentorpro2.py fe:ed:fa:ce:be:ef 0 & 

  • + +
  • add: /usr/bin/python /home/pi/ssdp.py &
  • +
  • add sudo /usr/bin/python /var/www/html/undergroundweather.py [yourAPI key] [state] [city] &
  • + +

    Smarthings IDE side:

    + +

  • with a github enabled SmartThings IDE (see here), import the namespace philippeportesppo and repository AirMentorPro2_SmartThings on master branch
  • and the following device handlers and smartapps: +

    SmartApps: +
  • AirMentor Pro UPnP Service Manager : the smartapp managing the ssdp discover.
  • +
  • IAQ_vent : the smartapp managing vents and AC fans upon air quality notification
  • +
  • Notify Me When for AirMentor Pro : the smartapp managing events and notify you about the air quality.
  • +

    Device Handler: +
  • Air Mentor Pro 2 : the device handler to access the AirMentor Pro 2
  • +

    +If you cannot access github integration, you might have to create the devicehandler and smartapps manually from the code. + +

    SmartThing Mobile app:

    +

  • Go to Smartapps section and add the AirMentor Pro UPnP Service Manager smartapp from "My Apps"
  • +
  • Start the research, few seconds later the pi will be discovered, select it, press next and save.
  • +
  • AirMentor Pro 2 will be added + + +

    IMPORTANT:

    use pollster smartapp to cadence the polling (every 5min) otherwise, Smartthing known issue will let the DTH stoping the polling after 24h or so.

    Hope you like it. +