aarons22 / homebridge-bond

Homebridge plugin for Bond
MIT License
63 stars 31 forks source link

Setting to disable bond.api.toggleFan when changing fan from off to a set speed #255

Open Shamus03 opened 9 months ago

Shamus03 commented 9 months ago

Is your feature request related to a problem? Please describe. I have a Hunter ceiling fan. The remote can send the following fan-related signals:

Since there is no button to explicitly set the fan speed to 2, it just works out better to map only the "toggle fan" button to Bond's on/off button, the "set fan speed to 1" signal to Bond's "fan speed 1" button, and the "set fan speed to 3" signal to Bond's "fan speed 2" button - essentially faking Bond out and turning it into a 2-speed fan (I don't really need fan speed 2). This works well when interacting with the fan through Bond, because tapping either fan speed button sends only the command required to set the fan to the desired speed.

My problem: If the fan is off, and I drag the fan speed slider from 0% to 50% in Homekit, the Bond Homebridge plugin actually sends BOTH the "toggle fan" signal AND the "set fan speed to 1" signal. This causes the fan to turn on and then off immediately after, with both Bond and Homekit incorrectly thinking the fan is now at 50% speed. For some reason this problem does not happen when transitioning from off to 100%. So in practice to actually get the fan to go from 0% to 50%, I need to first set it to 100% followed by 50% shortly after.

Describe the solution you'd like I think the best solution in my case is a setting to disable the "toggle fan" command (bond.api.toggleFan) when the fan is currently off and transitioning to a set power level (since sending ONLY the "set fan speed to 1" command is sufficient to turn on the fan). That would cause ONLY the "set fan speed to 1" signal to be transmitted in that case.

Describe alternatives you've considered If my fan had explicit ON/OFF signals I could send it, I think this problem would be fixed. I also considered removing the on/off button in Bond and ONLY creating an "off" button, but that does not end up working well.

Also if Bond was smart enough to understand that to actually get to the "real" fan speed 2, it should send the "fan speed 1" signal, shortly followed by the "increase fan speed" button, I'd actually be able to map all 3 speeds. As mentioned earlier I am happy with just having 2 speeds but if someone has a workaround for this I'd be interested to hear it. I thought perhaps mapping Bond's "set fan speed to 2" signal to a dummy RF signal that does nothing would work, but that causes an issue when transitioning straight from off to fan speed 2 (fan does nothing, Bond now thinks the fan is at speed 2).

Additional context N/A

Shamus03 commented 9 months ago

I think just adding something like if (isCurrentlyOff && disableFanOnSignal) return (where disableFanOnSignal is the setting I am requesting) to this section of the code would work: https://github.com/aarons22/homebridge-bond/blob/17d21f3187a9ff86f872ea058782f601d7d1f122/src/accessories/CeilingFanAccessory.ts#L201

That would cause the bond.api.toggleFan call to be skipped in my specific case.

Alternatively, it would be much more work, but if this plugin could allow you to configure more advanced sequences of signals for specific state transitions, that would allow me to fix my issue AND possibly support other devices with similar issues.

Shamus03 commented 9 months ago

Here is an example of how the Tuya plugin handled this issue: https://github.com/monkeycatdog/homebridge-tuya-platform/blob/develop_1.7.0/ADVANCED_OPTIONS.md#skip-send-onoff-command-when-touching-brightnessspeed-slider

Shamus03 commented 9 months ago

An update on this, I decided to try removing the on/off toggle button within bond and only bind the "off" button. This means clicking the "off" button within the Bond app actually sends the "toggle" signal, but now the Bond Homebridge plugin knows it only needs to send that signal when I actually want to turn the fan OFF. So I have an acceptable workaround, but it would be nice if it worked without the hacky setup.