merdok / homebridge-miot

Homebridge plugin for devices supporting the Xiaomi miot protocol
MIT License
395 stars 63 forks source link

Air Purifier 2 default fan level #555

Closed MrAnnoymous closed 6 months ago

MrAnnoymous commented 11 months ago

[12/15/2023, 12:09:31 AM] [miot] [Air Purifier 2] Device properties: [ "air-purifier:on", "air-purifier:mode", "environment:relative-humidity", "environment:pm2.5-density", "environment:temperature", "filter:filter-life-level", "filter:filter-used-time", "indicator-light:on", "indicator-light:brightness", "alarm:alarm", "physical-controls-locked:physical-controls-locked", "air-purifier-favorite:favorite-fan-level"

hi, how do i change the default fan level from favorite to auto ?

merdok commented 11 months ago

I am not quite sure what you mean, but probably you want to enable mode control, afterwards you will be able to switch the modes from homekit.

sasojadrovski commented 4 months ago

Hi @merdok,

This is a very valid question and it is also applicable to the Air Purifier 4 — If we have the following configuration for the Purifier:

{
    "name": "Air Purifier",
    "ip": "XXX.XXX.XXX.X",
    "token": "<<token>>",
    "deviceId": "<<deviceId>>",
    "model": "zhimi.airp.mb5a",
    "pollingInterval": 10,
    "deepDebugLog": false,
    "silentLog": false,
    "deviceEnabled": true,
    "onlyMainService": false,
    "buzzerControl": false,
    "ledControl": false,
    "childLockControl": false,
    "modeControl": false,
    "suppressAutoServiceCreation": [
        "illumination"
    ],
    "fanLevelControl": false,
    "screenControl": false // Manually added to JSON based on documentation
}

where the screenControl property was manually added to the JSON config (since there's no toggle in the UI for it), with the intent to remove the controls for the Purifier's screen, otherwise, toggles are added to HomeKit for them.

Once this configuration is applied, and the Air Purifier is turned ON via the Home app, it automatically goes to the "Favorite" mode, and sets the fan's level to highest, which is rather annoying.

Theoretically, this should not happen, and the Air Purifier should turn in the mode it was last in, for example "Auto".

Please note that if we toggle "Show only the main accessory service" to ON in the UI config, this issue does not happen, however we loose other services such as "Temperature", "Humidity" and "Air Quality".

I would appreciate if you could look into this. I am here to provide any additional details, if needed. Thanks!

Cheers, Sasho

merdok commented 4 months ago

@sasojadrovski so you are saying that adding the screenControl property manually to the config is causing this?

sasojadrovski commented 4 months ago

Hi @merdok,

Thank you for your prompt reply! Much appreciated!

Yes, however, I just re-tested, and it might be related to the way the Air Purifier is turned on from the Home app. For example, if the screenControl property is set to false, there's only one actual toggle control you can toggle ON/OFF, and if you tap on the Air Purifier directly on the Home tab in the Home app and with that, turn it ON, it goes to 100% fan speed, and it's mode is set to "Favorite". However, if you enter the Air Purifier's details in the Home app, and turn it on there (by tapping the ON/OFF circular button below the slider), it goes to the mode it was turned off in, for example "Auto". When the screenControl property is set to true, there are more toggle controls you can toggle: one for turning the purifier ON/OFF, and a few more for the screen's brightness, and with this, when you are on the Home tab of the Home app, you cannot directly turn the Air Purifier ON, it always takes you to the details, where you can tap on the ON/OFF circular button, and with that, the issue never happens.

I hope this brings a bit more context to what is happening. Please let me know if you need me to provide more details, or videos/screenshots.

Best regards, Sasho

sasojadrovski commented 4 months ago

Oh, forgot to mention that the issue never happens if the onlyMainService property is set to true, regardless if you toggle the Air Purifier ON/OFF from the Home tab of the Home app, or from the details view. It always turns on "Auto" (which is a different issue, but one that is less annoying than having the fan to 100% each time you turn it on 😄). But in this case we loose all the other goodies like the sensors info.

merdok commented 4 months ago

I guess the issue you are facing is a matter of how the Home app shows the accessory. I do not really have control over that... So i guess when you enable the screenControl then it is simply shown differently...

sasojadrovski commented 4 months ago

The Home app shows the accessory the same way. However, when screenControl is true, you cannot turn on the accessory by tapping on its icon on the Home tab, it always takes you to the details screen, since there's more than one toggle that can be turned on (in this case the other ones are for the screen's brightness).

But, when onlyMainService is set to true, everything works good, even from the Home tab, and the accessory even has more options inside the details screen, such as a segmented control for changing between "Auto" and "Manual", a slider for the fan's speed, etc. And when this property is se to true, the accessory never starts with the fan set to 100%, which is good.

So if there's a way to achieve this behavior when onlyMainService is set to false (because in this case we get sensors data in the Home app, such as for Humidity, Temperature, Air Quality), while having the screenControl property to false, that would be great!

merdok commented 4 months ago

As I already mentioned, I do not have control over how the accessory group will look like in the home app. It depends on what accessories are provided inside the group, as you already noticed. Maybe a solution for you would be to ungroup the accessories which you can do in the home app?