merdok / homebridge-miot

Homebridge plugin for devices supporting the Xiaomi miot protocol
MIT License
397 stars 64 forks source link

xiaomi.airc.r24r00 gives invalid value `101` for `Filter Life Level` #614

Closed Willian-Zhang closed 4 months ago

Willian-Zhang commented 4 months ago

Describe the bug xiaomi.airc.r24r00 gives invalid value when no filter is installed.

Expected behavior disable filter field or shows N/A while its not applicable

Debug log

[homebridge-miot] This plugin generated a warning from the characteristic 'Filter Life Level': characteristic was supplied illegal value: number 101 exceeded maximum of 100. See https://homebridge.io/w/JtMGR for more info.

Additional context

this.addPropertyByString('filter:filter-life-level', '{"siid":21,"piid":1,"type":"urn:miot-spec-v2:property:filter-life-level:0000001E:xiaomi-r24r00:1","description":"Filter Life Level","format":"uint8","access":["read","notify"],"unit":"percentage","valueRange":[0,101,1]}');

The range is currently autogenerated, more manual override may be required.

merdok commented 4 months ago

That is kind of odd as we assume that filter life level is a value between 0 and 100%. What the heck does 101% mean for the filter life level?😅 I guess we would need to manually adjust the auto generated class and set the property to 100 max, could you test that out and provide a pull request?

Willian-Zhang commented 4 months ago

What the heck does 101% mean for the filter life level?😅

I think it means "no filter installed"

I guess we would need to manually adjust the auto generated class and set the property to 100 max,

you mean change to "valueRange":[0,100,1]}' ?

I am not sure that's the correct way of doing it, as the raw value 101 would definitely be provided from the device, in my case, no filter is installed.

merdok commented 4 months ago

This is fine in that case, as this is used to generate the ui and validate properties. Changing it too 100 should do the trick. The sliders in homekit anyway cannot go beyond 100% so not even sure how to interpret the 101% value...

Willian-Zhang commented 4 months ago

"valueRange":[0,100,1]}'

tried this, still spitting the exact warning

merdok commented 4 months ago

Then I would need to have a look and handle that in code.

merdok commented 4 months ago

Should be fixed with version 1.7.2