python-miio icon indicating copy to clipboard operation
python-miio copied to clipboard

airpurifiermiot: Xiaomi 3H updating PM2.5 sensor only once in 30mins

Open RazerPC opened this issue 4 years ago • 12 comments

Describe the bug The PM2.5 sensor is updating only once in 30 mins

Version information (please complete the following information):

  • OS: HASSOS
  • python-miio: latest

Device information: If the issue is specific to a device [Use miiocli device --ip <ip address> --token <token> info]:

  • Model: Xiaomi Purifer 3h

To Reproduce Steps to reproduce the behavior:

  1. Use Mio integration

Expected behavior Refresh every X seconds

Hello, i've been told to post this here, the Xiaomi 3h purifier has an issue that consists in the sensor reporting output only once in 30 mins, a user found a solution and i've been told to post it here

Here is there reference

https://community.home-assistant.io/t/lovelace-xiaomi-mi-air-purifier-3h-card/192100/300

https://github.com/home-assistant/core/issues/63250

RazerPC avatar Jan 05 '22 16:01 RazerPC

One potential solution would be calling to set that property with a short time (e.g., 1 seconds) prior to requesting the data. This way the caller of update() would always get the newest data, and the device would not need to keep polling the sensor internally all the time.

rytilahti avatar Jan 05 '22 18:01 rytilahti

Thanks for helping

Could we test this out? I'm not a developer but I'll do what I can

RazerPC avatar Jan 05 '22 19:01 RazerPC

@Razer0123 See the linked PR, you could copy the file over to your local installation and try if miiocli airpurifiermiot status gets an updated value on each call :-)

rytilahti avatar Jan 05 '22 20:01 rytilahti

I will test it over the day and check if it's stable solution.

One strange thing I noticed. aqi-updata-heartbeat is decreased every 5 seconds. For example if we would set 15 seconds and continuously monitor countdown, we will get: 15-10-5-0

If we set 1 second, after 5 seconds API is returning "-4". It looks like device bug, which violates API (minimal value is 0) https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-mb3:1

I didn't notice any problems related to this, but think safer would be usage of multiplicity of 5, so 5 in this case.

mak3 avatar Jan 06 '22 09:01 mak3

Thanks for testing @mak3! I adjusted the PR to use 5 seconds now.

rytilahti avatar Jan 07 '22 15:01 rytilahti

@rytilahti Fix was on testing for over 40 hours with two 3H devices. I applied it in my Home Assistant environment. AQI readings were always accurate.

mak3 avatar Jan 07 '22 18:01 mak3

@mak3 this is with the duration of 1, right? Although I don't think that raising it to 5s changes anything, so I think the PR can be merged now for the next release.

rytilahti avatar Jan 07 '22 19:01 rytilahti

Yes, that was with 1 seconds. I have newest version for few hours, all seems fine.

mak3 avatar Jan 07 '22 22:01 mak3

I want to thank you both, this issue was a pain in the arse

RazerPC avatar Jan 08 '22 01:01 RazerPC

Hello, is this supposed do be fixed in HA 12.9? Because I see no change

RazerPC avatar Jan 12 '22 16:01 RazerPC

Hi, alas, there has been no releases and I'm afraid I'm able to do one first in the beginning of February.

rytilahti avatar Jan 12 '22 21:01 rytilahti

Ok I'll wait, thanks

RazerPC avatar Jan 15 '22 01:01 RazerPC