itavero / homebridge-z2m

Expose your Zigbee devices to HomeKit with ease, by integrating 🐝 Zigbee2MQTT with 🏠 Homebridge.
https://z2m.dev
Apache License 2.0
312 stars 49 forks source link

[Feature] Expose dimmer switch as Fan #851

Closed ThisIsQasim closed 5 months ago

ThisIsQasim commented 5 months ago

Problem description

I have a dimmable fan connected to a dimmer switch. It works fine but the switch shows up as a Light instead of a Fan.

Suggested solution

I would rather have it displayed as a fan. I believe the homekit v1 Fan can be easily mapped since it only has an on off service and a rotation speed service which can be mapped to the brightness attribute. Do you think it makes sense to add overrides?

Alternative solutions

No response

Additional context / information

No response

itavero commented 5 months ago

I'd recommend using something like homebridge-mqttthing for such customizations.

ThisIsQasim commented 5 months ago

Thanks for the pointer. Do you know if can adjust the range of brightness expose in z2m from 1-255 to 1-100 as expected by HomeKit?

ThisIsQasim commented 5 months ago

I see there is an apply function in mqttthing that should do the trick. Thanks again for the pointer and the awesome plugin. Cheers!

ThisIsQasim commented 5 months ago

For anyone interested, following is the config I ended up using. Works great.

{
    "type": "fan",
    "name": "Fan",
    "url": "mqtt://broker-address:1883",
    "username": "username",
    "password": "password",
    "topics": {
        "getOnline": "zigbee2mqtt/Fan/availability$.state",
        "getOn": "zigbee2mqtt/Fan$.state",
        "setOn": "zigbee2mqtt/Fan/set/state",
        "getRotationSpeed": {
            "topic": "zigbee2mqtt/Fan$.brightness",
            "apply": "return Math.round( message / 2.54 );"
        },
        "setRotationSpeed": {
            "topic": "zigbee2mqtt/Fan/set/brightness",
            "apply": "return Math.round( message * 2.54  );"
        }
    },
    "onlineValue": "online",
    "offlineValue": "offline",
    "onValue": "ON",
    "offValue": "OFF",
    "accessory": "mqttthing"
}

That said I am still using this z2m plugin for everything else so thanks again for the awesome plugin and the amazing support.