webdeck / homebridge-indigo

Homebridge Plugin for Indigo
Apache License 2.0
13 stars 6 forks source link

Added Missing Treat As Fan Code #25

Open rycardo opened 6 years ago

rycardo commented 6 years ago

It appears the code to support 'treatAsFanIds' was added to this file, but the treatAsFanIds array and the lines to read from the array were not added yet. I added the code to read the treatAsFansId array and the call to create the fan accessories from it.

I also put the example and definition "treatAs..." lines in alphabetical order.

I didn't update the config.json file, as I'm not sure if there is a reason you didn't add the missing code. I'm using fans on a handful of Indigo devices, and in 18 hours I haven't had any issues.

My first pull request to this project, I welcome any feedback.

rycardo commented 6 years ago

Hey - I wondered about that, but I also didn't want to modify your code if it wasn't necessary, and I didn't want to cause actual fan devices to not work correctly. I thought about returning the speed as maximum speed when on (for these treat as devices).

I did add this else if block, which I copied from existing code: } else if (json.typeSupportsOnOff && this.treatAsFanIds && (this.treatAsFanIds.indexOf(String(json.id)) >= 0)) { Does that get around your concern?

webdeck commented 6 years ago

The issue is that Homekit will show a speed control and that won't work - any attempt to get/set the speed will result in the error "Accessory does not support rotation speed".

rycardo commented 6 years ago

I understand what you are saying now. I had only viewed these devices in Home, and they show as a spinning fan on or off, also previous to changing the code, I edited their details in Home, changing them from Switch to Fan. I could turn them on/off in Home, with no speed control, although I very rarely did as they are on schedules.

Now, when I attempt to turn them on/off, I see what you are saying. Let me give it some more thought.