[RELEASE] Honeywell HPA250B Air Purifier integration (through Raspberry Pi)

devicetype
honeywell

(PPO16) #1

hi there,

I am publishing the integration I made with a Raspberry Pi to command my Honeywell HPA250B which is originally a BT-LE remote controlled with a (bad) smartphone app.

This integration is based on a protocol I defined over HTTP between the raspberry and SmartThings device handler. When a command is sent from the DTH to the Pi, a python script parse the requests, sends the needed BT-LE command to the Air Purifier and return the notification it receives as a JSON to the DTH. The DTH refreshes upon polling (use Pollster) of the notifications in case you use the purifier controls directly. Either on the next refresh polled or the next command sent by the DTH, the status will be updated on the DTH screen.

The DTH implements the controls of the HPA250B except their (bad) app allergy automation based on the (bad) service provided by Accuweather. I will certainly add a WeatherUnderground feature later as it seems more accurate where I live and in general.

Codes and HowTo available on my GitHub:

Appreciate your comments and thanks @tgauchat for his precious help in DTH tiles behavior clarification.

Here is the general and simple architecture:

Here are some snapshots of the DTH:

Thanks!


[BETA RELEASE] URI Switch -- Device Handler for controlling items via HTTP calls
Reading JSON data into a DTH?
(Mitchell Lu) #2

@Philippe_Portes How to install below service, Is that necessary… I currently did not have HOA250B, so I have not way to try your code, Once I have that, I will try the code and let you know what I have learn from that…

Raspberry configuration:

Bluez (http://www.elinux.org/RPi_Bluetooth_LE)
BluePy (https://github.com/IanHarvey/bluepy)
requests (http://raspberrypi-aa.github.io/session4/requests.html)


(PPO16) #3

Hi Mitchell,

These are the same you installed for the AirMentor. You can run the HPA250B py script on the same raspberry you are you using for the AirMentor if the devices are in the range. Otherwise, if you use another Raspberry, you just have to do the same as for AirMentor config.
the only difference is that this HPA250B doesn’t need apache/php5 as I didn’t use a website approach.

Cheers

Philippe


(Mitchell Lu) #4

Philippe,
I finally have my HAP250 on my hand, but a little problem here.
example: sudo python hpa250b_agent.py fe:ed:fa:ce:da:ad 12345 “ifconfig wlan0 | grep "inet " | awk -F'[: ]+' '{ print $4 }'” 1 &

fe:ed:fa:ce:da:ad => Is that the Raspberry Pi bluetooth mac address ?
wlan0 ? What is that ?, My Raspberry Pi connect with Ethernet, not wlan0, Is that is case, How I can configure ?

1, Is that the Bluetooth Ports , hc0 or hc1 , Is that same as I use for AirMentor ? I use hc0…


(PPO16) #5

Excellent !

no that’s the purifier MAC

if you know your Pi IP address you can just:

sudo python hpa250b_agent.py fe:ed:fa:ce:da:ad 12345 192.168.XX.YY 1 &

Yes the BT port. You can share the same as Airmentor.
0 is hci0, 1 is hci1
let me know


(Mitchell Lu) #6

How to know my purifier MAC ? use the blutoothctl and devices command, there are couple of device, no names, need to check one by one ?


(PPO16) #7

1.Disable the BT on the purifier by pressing the button

2.Just do on your Pi:

pi@raspberrypi:~ $ sudo hcitool lescan

  1. Wait that the list doesn’t add more devices then
  2. Then press the BT button on the purifier, it will appear at the end of the list. That will be the one.

Might start by 05:65 I believe.

BTW, make sure you don’t run the mobile app at the same time, otherwise the PI won’t be able to connect. There can be only one connection (this is not like Arimentor where I was only listening, here I need to connect).


(Mitchell Lu) #8

Hi Philippe

 That is why I can not connect , as I have mobile phone running and connect to the HPA250.. I will try to disable that mobile connection and try again

(PPO16) #9

Once the PI will be connected, the app will no longer be able to connect but anyway, the smartapp device offer the same settings (and less buggy…).


(Mitchell Lu) #10

Still have problem
sudo python hpa250b_agent.py d0:b5:c2:93:be:xx 12345 192.168.1.xxx 0&
[1] 2509
pi@raspberrypi:~/Documents $ Will follow broadcasts from: d0:b5:c2:93:be:xx . SmartThings DeviceHandler will have to be configured with IP: 12345 and port: 12345
connection error
connection error
.
.
. I have HP250 MAC d0:b5:c2:93:be:xx
Raspberry Pi IP is 192.168.1.xxx

IP above error show 12345 ?. any command is wrong ?


(Mitchell Lu) #11

It work after I update the hpa250b_agent.py from your Github


(PPO16) #12

Good, let me know if any issue


(Mitchell Lu) #13

How it become a switch to Turn on and off base on my Home Automation rule ?


(PPO16) #14

I just coded it for you right now.

Replace the code of your DTH with the one at https://github.com/philippeportesppo/Honeywell_HPA250B_SmartThings/blob/master/honeywell-hpa250b.groovy

I added the switch capability and on/off methods so you can use it as a swtich in routines.

I just tested it and it works fine :wink:


(Mitchell Lu) #15

Philippe
Did you see any connect issue, sometime it will lost connection ? any way to improve that ? I have re-isnatll Raspberry Pi 3 before due to system crash, and the Air Mentor used to hang-up very often, but It now can running more than week… but The HPA250 seem easy to disconnect from Raspberry Pi 3


(PPO16) #16

I don’t have any hangs. My Pi runs for now 6 months regarding the AirMentor one. The other one in my bedroom is running the HPA250B scripts for weeks now.

I suggest you make sure to install an image from https://www.raspberrypi.org/downloads/raspbian/

And to be honest, I bought once a Pi on Amazon that came with a nice Pi white housing and the board was hanging I suppose because there was no heat-sink and the housing had no air circulation. I cannot imagine why Raspberry sells that. So I returned the boards and housings.

Now I only buy from this supplier: the housing is great and kit is complete, although a bit more pricy than others.

That’s the 2nd I buy and they work absolutely perfectly.

Do you have heat-sinks?

How far is the Pi from the HPA250B? Mine is always in a 4m range.


(PPO16) #17

@mitchell_lu66,

I fixed a small issue in https://github.com/philippeportesppo/Honeywell_HPA250B_SmartThings/blob/master/honeywell-hpa250b.groovy

Yesterday implementation was working with Alexa but Alexa was not refreshing the status in Alexa app. Now it works fully like a switch on/off.


(Mitchell Lu) #18

Philiippe

I only have 1 Raspberry Pi 3, and It need to used Air Mentor, and weather ground and HPA250, and I also move the BigTalk (VLC Play) in Raspberry Pi3, so , I believe the Raspberry is busy enough and different from you setup… I also notice there are some error from time to time in the running terminal, so you can check if any code issue special at the line the terminal indicate line 175, line 272.

Delegate initialized
Connecting
Connected to d0:b5:c2:93:be:7e
Notification received from handle: 46 Data: �
Valid notification:a5000000000000000000000000000000000000
{“hpa250b”: {“fanSpeed”:“off”,“voc”:“off”,“vociaq”:“green”,“light”:“off”,“timer”:“0”}}
{“hpa250b”: {“fanSpeed”:“off”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
Error on line 175
Device disconnected
Trying to reach again d0:b5:c2:93:be:7e
Trying to reach again d0:b5:c2:93:be:7e
Re-connected BT-LE target
Notification received from handle: 46 Data: �
Valid notification:a5000000000000000000000000000000000000
{“hpa250b”: {“fanSpeed”:“off”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
{“hpa250b”: {“fanSpeed”:“off”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
Error on line 175
Device disconnected
Trying to reach again d0:b5:c2:93:be:7e
Trying to reach again d0:b5:c2:93:be:7e
Trying to reach again d0:b5:c2:93:be:7e
Re-connected BT-LE target
(‘Server received’, “‘GET /api/fanspeed/germ HTTP/1.1\r\nAccept: /\r\nUser-Agent: Linux UPnP/1.0 SmartThings\r\nHOST: 192.168.1.149:12345\r\n\r\n’”)
fanspeed
Sending command:��
Notification received from handle: 46 Data: �
Valid notification:a5000000000000000000000000000000000000
{“hpa250b”: {“fanSpeed”:“off”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
{“hpa250b”: {“fanSpeed”:“off”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
Notification received from handle: 46 Data: �
Valid notification:a5110000000000000000000000000000000000
{“hpa250b”: {“fanSpeed”:“off”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
{“hpa250b”: {“fanSpeed”:“general_on”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
Received notification after command
Error on line 272
Device disconnected
Trying to reach again d0:b5:c2:93:be:7e
Re-connected BT-LE target
(‘Server received’, “‘GET /api/fanspeed/off HTTP/1.1\r\nAccept: /\r\nUser-Agent: Linux UPnP/1.0 SmartThings\r\nHOST: 192.168.1.149:12345\r\n\r\n’”)
fanspeed
Sending command:��
Error on line 217
Device disconnected
Trying to reach again d0:b5:c2:93:be:7e
Re-connected BT-LE target
Notification received from handle: 46 Data: �
Valid notification:a5110000000000000000000000000000000000
{“hpa250b”: {“fanSpeed”:“general_on”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
{“hpa250b”: {“fanSpeed”:“general_on”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
(‘Server received’, “‘GET /api/light/medium HTTP/1.1\r\nAccept: /\r\nUser-Agent: Linux UPnP/1.0 SmartThings\r\nHOST: 192.168.1.149:12345\r\n\r\n’”)
light
Sending command:��
Notification received from handle: 46 Data: �
Valid notification:a5110100000000000000000000000000000000
{“hpa250b”: {“fanSpeed”:“general_on”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
{“hpa250b”: {“fanSpeed”:“general_on”,“voc”:“off”,“vociaq”:“green”,“light”:“medium”,“timer”:“0”}}
Received notification after command
(‘Server received’, “‘GET /api/fanspeed/germ HTTP/1.1\r\nAccept: /\r\nUser-Agent: Linux UPnP/1.0 SmartThings\r\nHOST: 192.168.1.149:12345\r\n\r\n’”)
fanspeed
Sending command:��
Error on line 215
Device disconnected
Trying to reach again d0:b5:c2:93:be:7e
Re-connected BT-LE target
Notification received from handle: 46 Data: �
Valid notification:a5090100000000000000000000000000000000
{“hpa250b”: {“fanSpeed”:“general_on”,“voc”:“off”,“vociaq”:“green”,“light”:“medium”,“timer”:“0”}}
{“hpa250b”: {“fanSpeed”:“germ”,“voc”:“off”,“vociaq”:“green”,“light”:“medium”,“timer”:“0”}}
(‘Server received’, “‘GET /api/fanspeed/off HTTP/1.1\r\nAccept: /\r\nUser-Agent: Linux UPnP/1.0 SmartThings\r\nHOST: 192.168.1.149:12345\r\n\r\n’”)
fanspeed
Sending command:��
Notification received from handle: 46 Data: �
Valid notification:a5000000000000000000000000000000000000
{“hpa250b”: {“fanSpeed”:“germ”,“voc”:“off”,“vociaq”:“green”,“light”:“medium”,“timer”:“0”}}
{“hpa250b”: {“fanSpeed”:“off”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
Received notification after command
Error on line 272
Device disconnected
Trying to reach again d0:b5:c2:93:be:7e
Re-connected BT-LE target
Notification received from handle: 46 Data: �
Valid notification:a5000000000000000000000000000000000000
{“hpa250b”: {“fanSpeed”:“off”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
{“hpa250b”: {“fanSpeed”:“off”,“voc”:“off”,“vociaq”:“green”,“light”:“on”,“timer”:“0”}}
Error on line 175
Device disconnected
Trying to reach again d0:b5:c2:93:be:7e
Trying to reach again d0:b5:c2:93:be:7e
Trying to reach again d0:b5:c2:93:be:7e
Trying to reach again d0:b5:c2:93:be:7e
Trying to reach again d0:b5:c2:93:be:7e
Trying to reach again d0:b5:c2:93:be:7e


(Mitchell Lu) #19

when disconnect fro HPA250 from Raspberry Pi 3, and try to close the terminal and connect to HPA250 again.It have below error, and I need to restart Raspberry again, so I can start the HPA250_xxx .py again.

SmartThings DeviceHandler will have to be configured with IP: 192.168.1.xxx and port: 12345
hci used: 0
Delegate initialized
Connecting . .
Connected to d0:b5:c2:93:be:xx
socket already bond
Traceback (most recent call last):
File “hpa250b_agent.py”, line 291, in
main()
File “hpa250b_agent.py”, line 169, in main
s.bind((host, port))
AttributeError: ‘NoneType’ object has no attribute ‘bind’


(PPO16) #20

The errors line 175 and 272 are meaning something went wrong talking to the BT-LE device (the purifier). Fortunately the py script recovers the connections when needed so you should still have the function working from smartthings. These errors can be caused by a weak signal. I remember you had a USB BT-LE dongle, do you use it? If not, can you try by using its HCI port #, if yes, can you use the internal Pi one?