aijayadams / hass-blueair

BlueAir sensor integration for HomeAssistant
34 stars 15 forks source link

Doesn't support AWS IoT Core backed models (HealthProtect Series) #9

Open uprisingchuns opened 2 years ago

uprisingchuns commented 2 years ago

just tried the integration and no devices/entities showed up.

aijayadams commented 2 years ago

I don't know what that looks like in the BlueAir API, could you send an example of it?

labactani commented 2 years ago

Hi @aijayadams , I am interested in this as well - if you guide me on how to read the API, I will be happy to share mine (Health Protect 7440i)

aijayadams commented 2 years ago

Hi @labactani, thanks for offering to get us some data from this model. Hopefully it's not super different to the i models that a couple of us who initially built this integration have. I'm not sure how familiar you are with python, but with just a little setup you should be able to use the code we have here to connect to your blueair account and see how your Health Protect is represented.

First we need to get a copy of this repository downloaded some where, and you can load the code we use to talk with the blueair API using a process something like the below.

# Download the repository 
git clone git@github.com:aijayadams/hass-blueair.git

# Change into the right directory so we can import the module
cd hass-blueair/custom_components/blueair

# Setup a python venv so that we don't leave any mess in your system python packages (If you're on windows this is a little different, but still easy,  just google it)
python3 -m venv get_responses
source get_responses/bin/activate

# Install the dependencies we need
pip3 install requests typing_extensions ipython

# Start ipython shell
ipython

If all is well you should have a new prompt that looks like

In [1]:

From here we can import the blueair client, connect and run some commands to learn how your device is represented. The important thing to notice is the UUID from the get_device() call is used in subsequent calls to get_attributes(), get_info() and api_call().

If you can get the response from these calls for your unit as I've shown for mine below that would be most helpful. It's entirely possible that they won't all work, but as long as it shows up in get_devices() we should have something to go on!

In [1]: import blueair

In [2]: client = blueair.BlueAir("USERNAME", "PASSWORD")

In [3]: client.get_devices()

Out[3]:
[{'uuid': '2507776F07C0BCA2',
  'userId': 164005,
  'mac': '34EAE728960E',
  'name': 'Living Room'},
 {'uuid': '2D05576D4DC09CB2',
  'userId': 164005,
  'mac': '98D863E32A86',
  'name': 'Office'},
 {'uuid': '2D0A776FD0D0BEC2',
  'userId': 164005,
  'mac': '34EAE7475BC8',
  'name': 'Bedroom'}]

In [4]: client.get_attributes("2D05576D4DC09CB2")
Out[4]:
{'brightness': '4',
 'child_lock': '0',
 'fan_speed': '2',
 'fan_usage': '0;0;880;0;880;50960',
 'filterType': 'row',
 'filter_status': 'OK',
 'mode': 'manual',
 'wifi_status': '1'}

In [5]: client.api_call(f"device/2D05576D4DC09CB2/datapoint/0/last/0/")
Out[5]:
{'uuid': '2D05576D4DC09CB2',
 'start': 1652241985,
 'end': 1652241985,
 'sensors': ['time',
  'pm',
  'pm1',
  'pm10',
  'voc',
  'co2',
  'tmp',
  'hum',
  'allpollu'],
 'units': ['s', 'ugm3', 'ugm3', 'ugm3', 'ppb', 'ppm', 'C', 'pc', '%'],
 'datapoints': [[1652241985,
   0.0,
   0.0,
   0.0,
   152,
   440,
   20.097,
   42.394,
   3.857143]]}

In [6]: client.get_info("2D05576D4DC09CB2")
Out[6]:
{'uuid': '2D05576D4DC09CB2',
 'name': 'Office',
 'timezone': 'America/Denver',
 'compatibility': 'classic_280i',
 'model': '1.0.9',
 'mac': '98D863E32A86',
 'firmware': '1.1.38',
 'mcuFirmware': '1.0.35',
 'wlanDriver': 'V10',
 'lastSyncDate': 1652242147,
 'installationDate': 1600350827,
 'lastCalibrationDate': 1600350827,
 'initUsagePeriod': 45825525,
 'rebootPeriod': 10811,
 'aimSerialNumber': 'S194600016717',
 'aimUpdateDate': 1600350827,
 'roomLocation': 'kitchen'}
labactani commented 2 years ago

no super skilled with python honestly, but I can give it a try. 2 questions (which will tell you already how inexperienced with python I am :-)

  1. Do I use those commands from the RPi4 I have HA on, or I can use my Mac laptop? I guess it is the same
  2. when I to download the repository, I get the following error: `Cloning into 'hass-blueair'... git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.`

aijayadams commented 2 years ago

The set of commands I gave you should work just fine on your Mac assuming you are running a recent macOS.

Don't worry about not being too familiar with python - it gives fairly human errors most of the time, and it's the error I'm looking for ;)

Now that error you shared is more about ssh keys and GitHub, but since there is no need for you to push any code back to the repository we can just clone with https and skip that part.

Use this command in place of what I shared above to clone the repo, the rest will still work.

git clone https://github.com/aijayadams/hass-blueair.git
labactani commented 2 years ago

So this works now, thanks issue I am facing now is that when I input client.get_devices(), I get an empty list... Out[3]: []

It is like it cannot see my device...

I have checked and I can properly login, in fact when I pass a wrong password I get auth error.

Any idea?

aijayadams commented 2 years ago

Hmm, ok, well if they aren't returning the HealthProtect devices from that endpoint it definitely explains why the integration doesn't surface their data. Could I ask you to confirm that when you use the BlueAir app on your phone the device does show up? If so, I'll try searching through the latest app bundle and see if I can find paths that might be alternate API endpoints they are using for Health series devices.

labactani commented 2 years ago

Yes the product shows properly in the app. Here some screenshots: [Image.jpeg][Image.jpeg]


Da: Aijay Adams @.> Inviato: Wednesday, May 11, 2022 6:05:11 PM A: aijayadams/hass-blueair @.> Cc: labactani @.>; Mention @.> Oggetto: Re: [aijayadams/hass-blueair] doesn't work with HealthProtect 7710i (Issue #9)

Hmm, ok, well if they aren't returning the HealthProtect devices from that endpoint it definitely explains why the integration doesn't surface their data. Could I ask you to confirm that when you use the BlueAir app on your phone the device does show up? If so, I'll try searching through the latest app bundle and see if I can find paths that might be alternate API endpoints they are using for Health series devices.

— Reply to this email directly, view it on GitHubhttps://github.com/aijayadams/hass-blueair/issues/9#issuecomment-1123969455, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ATIRNLPWA326CPB4LPLNGUDVJPLDPANCNFSM5KXN3ZEA. You are receiving this because you were mentioned.Message ID: @.***>

aijayadams commented 2 years ago

So I took a quick look, and I see a bunch of stuff in that app that looks like it's talking to AWS IoT service. This seems to indicate that BlueAir have moved away from their classic rest'ish API and towards an MQTT style API for control and data. This doesn't mean that we can't add support, but it's a pretty dramatic change and it's definitely not something I'm likely to be able to do quickly.

Thank you for trying this out for me, but I'm afraid unless someone with the time to work out how to impersonate their app to this new backend has a bunch of time (or BlueAir decide to publish docs :P hahaha) this is more of a wishlist feature.

[edit] fjs21/homebridge-blueair seem to have already done the heavy lifting in the last few weeks of adding this support. We should probably use their implementation.

labactani commented 2 years ago

Indeed i found this online https://aws.amazon.com/it/solutions/case-studies/blueair-iot-case-study/

Also, not sure if it can be somehow of help, this plug in for homebridge that seems to support the new AWS API https://github.com/fjs21/homebridge-blueair

leo


Da: Aijay Adams @.> Inviato: Wednesday, May 11, 2022 7:01:36 PM A: aijayadams/hass-blueair @.> Cc: labactani @.>; Mention @.> Oggetto: Re: [aijayadams/hass-blueair] doesn't work with HealthProtect 7710i (Issue #9)

So I took a quick look, and I see a bunch of stuff in that app that looks like it's talking to AWS IoT service. This seems to indicate that BlueAir have moved away from their classic rest'ish API and towards an MQTT style API for control and data. This doesn't mean that we can't add support, but it's a pretty dramatic change and it's definitely not something I'm likely to be able to do quickly.

Thank you for trying this out for me, but I'm afraid unless someone with the time to work out how to impersonate their app to this new backend has a bunch of time (or BlueAir decide to publish docs :P hahaha) this is more of a wishlist feature.

— Reply to this email directly, view it on GitHubhttps://github.com/aijayadams/hass-blueair/issues/9#issuecomment-1124022380, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ATIRNLPPMWRWGHA4CPCYCG3VJPRXBANCNFSM5KXN3ZEA. You are receiving this because you were mentioned.Message ID: @.***>

aijayadams commented 2 years ago

Thanks! Oh wow - they published a full white paper but didn't give a public API doc. So kind of them.

I saw that the folks over in fjs21/homebridge-blueair have been working on adding support. It is definitely a huge head start, but it's still not the trivial change I was secretly hoping for with the HealthProtect series. At best I might have time to sit down and look at adding it over the weekend, but that's optimistic.

jctull commented 2 years ago

I am guessing that better things came up that weekend ;-). Any idea if support for these models is likely to make it into the codebase? Wish I could help, but I do not have the skills. TIA

dahlb commented 2 years ago

I ported the above referenced homebridge to python and verified the basics using the stub file in https://github.com/dahlb/blueair_api feel free to port or fork, I'm posting here because this thread was helpful documentation in my efforts

rremmelts commented 2 years ago

Also looking forward to have this integration working with the blueair 7770i 😀