merdok / homebridge-miot

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

Single tile for Property Control #337

Closed bvalasek closed 1 year ago

bvalasek commented 1 year ago

Hello, I would like to change between values of property within single tile (expected is Light tile, not Switch tile) instead of having multiple tiles with one value. Maybe it is already possible but my programming skills are none.

I have mijia.vacuum.v2 and if I use Property Control for “vacuum:fan-level”property it shows as many tiles as possible Values for that property. In this case 4 values, therefore Homebridge creates 4 new tiles for each option, instead I would like to use 1 tile showed as Light, maybe somewhere I can manually specify range of values from 0-4. This way maybe I could control suction power from single tile. This way I can create separated tile for Water releasing when mopping.

Can we use something like Action Button and we would specify range of values? I have tried to use this property for Action Button, Property Control and Property monitor but none of them result in expected state. I can reach expected result with different plugin but I would like to use this one, because it is more stable. I have red this page and it was not useful for my case https://github.com/merdok/homebridge-miot/blob/main/docs/robotcleaner.md

Screenshot 2022-09-12 at 18 21 13

merdok commented 1 year ago

The problem here is that, how do you display 4 values on a switch which only accepts 2 values(on/off)? Even if would let you to specify that you want to set mode 1 to the ON state and mode 2 to OFF state, then what would the switch display in case when mode 3 is set on the vacuum?
This is unfortunately not an easy to solve problem because HomeKit can only have switches with 2 states.

But there is a way to reduce the number of switches, simply disable modeControl and create yourself switches using the propertyControl. There you can create switches which when turned on will set a specified value, hence you could only add those switches which you really need. Will that work for you?

bvalasek commented 1 year ago

You are right, I assume it cannot be Switch tile but Light or Fan tile. This way there is slider on a tile which can output number and this number changes the property value for "vacuum:fan-level". But it needs to be somehow handled properly because this specific property does not support values from 0-100 but only from 0-4 included (0 means fan is off and 4 is fan is on maximum). In attached video is expected result how it behaves in the other plugin, we can see that the Fan slider is able to do steps of 25, the number is visible on HomeBridge tiles on right side of video.

And to your suggestion to use propertyControl, I have already used it and you can see result in my first comment. Using propertyControl for propert "vacuum:fan-level" it generated 4 new Switch tiles - each one affect dedicated value for the property. What I am trying to reach is to have single Tile for one propertyControl for 4 values.

If it is still unclear do not hesitate to ask more info, If it is too much work just ignore it, I just see that this approach to controlProperty seems more useful in my case and might be useful also for others.

https://user-images.githubusercontent.com/7964597/189893267-05ee6df8-ebc5-433f-9711-406d5c70bb07.mov

merdok commented 1 year ago

You can specify a value in propertyControl which will then generate you a single switch for the specified value. When you not specify a value then it will generate all switches. Please have a look at the example in the README.

As for the slider, it is fine for speed based controls and it is already like that, that the plugin will emulate fan levels with a slider. But that does not make sense for modes since then you do not know what mode is behind the 50% value and what is behind 75%.

bvalasek commented 1 year ago

yep exactly how you said, for modes generally it does not make sense to be controlled with slider but it makes sense for modes which control speed/power in levels (as in my case).

merdok commented 1 year ago

Fan levels are already emulated as a slider if present.

For modes you simply need to use the the propertyControl property and configure it yourself as you wish.

bvalasek commented 1 year ago

perfect but still confused because this property seems like it controls fan speed in levels exactly how you say so is user able to control "vacuum:fan-level" property with slider? If it is possible, can you please show how to adjust config:

"propertyControl": [
                        {
                            "property": "vacuum:fan-level",
                            "name": "Suction Power"
                        }
                    ]
merdok commented 1 year ago

Oh, just realized you have a vacuum. The emulation is only being done on air purifiers, fans and humidifiers since those use that setting extensively. This is kind of rare for vacuums, since they used modes to control that, hence you will not get a slider on vacuum devices.

But yeah, just specify for which value you want to create that switch and it should create a single one, you can do that multiple times for every value that you need. And I assume that you not always use all of the values right?

bvalasek commented 1 year ago

Thats correct, not using all of the values per single vacuuming but definitely from time to time I need all of the values. Having 1 or 2 Switch tiles for most used values are OK solution but not satisfying enough because it is not ready for all of the values. Also having dedicated Switch tiles for all values for Fan on vacuum would mean 4 new tiles, and for Water it would mean 3 tiles. It means users Accessory list bloats bigger for 7 new tiles while there could be only 2 new tiles, thats why I started this issue.

But no worry, I will figure out smtn. Thanks for clarification. You can close this issue.

merdok commented 1 year ago

The biggest issue is here that homekit does not support vacuum accessories or many configuration possibilities, hence we have to do tricks to make all the functionally to work...