Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin Modification help #12

Closed
bluephlame opened this issue May 31, 2017 · 1 comment
Closed

Plugin Modification help #12

bluephlame opened this issue May 31, 2017 · 1 comment
Labels

Comments

@bluephlame
Copy link

I am after advice on how to modify this Bluetooth-plugin such that it will reach to the BLE door opener that I have.

I have the following code that will toggle the door. But I am unsure as to what the best location and architecture is to put into the homebridge plugin.

Thanks, I am new to NodeJS and homebridge.

noble.on('discover', function(peripheral) {
  console.log("hello world - discovered " +peripheral.advertisement.localName+ ": " + peripheral.uuid );
  if(peripheral.uuid == "568c300974984c9b96ea051f02a46fea")
  {
   peripheral.connect(function(error) {
     console.log('connected to peripheral: ' + peripheral.advertisement.localName);
     console.log('advertising the following service uuid\'s: ' + peripheral.advertisement.serviceUuids);
     peripheral.discoverServices(['1802'], function(error, services) {
       for (var i in services) {
        deviceInformationService =services[i];
        deviceInformationService.discoverCharacteristics(['2a06'], function(error, characteristics) {
          for (var i in characteristics) {
            console.log('  ' + i + " Service UUDI:"+characteristics[i]._serviceUuid+ ' uuid: ' + characteristics[i].uuid +" name:"+characteristics[i].name + " ServiceProperties:"+characteristics[i].properties);
          }
          var alertLevelCharacteristic = characteristics[0];
            console.log("The door just triggered, uncomment the lines below to actually make it open");
            // alertLevelCharacteristic.write(new Buffer([0x00,0x80,0x54,0x03,0xb3,0xf6,0x35,0x84]), true, function(error) {
            //   console.log('Door toggled');
            // });
            peripheral.disconnect()
         });
       }
     });
   });
  }
});
@vojtamolda
Copy link
Owner

Hello @bluephlame,

Thanks for opening the issue here. I went through your code and I think the best solution would be to write your own plugin for Homebridge.

Reason is that this plugin is a relatively simple and straightforward mapping from HomeKit to BLE. If the control messages between the two don't match and need some translation logic in between (like in your case) it's not so easy to specify.

It's doable, but I think it would be easier in a separate project. You can mix this example with some code from here to handle the BLE layer and you'll be mostly removing stuff that's not needed.

Don't worry about node.js and just try it. You can google everything about it. I had no prior experience before doing this project... ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants