dcmeglio / hubitat-bond

BOND Home Integration for Hubitat
32 stars 20 forks source link

Feature Request #12

Open jvmahon opened 4 years ago

jvmahon commented 4 years ago

I have a feature request for the "Fan" part of your plugin.

This request concerns integration of Fans with Homekit. I have authored one of the homebridge plugins that can integrate HomeKit and Hubify. See https://www.npmjs.com/package/homebridge-hubitat

In HomeKit, Fan speed is controlled by a percentage slider (0-100%). The Hubitat FanControl capability used in your Bond drivers, however, only uses a few labeled values (i.e., the FanControl values, low, medium-low, medium, medium-high, high).

Many Hubitat fan drivers also add a percentage control using the SwitchLevel Capability. In these drivers, the low, medium low, medium gets mapped to a level (e.g., on a 3 speed fan, if the driver receives 1-33, it sets "low", 34-66 it sets "medium", 67-100, it sets "High").

Can this SwitchLevel ability be added to your code / drivers to also allow control based on a percentage value - my goal is to allow integration between Fans created in Hubitat using your Bond drivers and Homebridge.

Looking at the Bond V2 API, I understand that the API will report a max_speed value indicating the highest supported value. It seems the basic logic for setting values would be straightforward along the lines of . . .

When new speed value is reported by Bond, Set Switch Level to: Math.round( (Bond_speed_value) * (100 / max_speed)).

When a new Switch Level (0-100%) is received at Hubitat, send to Bond the speed: Math.ceil( (SwitchLevel) / (100 / max_speed))

So, for example, if you have a 5 speed fan, and you receive a SwitchLevel value of 15 at the Hubitat User interface, you would send Bond the value: New Value to Bond = (Math.ceil (15 / (100/5) ) = 1 (to keep the "FanControl" capability synchronized, you'd also want to set the FanControl to "low")

While SwitchLevel of 21 would result in: New Value to Bond = Math.ceil ( 21/ (100/5)) = 2 (to keep the "FanControl" capability synchronized, you'd also want to set the "FanControl" value on Hubitat to "medium-low").

Obviously, if FanControl were being changed instead, you'd have to similarly keep the SwitchLevel synchronized, but that seems a bit simpler -- e.g., Off = 0, Low = 20, medium low = 40, medium = 60, medium high = 80, high = 100.

I note that the Hubitat "Generic Fan Component" driver already implements a "SwitchLevel" capability as well as the "FanControl" so perhaps that could be used as the basic component driver to do this (obviously, that doesn't support lighting, but it appears that others handle fans with lighting using a parent device which has the Fan and the light as separate child components).

I'd appreciate you giving this some thought. Thanks.

dcmeglio commented 4 years ago

I will add this, but not until HE fixes a current bug that causes alexa issues when a device support fan control and switch level. They should have it fixed in the 2.2.4 firmware so then I'll get this done.

jvmahon commented 4 years ago

Thanks. Ideally, I'd like to see Hubitat add a dedicated "FanLevel" Capability and a "FanDirection" attribute, but I'm waiting until 2.2.4 is done to propose that.

dcmeglio commented 4 years ago

They mentioned that they are looking to add more capabilities in 2.2.5 so you might want to suggest it now to (possibly) see it in 2.2.5!

jvmahon commented 4 years ago

Where did you see that mentioned? I'd like to respond.

dcmeglio commented 4 years ago

https://community.hubitat.com/t/capability-request-water-flow-rate/24878/37