RobertD502 / home-assistant-iocare

Home Assistant custom component for monitoring and controlling Coway Airmega Purifiers
MIT License
50 stars 8 forks source link

Add PM2.5 support for IconS devices #26

Closed yostinso closed 1 year ago

yostinso commented 1 year ago

IconS devices don't report AQI or PM10, but do report PM2.5 both on the device's display and via the API. Add a new sensor for PM2.5.

Also make sure we clamp the values for both PM10 and PM2.5 to 0 instead of empty string -- that squelches a lot of HASS complaints because sensors of type "measurement" need to be numeric. In order to reflect that 0 isn't a real measurement, mark the sensors as unavailable when the reported value(s) are empty strings.

Finally, bump version to 0.3.0.

RobertD502 commented 1 year ago

Hi, could you please provide an example of Home Assistant complaining? This has not been an issue before as the PM10 is never returning an empty string - it already returns 0.

Example from a 300S:

"IAQ":[{"co2":"0","inairquality":"20","humidity":"","dustpm25":"0","temperature":"","dustpm10":"0","dustpm1":"","vocs":"0","rpm":""}]

Also, you mention the IconS doesn't report the AQI - is the AQI sensor currently being created for your purifier in HA?

yostinso commented 1 year ago

Okay, I can take a look at making the change to choose sensors based on product model and the logger changes

RobertD502 commented 1 year ago

Okay, I can take a look at making the change to choose sensors based on product model and the logger changes

If you can provide me with the debug of your purifier, I can make the appropriate changes regarding making sure the AQI and PM10 sensors aren't being added for IconS purifiers and having the PM25 only be added for IconS purifiers.

Edit: Based on the IconS product page, the app shows a PM10 reading...does the API never return a PM10 reading?

yostinso commented 1 year ago

@RobertD502 Do you have a collection of values from the device_attr['product_name'] field as a starting point?

I don't, but if you have the output for the product_name_full for the IconS, I can use that.

yostinso commented 1 year ago

This is an example info from the IconS:

CowayPurifier(
device_attr={
  'device_id': '15902FJ322C0700027',
  'model': 'AP-1022K(US-701207)',
  'name': 'IconS MB',
  'product_name': 'AIRMEGA_ICONS',
  'product_name_full': '미주향 아이콘청정기',
  'device_type': '004',
  'device_brand': 'MG',
  'device_seq': 999397
},
mcu_version='V1.0.0.1',
network_status=True,
is_on=False,
auto_mode=False,
auto_eco_mode=False,
eco_mode=False,
night_mode=False,
fan_speed='99',
light_on=False,
timer='0',
timer_remaining='0',
pre_filter_name='극세사망 프리필터',
pre_filter_pct=86,
pre_filter_last_changed='',
pre_filter_change_months='2',
max2_name='Max2 필터',
max2_pct=100,
max2_last_changed='',
max2_change_months='12',
dust_pollution='0',
air_volume='99',
pollen_mode='0',
particulate_matter_2_5='1',
particulate_matter_10='',
carbon_dioxide='',
volatile_organic_compounds='',
air_quality_index='',
pre_filter_change_frequency=3,
smart_mode_sensitivity=2)
yostinso commented 1 year ago

And this is with it turned on and running

CowayPurifier(
device_attr={
  'device_id': '15902FJ322C0700027',
  'model': 'AP-1022K(US-701207)',
  'name': 'IconS MB',
  'product_name': 'AIRMEGA_ICONS',
  'product_name_full': '미주향 아이콘청정기',
  'device_type': '004',
  'device_brand': 'MG',
  'device_seq': 999397
},
mcu_version='V1.0.0.1',
network_status=True,
is_on=True,
auto_mode=True,
auto_eco_mode=False,
eco_mode=False,
night_mode=False,
fan_speed='1',
light_on=False,
timer='0',
timer_remaining='0',
pre_filter_name='극세사망 프리필터',
pre_filter_pct=86,
pre_filter_last_changed='',
pre_filter_change_months='2',
max2_name='Max2 필터',
max2_pct=100,
max2_last_changed='',
max2_change_months='12',
dust_pollution='0',
air_volume='1',
pollen_mode='0',
particulate_matter_2_5='3',
particulate_matter_10='',
carbon_dioxide='',
volatile_organic_compounds='',
air_quality_index='',
pre_filter_change_frequency=3,
smart_mode_sensitivity=2
)
RobertD502 commented 1 year ago
  1. It looks like you have an MCU version so the check isn't necessary for the AQI sensor since it isn't being added for your purifier. Done.
  2. In your case, I can use the product name instead of the full name since it seems there is no distinction in color (The airmega 300 is listed as Airmega 300S while for the 400S the color is appended). I'll use this to not add the PM10 sensor for your purifier and to only add the PM2.5 sensor for IconS purifiers. Done.
  3. I do see that your dust_pollution key has a value of 0 which the 300s and 400s doesn't have (only has 1,2,3,4). In this case I'll need for you to simulate the different air quality levels and find the corresponding dust_pollution value if we are going to have the IconS include the Indoor air quality sensor - If you can take a screenshot of the Report tab in the mobile app, that may give me a clue as to what levels there are.
yostinso commented 1 year ago

Just blew some smoke at the sensor. Even with PM2.5 = 49 which is an AQI of 134, the dust_pollution field is still '0' so I think it needs to be moved into the not-IconS section

RobertD502 commented 1 year ago

Just blew some smoke at the sensor. Even with PM2.5 = 49 which is an AQI of 134, the dust_pollution field is still '0' so I think it probably needs to be a check for mcu_version and also not IconS

Good to know. I'll add it to the matching as I haven't had any reports of it not being available for purifiers that have a MCU version. If it turns out to be the case, then I'll move it to the MCU version check portion.

yostinso commented 1 year ago

Thanks!