robertklep / homebridge-klikaanklikuit

Homebridge plugin for KlikAanKlikUit outlets
15 stars 7 forks source link

Dimmable switch not dimmable in Homekit app #29

Closed deadlyknapsack closed 6 years ago

deadlyknapsack commented 6 years ago

Hi Robert. First of all, amazing work on the plugin. It actually was the reason I decided to automate my home. The combination of the KIKA builtin outlets and Homebridge with Homekit is amazing. I've started on my switches and I'm running into a problem. I have a dimmable switch from KAKU (AWMD-250). I put it in my config.json as dimmable, but I'm not sure what to expect in terms of controls in Homekit? It's basically still a on/off switch (that works).

Am I missing something? I was sort of expecting a slider on my Homekit app.

robertklep commented 6 years ago

Can you show the entry for that particular device from your config.json?

deadlyknapsack commented 6 years ago

Sure. See below. All switches work fine, just no option to dim.

{ "bridge": { "name": "Homebridge", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "031-45-154" },

"description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.",

"accessories": [

],

"platforms" : [{

"platform" : "KlikAanKlikUit", "driver" : { "type" : "rpi", "pin" : 11 }, "accessories" : [ { "name" : "Test Inbouw Outlet", "type" : "Outlet", "address" : 1, "device" : 1 }, { "name" : "Test Outlet Plug", "type" : "Outlet", "address" : 2, "device" : 2 }, { "name" : "Schakelaar", "type" : "Switch", "dimmable" : true, "address" : 3, "device" : 3 } ] }]}

robertklep commented 6 years ago

The "Switch" device type in HomeKit doesn't have a brightness/dim capability. Try making it of type "Lightbulb":

{
"name" : "Schakelaar",
"type" : "Lightbulb",
"dimmable" : true,
"address" : 3,
"device" : 3
}
deadlyknapsack commented 6 years ago

Brilliant! Works like a charm! I guess I was confused about the words "dimmable switch" on the package.

robertklep commented 6 years ago

I completely understand the confusion :)

HomeKit types, like "Lightbulb", "Switch" or "Outlet", have a fixed set of capabilities that they support (perhaps it's possible to add additional capabilities to an existing type, but I don't think I've ever tried). So you have to know exactly which type to use if you want it to support certain capabilities.

Having to use "Lightbulb" for a switch seems counterintuitive, but that's the type that has the brightness/dimming capability that your switch supports.

deadlyknapsack commented 6 years ago

That explains a lot. What about a β€œfan”? I have a central air circulation system. I discovered it basically operates on a few different voltages - per setting. Low = 1 volt, medium is 5 volt, high is 9 volt. I bought a LED dimmer of KAKU (the one going from 0 to 10v), with the idea that I can now control it from within HomeKit. I’m expecting it to show up as a 'lightbulb', because that is the only type that is dimmable. Is there a way to change th icon in HomeKit to a fan? fingers crossed

robertklep commented 6 years ago

A "fan" is defined here: https://github.com/KhaosT/HAP-NodeJS/blob/9eaea6df40811ccc71664a1ab0c13736e759dac7/lib/gen/HomeKitTypes.js#L2885-L2895

It doesn't support the Brightness characteristic so you can't use it directly (as "type" : "Fan") I'm afraid :(

deadlyknapsack commented 6 years ago

Mmm... thanks for the link. That is unfortunate. It is working. I can set the speed, based on the brightness haha. Works beautifully. Is there any way you can think of that I can have it appear as a fan?

deadlyknapsack commented 6 years ago

Is there for example a way to extend your plugin with a "fan" and have a "speed"? I know it's unconventional and potentially an insane amount of work, but it would solve it! πŸ™‚

robertklep commented 6 years ago

It might actually be a really simple change: https://gist.github.com/robertklep/e79120a326a8518c6aded4cb687b4758

If you take that file and replace the original index.js with it, it might work if you set the type (in config.json) to Fan.

deadlyknapsack commented 6 years ago

Wooooow! I'm so excited to try! What is the location for index.js?

EDIT: found it πŸ™‚ Trying now.

deadlyknapsack commented 6 years ago

It works beautifully! You absolutely made my day!

robertklep commented 6 years ago

Cool, nice to know!

deadlyknapsack commented 6 years ago

Thanks!