Support for Bond hub

Unfortunately I've run into some new issues with the latest version of the app. I'm seeing these kinds of errors in the logs when setting fan speed. The reference is to line 444 in the code, which looks like where you have some new stuff. I think the error may be in the translateHEFanSpeedToBond function but not sure...

    if (executeAction(bondId, "SetSpeed", translateHEFanSpeedToBond(state.fanProperties[bondId].max_speed ?: 3, speed))) 

Here's what I receive with the IncreaseSpeed command:
curl -H "BOND-Token: xxxxxxxxxxxxxxx" -i http://192.168.1.122/v2/devices/xxxxxxxx/actions/IncreaseSpeed -X PUT -d "{"argument": 2}"
HTTP/1.1 400 Bad Request
Content-Length: 54
Content-Type: application/json; charset=utf-8

{"_error_id":61,"_error_msg":"action not supported"}

....and the DecreaseSpeed(No change to speed.):
curl -H "BOND-Token: xxxxxxxxxxxxxxx" -i http://192.168.1.122/v2/devices/xxxxxxxx/actions/DecreaseSpeed -X PUT -d "{"argument": 1}"
HTTP/1.1 204 No Content
Content-Length: 0

Oddly, I can turn off the fan with TurnOff, but get the same "action not supported" message on the with the TurnOn action.

No delay is needed. The Bond Bridge will queue up to 32 signals, so that you can control several fans at once without worrying about "cutting off" an earlier transmission.

And, kudos for building this, Dan! We've spoken with so many Hubitat users over the last two years, and it is trilling to finally launch integration!

1 Like

Yeah, Bond devices also have this behavior. There's a pair of state variables, "power" and "speed". If "power" is 1, "speed" is the current speed of the fan. If "power" is 0, the fan is off, and "speed" is the last speed seen.

Yeah, looks like you're doing everything right. I'll debug here!

BTW the 204 is the expected success response, something should have been transmitted there.

Removed.

Happy to share. I hope to continue to expand this over time. I want to add more support for other commands like dimmers (need someone to test) and also shades (though that doesn't look documented yet?)

I think I have this fixed now.

1 Like

Thanks for those changes. I think I've run into another issue -- in the two "translate" functions. For example, the function translateHEFanSpeedToBond which returns a speed value (integer) seems to be incorrect. For example, if I select a fan speed of "low" the translate function returns a speed value of 0 when it should be 1 instead.

Earlier today to get it working I modified the arrays in the two functions to include "off" (which would return a 0 value for speed). Anyway, I'm not sure if this is the best way to fix this but here is a copy of the changes I made. Feel free to use or modify as you see fit.

def twoSpeeds = ["off", "low", "high"]
def threeSpeeds = ["off", "low", "medium", "high"]
def fourSpeeds = ["off", "low", "medium-low", "medium", "high"]
def fiveSpeeds = ["off", "low", "medium-low", "medium", "medium-high", "high"]

Good catch. I decided to modify the array indices instead. I want to actually redo this part so that even if you have a 3 speed fan if you choose medium-low I want it to still work but just set it to medium. Just haven't had time to recode that yet.

1 Like

Ah, I see what you did there in the code, a better implementation than mine I think! Thanks again, can't tell you how much I appreciate you stepping up and building this app and drivers for the Bond integration! :+1:

Glad you find it useful! I'm building a bunch of different integrations I need for my own use (Bond and Ring are done so far, working on Kevo+, Kohler DTV, and plan to add Petnet, Litter Robot, and Roomba. I figure if I'm building it for myself, might as well share. Also you get some great community enhancements, I've already had a few enhancements submitted to my Ring integration!

1 Like

Sorry, a couple more code tweaks, based on my testing this evening of the ceiling fans. FYI the two scenarios as described below are consistent with what happens with my Lutron Fan Control devices.

I added two new lines of code, both in the BOND app. New code is shown with **

Definitely double-check my logic(!) to make sure I'm not breaking something but this seems to work well in my testing...

Scenario 1 -- if the fan is currently Off (switch Off, fan speed Off) and then selecting a fan speed (Low, Medium, High, etc.) the "switch" parameter also needs to be automatically updated to show "On"

New code in def handleFanSpeed

    if (executeAction(bondId, "SetSpeed", translateHEFanSpeedToBond(state.fanProperties?.getAt(bondId)?.max_speed ?: 3, speed))) 
	{
		**device.sendEvent(name: "switch", value: "on")**
		device.sendEvent(name: "speed", value: speed)
	}

Scenario 2 -- if the fan is currently On and then the switch is turned Off the fan speed value also needs to be automatically updated to show "Off"

New code in def handleOff

	if (executeAction(bondId, "TurnOff") && shouldSendEvent(bondId)) 
	{
		device.sendEvent(name: "switch", value: "off")
		**device.sendEvent(name: "speed", value: "off")**
        
		return true
	}

That makes sense. I changed one thing on the off part though because handleOff is also used for fireplaces so I added a check to make sure it's a fan and not a fireplace before sending the speed off.

Good deal! I think this is coming together well.

I will continue to test and see how this new Bond integration works with several of my RM 4 rules which automate the ceiling fans (a combination of Lutron Fan Controls and now my two remote control based Emerson ceiling fans which are Bond enabled)...

One more! Then I'm walking away from this for the evening... (annoyed wife factor is emerging)

In the Bond Fan device driver, in the defSpeed function, I think there needs to be some logic when setting the lastSpeed value. I don't think it needs to save On or Off values, only the actual fan speeds (Low, Medium, High, etc.)

Something like this perhaps, or similar...

if (speed != "off" && speed != "on")
{
    state.lastSpeed = speed
}
1 Like

Yeah seems I've fallen behind in documentation of features. I'll get the Open/Close feature (that shades and any other "Openable" use) and the FpFan feature documented today for you. Oh, yeah it seems Dimmers aren't documented either! I'll get that one as well. It's a simple one for most fans: the start action is "StartDimmer", the stop action is "Stop". ("Stop" can also be used to stop any in-progress transmission)

Now that the basic on/off and fan speed adjustment is working with the Bond integration I would definitely be very interested in testing some of these additional features, once they are implemented.

My two Emerson ceiling fans have up (top) and down (bottom) lights, dimmers and fan direction/reverse...

1 Like

I think this functionality might need to be preserved somewhat -- at least in my case. I have a Breezemore fan from home depot that has its own internal memory and remembers its last speed state before you turned it off. It will even recall it if you flip the switch off.

These are nice fans by the way, they use a DC motor and don't have any pull chains, totally dead silent save for the sound of air moving, and they move a LOT of air.

I'm not sure if this is just the app or what, but I don't know if bond even has the correct speeds available for every fan. My Breezemore fan has 9 speeds according to Home Depot and the included manual, but the Bond app only shows 6 speeds.

I hope to get back to working on this next weekend. I needed to get an integration built for my Petnet pet feeder first

1 Like

No rush, the integration in its current form is working well for me! So far I haven't found any need for code changes. When you have time to tackle some of the other stuff (fan direction and up/down lights in particular) just let me know and I will be glad to test...