Foobot, BlueAir air purifier integration scripts & rules

As there isn’t (yet) a Binding for foobot or Blue Air air purifiers, I’ve tweaked some JS code and implemented some Exec Things and related Items / Rules to implement a few features using the REST API.

Using this method, I’m now cranking up the fan speed of the purifier when no-one is home or in the room and then bringing it down when people are around (I have some motion sensors to detect this).

Sharing it here in case anyone else has an interest or similar need. Enjoy.

More: https://www.npmjs.com/package/openhab-blueair

2 Likes

Trying this with openHAB 2.5 running on Synology NAS (that does not support Docker), and troubleshooting gives me the following results:

root@synology:/volume1/public/openHAB/conf/scripts/node_modules/openhab-blueair# /usr/local/bin/node index.js <mac removed> info
Polled API:https://api.foobot.io/v2/user/<email removed>/homehost/
Got home region:api-nc.foobot.io
Polled API:https://api-nc.foobot.io/v2/user/<email removed>/login/
Logged in to API
Got token: undefined
Polled API:https://api-nc.foobot.io/v2/owner/<email removed>/device/
Total number of devices found: undefined
Trying to identify using Mac address: <mac removed>
/volume1/public/openHAB/conf/scripts/node_modules/openhab-blueair/blueair.js:173
                            var device = json.filter(function(item) {
                                              ^

TypeError: json.filter is not a function
    at BlueAirDevice.<anonymous> (/volume1/public/openHAB/conf/scripts/node_modules/openhab-blueair/blueair.js:173:47)
    at BlueAirDevice.<anonymous> (/volume1/public/openHAB/conf/scripts/node_modules/openhab-blueair/blueair.js:68:17)
    at Request.self.callback (/volume1/public/openHAB/conf/scripts/node_modules/request/request.js:185:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/volume1/public/openHAB/conf/scripts/node_modules/request/request.js:1154:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/volume1/public/openHAB/conf/scripts/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:313:30)

I replied in your DM as well, but for others… it appears that at some stage Blueair divorced themselves from the foobot infrastructure, which foobot confirmed when I emailed them. Probably something related to their move into AWS.

When they did so, the URL for the API changed. I’ve been able to work out what the change was and now have this working again. In short, the API that was reachable on api.foobot.io is now (for Blueair devices) available at api.blueair.io.

One small change to my node script will fix this to be functional again. I’ll update the repo in the coming days with this change.