homebridge-bluetooth icon indicating copy to clipboard operation
homebridge-bluetooth copied to clipboard

Question about adding devices that don’t match HAP

Open Jonczu opened this issue 5 years ago • 1 comments

Hi Not sure if I’m asking in the right place I’m very new to all this, we are talking complete noob that has ideas and wants to make them work. Ok that aside this plugin is fantastic and makes connecting to a BLE device a breeze, my question is if it would be possible to add support for adding devices that don’t communicate using HAP (reverse engineered devices). Is it possible to write a small script that works together with this plugin and simply converts the values from the device to HAP recognisable values and HAP values to reverse engineered device. The device I’m trying to make work with Home is a BLE dimmer switch that is controlled using hex values 0-10000 (0x0000 - 0x1027 please note 0x1027 is actually 0x2710 all the values are reversed something about endianness as I found out) 0x0000 is off and 0x1027 is 100% or fully on. So far I can connect and send the default HAP value for On 0x01 which somehow turns the BLE dimmer to full but it bricks the dim switch and can no longer be switched off physically. When using a BLE terminal app I can send the hex values from 0x0000 to 0x1027 and I get full functionality. The brightness and on off is all controlled by the same characteristic but there is a seperate characteristic that returns 0x00 when off and 0x01 for on, in the native app this characteristic updates the icon but actual control is done by the brightness characteristic

  1. Will my idea of a translator script work or would it be easier to write a complete new plugin to get this to work, translating 0x0000 - 0x1027 values to int values 1-100 for brightness control
  2. How would I go about writing a script I have zero idea where to start

I’m sorry if I’m out of place asking this question here, as I said earlier I’m a complete noob and don’t understand enough to get what I want done and would greatly appreciate any help or direction where to get help. Again I apologise if I’m asking in the wrong place.

Jon

Jonczu avatar Jul 22 '18 09:07 Jonczu

Hello Jon,

From your description, I think it may be possible to add some conversion functionality to this plugin. The homebridge config.json file can contain a user defined conversion/translation like offset and scaling for each characteristic.

Good place to start hacking and at least get your device somehow working is either set(...) or toBuffer(...) method of the BluetoothCharacteristic class in characteristic.js:90 & 107. There's a switch case for each Characteristic format that makes a conversion into the raw bytes buffer that is later transmitted to the device.

vojtamolda avatar Sep 10 '18 15:09 vojtamolda