mylesagray / homebridge-blueair

BlueAir air purifier plugin for homebridge
Apache License 2.0
38 stars 20 forks source link

Add support for multiple air purifiers #15

Closed mylesagray closed 5 years ago

mylesagray commented 5 years ago

Currently we will just pull back the first instance of an air purifier in the array response, add logic such that n purifiers are supported.

Related to #12 #1

ndlaham commented 5 years ago

Not sure if this matters, but the 2 units I can help test this with are both sensorless models. I can report results from Postman or anything else, just let me know what you need. Thanks!

mylesagray commented 5 years ago

@ndlaham Would a stop-gap of adding multiple accessory configs with different index ids do until I can refactor the plugin into a platform?

What your config would look like in this case is something like this:

{
    "accessory": "BlueAir",
    "name": "BlueAir 1",
    "username": "{BlueAir-Email}",
    "password": "{BlueAir-Password}",
    "airPurifierIndex": "0"
},
{
    "accessory": "BlueAir",
    "name": "BlueAir 2",
    "username": "{BlueAir-Email}",
    "password": "{BlueAir-Password}",
    "airPurifierIndex": "1"
}

If so I can get this published in short order.

ndlaham commented 5 years ago

Yeah I can certainly try that in my config and see if it behaves how you want.

I won’t be home till later but hopefully can get to it tonight. I’ll keep you posted, thanks.

mylesagray commented 5 years ago

Let me push to the feature branch and I'll post back here when it's good to go!

mylesagray commented 5 years ago

Okay run:

npm -g install git+https://git@github.com/mylesgray/homebridge-blueair.git#feature\/multiple-purifiers --unsafe-perms

This should upgrade you to v0.4.0 - then set your config as above and let me know 👍

ndlaham commented 5 years ago

Okay got it running.

Both air purifiers are connected and I can control both! I don’t notice any issues yet (still having the update issue but that is unrelated to this), so I think all is good.

Only nuance I noticed which didn’t make sense to me is when I added the 2 accessory indexes in my config, the first one (index 0) ended up being the Blueair unit I could not control with the old code v0.3.2. I figured index 0 would be the same one that the old logic pulled the last time. Because of that I had my descriptions reversed the first time I booted the code, and realized this after. I just reversed my descriptions in my config, and now everything matches up and works.

This is great man, thank you! I’ll keep testing.

mylesagray commented 5 years ago

I know why they were reversed compared to the old config - a bug in my code meant it always took the LAST instance in the array not the first with the v0.3.2 code, my bad!

If it stays stable I’ll publish this as v0.4.0 later in the week. On Mon, 26 Nov 2018 at 01:28, ndlaham notifications@github.com wrote:

Okay got it running.

Both air purifiers are connected and I can control both! I don’t notice any issues yet (still having the update issue but that is unrelated to this), so I think all is good.

Only nuance I noticed which didn’t make sense to me is when I added the 2 accessory indexes in my config, the first one (index 0) ended up being the Blueair unit I could not control with the old code v0.3.2. I figured index 0 would be the same one that the old logic pulled the last time. Because of that I had my descriptions reversed the first time I booted the code, and realized this after. I just reversed my descriptions in my config, and now everything matches up and works.

This is great man, thank you! I’ll keep testing.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/mylesgray/homebridge-blueair/issues/15#issuecomment-441493424, or mute the thread https://github.com/notifications/unsubscribe-auth/AAlMTD0phB8DkrIHP1EHSr7wd_tuka8lks5uy0OrgaJpZM4Yxcq5 .

ndlaham commented 5 years ago

Got it. All good, just wanted to point it out in case it could cause a problem later for you.

The only way I can think to improve the new code for multiple devices (from a user based perspective) would be to pull down the descriptions automatically that are stored on the Blueair app/servers.

For now, the user just has to enter the descriptions manually in the config which is no big deal, but if you have 5 air purifiers it could get a bit confusing if you don’t know the order of how they will be indexed.

mylesagray commented 5 years ago

The addition of the device name from API will have to wait for the refactor into a Platform from its current state as an Accessory - I haven't figured out how to populate things like firmware version, name, etc after the device initialisation. Hoping moving to a Platform model will fix these limitations.

mylesagray commented 5 years ago

@ndlaham all still working okay? If so I will push 0.4.0 to main :)

ndlaham commented 5 years ago

Yep, all good on my end. Siri commands working great too.

I found Siri is a nice alternative to using the slider by just speaking something like, "Set {whatever room} Air Purifier to "Low", "Medium", or "High". Then each power level command corresponds perfectly with the logic you wrote.

mylesagray commented 5 years ago

v0.4.0 merged to master and shipped to npm: https://www.npmjs.com/package/homebridge-blueair

Closing and will use existing platform ticket #1 to track refactor.