ztalbot2000 / homebridge-cmd4

CMD4 Plugin for Homebridge - Supports ~All Accessory Types & now all Characteristics too
Apache License 2.0
145 stars 14 forks source link

A choice of display for "Switch" #120

Closed uswong closed 2 years ago

uswong commented 2 years ago

Hi John, I wonder whether you can make several choices of display available for the type "Switch". Currently, if I use the type "Switch", I have no choice in terms what it is displayed. I use the "Switch" to turn on a fan or a light bulb. I know I could use "Fan" or "Lightbulb" type to do so, but in my circumstances, I have to use the type "Switch".

I have an example of Xiaomi switch which made into HomeKit via Aqara Hub, it has options on Home App for us to choose the Switch to be display as "Switch", "Fan" or "Light".

image

uswong commented 2 years ago

Wow John! it is done! I can now see the three choices in your type "Switch" this morning.

image,image

You can see that I have used the type "Switch" for my Aircon Fan and I would like it to be displayed with a Fan symbol.

Thank you so much for your super fast effort.

ztalbot2000 commented 2 years ago

Hi,

I wish I could take the credit, but I did nothing on my end. I was just looking into it now. I can tell you though that there is a Cmd4 directive named "category". It is usually used to set the icon of a Television for instance. When "category" is set, supposedly HomeKit uses this as a clue to which icon to display. In /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Accessory.js you will find a list of all the possible categories starting on line 29. So if you wanted to change the icon, perhaps you can make a switch be a lightbulb.

As for the long press. I think the linked types did that for you and it must have been picked up after a restart. Changing an accessory to a linked type of another accessory probably would require a restart as I do not quite think homebridge is capable of understanding that an accessory changes like that, unless its name changes and a restart is done.

Glad to help though, John

uswong commented 2 years ago

Hi John,

If you have not done anything, then it is really strange! I have a "Switch" with a linkedTypes "Fan" and was unable to change the "Switch" to anything else as there was no option for me. Only after I sent you that enhancement request, the very next morning I found that all the options appear in my "Switch" and I can display the "switch" as a "Fan" or a "Light"! I did not change anything as well within that period of time. Anyway, it is all good for me for that and the info regarding the Cmd4 directive named "category" would come really handy for me.

Thanks again.

Cheers, Ung Sing