merdok / homebridge-miot

Homebridge plugin for devices supporting the Xiaomi miot protocol
MIT License
391 stars 61 forks source link

Correct value types for Mi air purifier 4 COMPACT #554

Closed mgolubevklg closed 5 months ago

mgolubevklg commented 10 months ago

Hi! Thank you very much for the plugin! May I request some small improvements? I'm using xiaomi.airp.cpa4 When I add Property monitor all values are showing in Luxes instead of RPM, percents and mg/m3 Also fan rpm control slider appears as light dimmer (it works tho) If there is a way to fix it - that would be great! Thank you in advance!

"propertyControl": [
                        {
                            "property": "custom-service:favorite-level",
                            "name": "1fan speed"
                        }
                    ],
                    "propertyMonitor": [
                        {
                            "property": "environment:pm2.5-density",
                            "name": "1PM2.5 Density\t"
                        },
                        {
                            "property": "filter:filter-life-level",
                            "name": "1Filter life"
                        },
                        {
                            "property": "custom-service:motor-speed-rpm",
                            "name": "1RPM"
                        }
Screenshot 2023-12-06 at 03 52 21 Screenshot 2023-12-06 at 03 52 31
merdok commented 10 months ago

Hi,

the thing is that property monitor tries to display any value in a generic way and the only way to display any numeric value in homekit is the light sensor which shows it in the lux unit. Like for example there is no accessory which can display RPM in a tile. The same goes for filter life and pm2.5 density. Although for pm2.5 density an air quality sensor could be used, it would not be shows on the accessory itself. Hence unfortunately the light sensor and lux is the best way to do it in homekit and there is nothing really that i can do to improve it.

The same goes more or less for propertyControl, where controlling of the property can be done in a generic way. The default way to display percentage values is a lightbulb but you can at least change that to a fan the following way:

            {
              "property": "custom-service:favorite-level",
              "name": "1fan speed"
              "config": {
                "type": "fan"
              }
            }

here it is possible as we also have the fan accessory which more or less does the same as a lightbulb so they work interchangeable.

mgolubevklg commented 10 months ago

ok, got it about numeric values can't add config for fan: syntax error i've just copypasted

merdok commented 10 months ago

A comma is missing in my example, just do not copy/paste blindly🤪 Basically this section is needed for your property control:

"config": {
  "type": "fan"
}
mgolubevklg commented 10 months ago

oh, sorry, fixed it thank you for help! also, maybe you can advice what voice command can siri support for such devices? so far I can only turn on/of, fan maximum but can't make her to set fan speed for desired amount or switch modes

merdok commented 10 months ago

you have to enable the mode buttons, give them meaningful names and then just tell siri to enable that button. Fan speed should also work by telling siri to set the fan speed to a specific value.

mgolubevklg commented 10 months ago

I did already it works sometimes, sometimes glitching sleep mode just shut device down instead with siri

merdok commented 10 months ago

Yeah well there is nothing i can do about that. It is all about how you name your switches...