merdok / homebridge-miot

Homebridge plugin for devices supporting the Xiaomi miot protocol
MIT License
364 stars 62 forks source link

hcho-density property as air quality sensor #529

Closed michaelflux closed 7 months ago

michaelflux commented 9 months ago

Over last couple years Xiaomi has been adding proper HCHO (formaldehyde) to some of their upper end purifiers such as zhimi.airp.sa4 (4 MAX), and zhimi.airp.ua1a (Ultra).

While HomeKit doesn't have a formaldehyde specific category as it does for Carbon Dioxide, Monoxide, Nitrogen, Ozone and Sulphur Dioxide, formaldehyde is a VOC and HomeKit does support HMCharacteristicTypeVolatileOrganicCompoundDensity

While I'm able to pick up the mg/m3 value output of the hcho-density property, it's currently being displayed as lux within the Home app. One small thing to note is that within miot spec the value is in mg/m3 (milligrams) while the expected HomeKit unit is µg/m3 (micrograms).

Are we able to allow for 'native' output of the hcho-density property in HomeKit where it would appear as a TVOC sensor as does Aqara's TVOC unit

Aqara-TVOC-AQI-settings

https://homekitnews.com/2021/07/16/aqara-tvoc-sensor-review/

merdok commented 9 months ago

In theory it should be possible, the propertyMonitor functionality would need to be extended to handle that specific property type correctly. Lux is currently used to display a generic value without any specific processing.

Could you tell me what exact device is it and what is the property id of that, so that I can have a look at the miot spec?

michaelflux commented 9 months ago

In my case I'm using zhimi.airp.sa4 https://home.miot-spec.com/spec/zhimi.airp.sa4 - but same hcho-density property is used on Ultra

{"type":"urn:miot-spec-v2:property:hcho-density:000000B0","description":"HCHO Density","format":"float","access":["read","notify"],"value-range":[0,2,0.01],"unit":"mg/m3"}

https://home.miot-spec.com/spec/zhimi.airp.ua1 https://home.miot-spec.com/spec/zhimi.airp.ua1a

merdok commented 9 months ago

Thanks, will see what I can do!

merdok commented 7 months ago

hi, the HCHO density should now be detected and the air quality sensor should show it as VOC if the device does not report VOC density. propertyMonitor will still show it as lux as this requires some more work, will see if i can also improve that later.

michaelflux commented 6 months ago

hi, the HCHO density should now be detected and the air quality sensor should show it as VOC if the device does not report VOC density. propertyMonitor will still show it as lux as this requires some more work, will see if i can also improve that later.

Works great, thank you. :)