BFT Gate Control Integration

Thanks a lot for this! A couple of questions, what is the url (+ headers) you need to hit to get the access token? I’m trying to develop a Homebridge plug-in. Also, have you tried accessing the device info through ssh instead of web api?

Again, great job, thanks

I think they are using one of these boards and their provided API:

https://docs.particle.io/

A few pointers here:

https://docs.particle.io/reference/device-cloud/api/#generate-an-access-token

You should be able to see the URL in my code:

    def get_token(self):
        """Get new token for usage during this session."""
        args = {
            "grant_type": "password",
            "username": self._username,
            "password": self._password,
        }
        url = "{}/oauth/token".format(self.particle_url)
        ret = requests.post(url, auth=("particle", "particle"), data=args, timeout=10)

Therefore:

url = https://ucontrol-api.bft-automation.com/oauth/token

requests.post(url, auth=(“particle”, “particle”), data=args, timeout=10)

Where:

args = {
“grant_type”: “password”,
“username”: self._username,
“password”: self._password,z

An example I just ran using the particle docs:

➜  bft git:(dev) curl https://ucontrol-api.bft-automation.com/oauth/token \
       -u particle:particle \
       -d grant_type=password \
       -d "username=<user>" \
       -d "password=<pass>"
{"access_token":"<received_token","token_type":"bearer","expires_in":115430400,"refresh_token":"<received_refresh_token>","created_at":1586191227}% ➜  bft git:(dev)

All working great. I’ve also been trying to get “opening” and “closing” states with reed sensors at the gate, but you can only guess based on close.cover and open.cover service calls (HomeKit expects opening, closing and stopped states, not only open and close). With your integration, “stopped” and “moving” states can very very useful to achieve that, and I guess opening and closing could be even be inserted in the cover.py code. Thanks!

Did you ever figure out how to get opening and closing state? The BFT app shows the progress of the gate and it can be polled via the API but it scales from <0 and >100 which is pretty confusing. I guess this might be gate angle in degrees.

I just couldn’t find “opening” or “closing”.

Thanks.

Turns out the cover component does not allow states other than open and close. The way HomeKit is implemented in Home Assistant does not comply with HMCharacteristic. I guess it would have to be written from scratch for API polling to get the gate’s position.

I installed 2 sensors and built a sensor template (when sensor 1 was closed and it just opened, while sensor 2 is open, door is opening; when sensor 2 was closed and it just opened, while sensor 1 is open, door is closing) that showed the correct state of the gate, but then again, Home Assistant would not pass those values to HomeKit, only open and close values. Truth be told, I’m having lots of problems with the cover component in HomeKit (sluggish, false openings, etc.).

Maybe HomeBridge is a better idea at this point? Any thoughts? Thanks!

Sorry to reopen an old thread but thought I would provide an update a year on. My integration is still working but BFT’s cloud service is very flakey! I’m still using it but I have just successfully integrated a Remootio controller into my garage opener and use a node-red “flow” (if that’s the right term) to control it directly via an API. This means the response is instant and there’s no reliance on any cloud server although it is still there as a backup.

Next step I’m going to put one of the remootio controllers into my BFT opener as they provide various wiring guides to do this:

Details of the Node-Red integration:

This requires you to install Node-Red, I do this via the Hassio supervisor and also “Node-Red companion” via HACs. From here you can create a flow similar to the below:

Of course, change the name to “gate” etc.

You’ll have to do some reading but it’s fairly straightforward to work out.

When I get the 2nd controller into the BFT box I’ll send an update. Remootio takes 5V DC and the BFT seems to have a 24V output so I think I’ll need a DC to DC convertor.

Hope this helps.

You’ll also need a cover template in HA:

  - platform: template
    covers:
      remootio_garage_door:
        device_class: garage
        friendly_name: "Remootio Garage Door"
        #value_template: "{{ states('sensor.remootio_garage_state') }}"
        value_template: >
          {% set s = states('sensor.remootio_garage_state') %}
          {{ s if s in ['open', 'closed'] else 'open' }}
        open_cover:
          - condition: state
            entity_id: sensor.remootio_garage_state
            state: "closed"
          - service: switch.turn_on
            target:
              entity_id: switch.remootio_garage_switch
        close_cover:
           - condition: state
             entity_id: sensor.remootio_garage_state
             state: "open"
           - service: switch.turn_off
             target:
               entity_id: switch.remootio_garage_switch
        stop_cover:
          service: switch.turn_on
          target:
            entity_id: switch.remootio_garage_switch

@perimore Hi there, I know this is an old topic. I wanted to do the integration for my bft gate with the repo you created but it doesn’t exist anymore on github. Would you be willing to upload it again? Many thanks

You should find the code here. Just stick those files in the custom components folder with the config and it should work

Hi @perimore thank you for sharing your custom bft component. I’ve been using it for the past couple of years and other than the flakey BFT cloud service which regularly times out, and the wifi module having a weak antenna it has been great.

I too have become frustrated with having to wait for the cloud service to respond (sometimes 30 seconds plus) and the cover status flapping in home assistant/apple homekit (due to the cloud service timing out). So I’ve finally installed a ZWave relay to trigger the gate motion locally removing the dependency on the BFT wifi module, internet or the BFT cloud platform.

I have essentially started to do what is described here with a Qubino Flush 1D Relay.

I’m currently powering the relay with 240V from the supply to my BFT Thalia, I tried 24V DC from the accessory terminals 50/51 but the relay would not power up. Not sure if this is insufficient power or something else. Because of this I don’t think I can connect the switch on the relay to pickup the gate status, so I’m going to try powering it directly from the transformer when I get some more spade connectors.

Did you resolve your DC power challenge? The transformer in my Thalia has 3 different output terminals which are all at different voltages I believe.

So now I’m able to start/stop the motor with the relay which is set to automatically switch off after 500ms. I had to change the BFT configuration logic for terminal ic1 from setting 2 (Open) to 1 (Start I).

No more frustrating delays or blackouts (usually caused by Internet/WiFi faults) now I have local control with the much more robust ZWave.

I’m still using your BFT custom module for the gate status until I can get the relay switch hooked up.

Hello, I am a new user et it is difficult for me to understand.
I want to control my bft portal in home assistant. I have the official wifi module and I basically use the app.

I tried to follow the tutorial but I don’t quite understand how it works.
For now I have created a custom folder and created the 2 files as indicated by @uspino and @perimore .
But I am now stuck.

Can you tell me the code to indicate in the file and how to integrate it in home assistant ?

Thank you so much because it is very important for me !

Benjamin (a french user)

Hi @Benjamin_45, I presume you have copied the bft directory into your custom_components directory within your home assistant installation? The link to @perimore’s home-assistant repository no longer work but it’s still available here .

Once you’ve got the bft custom component in place, you just need to add to your configuration.yaml and restart home assistant and your gate should appear as a cover entity. My configuration.yaml is below as an example (bft_user and bft_password are tokens for the values stored in my secrets.yaml).

cover:
  - platform: bft
    covers:
      driveway:
        device: "Main-Gate"
        username: !secret bft_user
        password: !secret bft_password
        name: "Main Gate"

Hey, not sure what repository the old link was meant to go to but the forked repo should be enough.

I thought about this the other day in fact and how to fix the flapping state. Maybe the integration should somehow assume the last known state if the cloud service is unreachable. Not sure if that will fix it but will give it a shot soon.

I abandoned the Remootio integration as I realised that unit can only send a single output and would require an external sensor to establish if the door was open or closed.

Thank you so much for your help but finally I bought a 230V Wifi Module with dry contact relay output which works very well, much better than the original card and for a ridiculous price (https://www.amazon.fr/DOOWIFI-DWF-0201PN-normalement-encastrable-dencastrement/dp/B08QFZ75GY/ref=sr_1_3?keywords=relais+wifi&qid=1650569937&s=hi&sr=1-3).

It is compatible with google home and tuya smart and it works perfectly.

I still use the bft app to know if necessary the position of the gate (open/closed).
I can also have the gate open or close automatically.

Thank you again for your answers !

I tried to publish the integration to HACS but can’t quite work it out but have published it to github again:

Hope this helps.

Also made a change to not set the gate to offline if the request times out. Instead it just retains the last state. So far this has stopped the open/closed flapping.

1 Like

I’ve lost patience with the flakey cloud service offered by BFT and am going down the route of using the Shelly integration. How To: Driveway Swing Gate Automation (Shelly + BFT) - Working Perfectly with states!

Hello,
i’m net to HA and i’m trying to integrate BFT (cloud) to HA.
I’m foloowing perimore integration (thatnks a lot) and looks taht is working for me in 25%.
Main problem is that garage doors are all the time in ‘open’ state and this is causing that i’m just ale to close and stop doors - ‘open’ button is not available.
Could you support me how to get status of gate and maybe why it is not working for me in HA but is wokrking in U-Control?
Not sure if thsi is important but on remote for BFT i’m using one button to open/stop/close gate.
I would like to have this integration done via bft cloud to avoid additional realys etc. WIl try how it is wokring and then decide if enough for me or need to invest in additoianal HW.
In one sentence: ‘status for gate is not updateing from cloud - all teh time is open’ - how to debug this and fix or how to completly skip statuses in this integration?
Regards to all!

My project BFT Gate Controle (ESP Home)