dxdc/homebridge-blinds

Support for SetPosition from Bond Pro bridge

Closed this issue · 25 comments

Fofer commented

The Bond Pro bridge has slider control for Somfy shades, which even Somfy's own "myLink" and "Tahoma" hubs don't offer. It allows you to pick precise position, as opposed to merely up/down/preset. However it requires the Bond Pro bridge, and only works from the Bond app. This functionality unfortunately doesn't extend to Homekit with the homebridge-bond plug-in, as discussed here: aarons22/homebridge-bond#158 (comment)

I'm wondering homebridge-blinds could support it? This extra functionality would justify the upgrade price to the Bond Pro bridge, at least for folks with lots of compatible shades. Thanks for the consideration.

dxdc commented

@Fofer -- I don't have a Bond Pro bridge, but if it's accessible via the API, it's very possible it could work. I would need some example commands to trial it.

From their docs, it looks like it could work like this:
http://docs-local.appbond.com/#section/Features/Position

In this case, maybe something like this would work:

"up_url": "http://1.2.3.4/v2/devices/<deviceId>/actions/SetPosition(%%POS%%)", 

Or, perhaps it's called one of these ways:

"up_url": "http://1.2.3.4/v2/devices/<deviceId>/actions/Position/%%POS%%", 
"up_url": "http://1.2.3.4/v2/devices/<deviceId>/actions/SetPosition/%%POS%%", 

There may be some other tweaks needed, but there are a number of ways to tune the position here: https://github.com/dxdc/homebridge-blinds#sending-specificexact-position-optional

dxdc commented

@Fofer I just read some more over the API docs. I think something like the following will work.

The only unfortunate part is that I don't think Bond transmits the current position state of the blinds... so there's not a convenient way to 'sync' it up.

{
    "accessory": "BlindsHTTP",
    "name": "Dining Room Shades",
    "up_url": {
        "url": "http://1.2.3.4/v2/devices/<deviceId>/actions/SetPosition",
        "body": "{\"argument\": %%POS%%}",
        "headers": {
            "BOND-Token": "<BondToken>"
        },
        "method": "PUT"
    },
    "down_url": {
        "url": "http://1.2.3.4/v2/devices/<deviceId>/actions/SetPosition",
        "body": "{\"argument\": %%POS%%}",
        "headers": {
            "BOND-Token": "<BondToken>"
        },
        "method": "PUT"
    },
    "stop_url": {
        "url": "http://1.2.3.4/v2/devices/<deviceId>/actions/Hold",
        "body": "{}",
        "headers": {
            "BOND-Token": "<BondToken>"
        },
        "method": "PUT"
    },
    "success_codes": [204],
    "motion_time": 11000,
    "response_lag": 1000,
    "trigger_stop_at_boundaries": false
}
Fofer commented

Thanks for the reply and insight, this is a very interesting development for those of us with compatible blinds.

@Fofer -- I don't have a Bond Pro bridge...

I don't have one either.... yet... this would be justification for me to get one (even though it's almost 4x the cost of the regular Bond bridge!)

@MattGeale has one though, his thread in the homebridge-bond github page is what got me investigating. Perhaps he can chime in with more details...

The reason im using the Bond bridge is because my blinds aren't HTTP blinds in the slightest. Somfy being somfy want to keep everything basically as an RTS blast. The pro was chosen because of the fact it offered SetPosition. As far as I'm aware, I can't do anything like what is above in terms of syncing , successcodes etc because my blinds aren't aware of where they are. The remote says "go down/up/stop" theres no communication back from the blinds to report teh status. Unless I'm missing something with the above.

dxdc commented

@MattGeale I suspect you can do all of those things via the Bond API. Bond exposes all these features via HTTP.

I agree with you that Bond may not store the position in an accessible manner.

I also built some 'psuedo' tracking of blind position using time into this plugin, meaning, if it takes 10 seconds for the blinds to move up to down, we can estimate 1 second to move 10%, and then send the stop command after 1 second if we requested 90% for example. To some degree, SetPosition is doing something similar I suspect although their methods are different.

@dxdc yeah your 'pseudo' tracking is exactly how the Bond guys run it in their native app, but they're working on bringing it into the Homebridge solution. Re the Bond may not store the position, I don't think the Bond actually handles that - since my blinds don't operate via HTTP but via RTS, they only accept RTS commands regardless of how they're getting them (it could be from a ras Pi with an RTS transmitter as an eg). As such, they don't send communication signals back and forth to the Bond API saying they're closing or opening. I cant speak for Bond whether they do get communicable information from the blinds but I know that based on the logs and my brief discussion with Somfy, the model of blinds I have only accept and transmit open, close and My (stop) commands. They excluded that out for their fancier Tahoma range (which isn't available in Australia); ironcially Tahoma is Homekit compatible out of the box.

dxdc commented

they're working on bringing it into the Homebridge solution

I've already brought it into the HB solution with this plugin using Bond, which has been working for some time. The only thing I can't test on my end is the SetPosition command b/c I don't have a bridge.

Hold please - ill dl yours and have a crack at setting it up ;)

dxdc commented

Sure thing.

You can find general Bond config instructions here: https://github.com/dxdc/homebridge-blinds#bond

If you scroll up, I took a crack modifying it to use the SetPosition API, but I don't have a way to test it.

Ok, I think I got it setup per your config, but for some reason, HTTP Method is only allowing GET - If you want to discuss on Discord for faster responses, my contact is Matt#8119 (fixed discord tag)

Likely set something up wrong.

Cheers

dxdc commented

Bond Pro is fully working thanks to @MattGeale's beta testing efforts. Was a little tricky because - in addition to limited documentation - also the 0-100 conventions between Bond and HK are exactly reversed.

Instructions and sample config for Bond Pro here:

https://github.com/dxdc/homebridge-blinds#bond-bridge-pro-configuration

Fofer commented

@MattGeale wrote:

ironcially Tahoma is Homekit compatible out of the box.

Somfy's offerings are so confusing. I tried a couple of other bridges before landing on the Bond bridge. This TaHoma Gateway worked similarly to Somfy's "myLink" bridge, but also had no HomeKit. This TaHoma allegedly includes HomeKit, but isn't available in the US. At least, I couldn't find it anywhere.

@dxdc wrote:

Bond Pro is fully working thanks to @MattGeale's beta testing efforts.

Wow, thanks so much, to both of you, for working this out so quickly. I just placed an order for a Bond Pro bridge. I'll be switching over to homebridge-blinds when it arrives. I look forward to the upgrade! Very much appreciated!

Honestly the whole reason I even found Bond Bridge was because of how shit Somfy's proprietary hubs are...honestly, they're an embarassment and they do nothing about it. If I could get lutron blinds here in Australia, I'd be 100% on the lutron train, but for what Somfy are, they do a good enough job. And especially thanks to @dxdc for this - working a treat!

Its kind of hilarous how you say that Tahoma isnt sold in the US; by the looks of it, it isn't sold anywhere. I contacted Somfy Australia (where I am) and they said that Tahoma was only available in the US; I'm beginning to think Tahoma never existed.

Fofer commented

Same boat here! Also was surprised that the Bond bridge was less than half the price of Somfy's own offerings... and handled a lot more than just shades, blinds and drapes. That said, I love my Lutron lights, but also have a budget so couldn't justify the cost of Lutron blinds around my house. Instead I went with Somfy, and was making do with the regular Bond bridge, just a little bummed by the lack of precision, disappointed to only have up/down/preset. With the Bond Pro though, and @dxdc's great work on this plugin, it feels like I'll be getting a big upgrade and all the functionality I wanted at a fraction of the cost. This development has made my night, it was very fun to watch the pieces fall into place. Thanks again to the both of you.

Yep wouldn't have been possible with @dxdc. Truely a legend. He and I spent about 4hrs on Discord trying various things and with SetPosition now in full swing, you'll be able to have it too on the Pro! I've just spent about 20min rolling out his version to the rest of the blinds and they all work an absolute treat!

dxdc commented

Thanks for the support!

Btw, @Fofer, before the Bond Bridge Pro arrives, you can still use the "classic" Bond configuration here if you like: https://github.com/dxdc/homebridge-blinds#bond-configuration.

@MattGeale would have to chime in here, but I think Bond's algorithm is quite similar to the one I used in this plugin. So you can still it to control your blinds in advance of the Pro's arrival.

The advantages of the Pro appear to be:

  1. The algorithm may go to the closest point (fully up or down), and then reverse it after that, in order to get a more accurate percentage. This is actually a doable feature upgrade to the existing plugin if people feel like that's helpful.
  2. Network latency is no longer a variable, since Bond is timing the opening and closing times directly.
  3. You can alter the position in either the Bond app or the HK app and they will cross-sync.

This seems like it could be particularly helpful when using blind "groups". In lieu of groups, I just configured another channel on my blinds remote and set it to operate >1 blind. While I don't have tracking in this case for the individual blinds, I really have a need to operate them independently.

  1. Bond Pro has native support for more blind types, like Rollease Acmeda.

In short, if you plan to use both the Bond app + HK app, I think the Pro is the way to go, but I'm not sure what the advantage would be of the Pro exactly if you only plan to use the HK app.

That all being said, as I was telling @MattGeale, any vision of multiple blinds being set to equal heights when set to a % open is not realistic. That is because:

  1. The blind motor battery will have a different speed depending on its charged%. This is probably the most significant reason, though I suspect less significant if the solar chargers are installed and have good sun exposure.
  2. Network / Rf signal delays are real and hard to perfectly account for.
  3. The up to down time is different than the down to up time due to effect of going against gravity.
  4. Blinds need to be exactly calibrated at the top and bottom to avoid extra slack. Otherwise the first n seconds of movement is just held up in picking up that slack and affects the estimated % open. This can be tested by choosing 3% open for example.
  5. Window openings are very slightly different in homes (even on "identical" windows), which is why installers have to be very careful when measuring and ordering. This affects the overall weight of the blinds, the installed height, and ultimately, motor performance.

For the above reasons, you can get multiple blinds to be close, but not exact. I'm sure there is a way it could be done using LIDAR or some other position sensor but before spending that money, it's probably cheaper to just switch to a motor that has native position detection like Rollease Acmeda.

Fofer commented

Btw, @Fofer, before the Bond Bridge Pro arrives

Thanks so much, I've learned so much from this thread and I'm glad the SetPosition request summoned MattGeale here to pave the way for this tighter integration with the Bond Pro bridge. I appreciate your detailed explanation, it makes total sense. We considered it carefully and do use the Bond app, and Alexa, as well as the HK app, so cross-syncing was our ultimate goal. The Pro bridge arrived from eBay and we got it set up and running.

I'll confess I'm having some difficulty with the configuration of this plug-in though. I'm trying to run the curl command but get this reply: "curl: (52) Empty reply from server." I then tried running the shell script to retrieve the list of Bond deviceId's but got this reply: "17: Syntax error: redirection unexpected."

I have limited experience with other plug-ins, I've tried to apply what I've learned but this one feels slightly beyond my grasp. Might you be available to help me via Discord too? I'd really appreciate it, after trying all the other bridges, this feels like the final piece of the puzzle.

dxdc commented

@Fofer which curl command are you running?

It sounds like you're either not including the Bond token or using the wrong IP address, but it's a bit hard to know. Sure, please send me your Discord tag and we can discuss.

Fofer commented

Hi, thanks, I was trying to run the curl command you included in the "Bond Pro Bridge Configuration" readme here: https://github.com/dxdc/homebridge-blinds#bond-bridge-pro-configuration

and yes, I customized the text with my own Bond token, and IP address of the Pro bridge.
(I also tried the IP address of my Pi, to no avail. Admittedly I'm flying blind here, lol.)

My Discord tag is Fofer#1613, thanks!

Fofer commented

Just wanted to chime back in, that this has been working great. Thanks so much @dxdc!

Bond just released a new beta that adds "groups." I'm wondering if there could be a way for these grouped shades to show up in Homebridge too...

https://forum.bondhome.io/t/v3-1-0-beta-for-bond-bridge-pro/3173

Also, @MattGeale, in that thread above the Bond developer asks, "if anyone else is reading this and cares a lot about SetPosition for shades, please make some noise." So if that is of any interest to you, this would be the thread to chime in at. They seem really committed to making this functionality even better.

@Fofer Add me on Discord Matt#8119 :)

Good to see they're adding setposition for shades. I'll defs make some noise.

dxdc commented

@Fofer happy to know everything is working well for you, and, thanks for sharing the update! It sounds useful, though the firmware is not coming to my unit :/.

In principle, I really like the idea of Bond keeping track of state of each blind. In fact, the fact that this feature was missing is primarily why I jumped on homebridge-blinds in the first place.

With Bond tracking state, the most appropriate place for the blinds code is in the homebridge-bond plugin itself, so it would be worth starting some noise over on that thread again. For example, 10+ blinds that need to individually communicate with the same API isn't very useful, but code to synchronize everything would end up being very specific to the Bond device itself. (You also have to worry about conflicts like someone activating a blind group followed by telling a single blind within that group to do something different.)

Still, unless you have blinds which can report state themselves (like Rollease), I don't think tracking state even helps that much because someone can always override manually with the remote control.

dxdc commented

Since we're deep into discussion here, I'll share with you guys that my view of home automation has shifted since getting into hb a few years ago. After configuring nearly every device to be capable of being operated inside the Home app, I felt it was not as great as I thought it would be and sometimes felt annoying. All I had succeeded in doing is creating one giant universal remote.

It was an improvement of course, but it didn't give me the freedom I thought it would.

So, I changed my goal. Instead of adding more remotes, I wanted the house to know what I wanted and then automate it. For example, if the sun was shining in a window and blinding me, and I was home, I wanted the blinds to go down. I wanted my thermostat to know exactly what temperature combination I preferred based on the humidity and radiant heat effects, as well as, the time of day or if I was asleep. I wanted the floor LED lighting to go on in the bathroom if I was in there in the middle of the night, and to shut off after I went back to bed.

I've done all of that and more, and while I have individual control to each device, I find I don't really need or use it anymore since I've merged the technology together to just "know" what I want. Node-RED has been an absolute game changer in this regard, since I can combine extremely complicated logical scenarios -- and it's exactly what's lacking with IFTTT, built in Home tools, and more.

For blinds specifically, I think the use cases are pretty simple, and may not all apply:

  • Saving energy (based on outdoor temps / radiant heat)
  • Reduce inside light (sun glare, watching TV, etc.)
  • Outdoor views
  • Privacy

If you can build the logic around these points, it's pretty easy to implement this all in Node-RED.
For example: if I'm ready for sleep, close all the blinds. If I'm awake, open them.

I can help share ideas or implementation details if you guys are curious to know more.

Since we're deep into discussion here, I'll share with you guys that my view of home automation has shifted since getting into hb a few years ago. After configuring nearly every device to be capable of being operated inside the Home app, I felt it was not as great as I thought it would be and sometimes felt annoying. All I had succeeded in doing is creating one giant universal remote.

It was an improvement of course, but it didn't give me the freedom I thought it would.

So, I changed my goal. Instead of adding more remotes, I wanted the house to know what I wanted and then automate it. For example, if the sun was shining in a window and blinding me, and I was home, I wanted the blinds to go down. I wanted my thermostat to know exactly what temperature combination I preferred based on the humidity and radiant heat effects, as well as, the time of day or if I was asleep. I wanted the floor LED lighting to go on in the bathroom if I was in there in the middle of the night, and to shut off after I went back to bed.

I've done all of that and more, and while I have individual control to each device, I find I don't really need or use it anymore since I've merged the technology together to just "know" what I want. Node-RED has been an absolute game changer in this regard, since I can combine extremely complicated logical scenarios -- and it's exactly what's lacking with IFTTT, built in Home tools, and more.

For blinds specifically, I think the use cases are pretty simple, and may not all apply:

  • Saving energy (based on outdoor temps / radiant heat)
  • Reduce inside light (sun glare, watching TV, etc.)
  • Outdoor views
  • Privacy

If you can build the logic around these points, it's pretty easy to implement this all in Node-RED. For example: if I'm ready for sleep, close all the blinds. If I'm awake, open them.

I can help share ideas or implementation details if you guys are curious to know more.

I'd love to have a crack at NodeRed but I'm also in a similar situation as you...I want to have blinds that can track their position. I'm trying even to the point of selling my Somfy ones (for a few more reasons other than SetPosition) so if you know anyone ;)

Nah but in all seriousness on the topic of NodeRed, I'd be game to have a crack at it, but I'd need to have someone sit down with me and teach me a few of the basics first cause from waht I've seen its really really indepth and can turn into a massive rabbit hole if you don't know what you're really doing.

dxdc commented

This is a good intro video (as are many in this channel): https://www.youtube.com/watch?v=3AR432bguOY

Essentially, everything works in "flows". You can use nodes of different types and create logical flows to represent patterns you want. Once you play with the basic set up and get comfortable, add the hb nodes: https://flows.nodered.org/node/node-red-contrib-homebridge-automation

You can then play with things like turning lights on/off, or getting notified when a light turned on for example.