vojtamolda / homebridge-bluetooth Goto Github PK
View Code? Open in Web Editor NEWHomebridge plugin to expose BLE peripherals as HomeKit accessories.
Home Page: https://www.npmjs.com/package/homebridge-bluetooth
License: MIT License
Homebridge plugin to expose BLE peripherals as HomeKit accessories.
Home Page: https://www.npmjs.com/package/homebridge-bluetooth
License: MIT License
I have an electric heater that I would like to control, the heater uses a bluetooth app for remote control. Is it possible to use this plugin to do that?
I need on/off, heater on/off, and temperature up/down commands
hi,
Is it somehow possible to let homebridge turn of my (xiaomi mi laser projecter with mi tv) streamer via a bluetooth turn off
command?
I see a lot of questions on the internet on how to use a bluetooth keyboard with a PI, but I want my PI to send a turn off/on, next etc command to media devices.
thanks a lot!
Hi There,
I am trying to run it on Lightblue Bean but I get the error ble_protocol.h: No such file or directory after I have imported the CurieBLE and CurieIMU libraries.
In file included from /Users/xx/Documents/Arduino/libraries/CurieBLE/src/BLECharacteristic.h:23:0,
from /Users/xx/Documents/Arduino/libraries/CurieBLE/src/CurieBLE.h:20,
from /var/folders/0z/1bn_g74n64l51gh8czxrbyt80000gn/T/untitled1440007012.tmp/sketch_dec18b/sketch_dec18b.ino:2:
/Users/xx/Documents/Arduino/libraries/CurieBLE/src/BLECommon.h:25:54: fatal error: ../src/services/ble_service/ble_protocol.h: No such file or directory
#include "../src/services/ble_service/ble_protocol.h"
You have any idea what could be wrong?
Thanks in advance.
hi there,
is your plugin able to act like an extender or ranger for BLE devices like "eve thermostat"?
this plugin "https://github.com/grover/homebridge-ranger" does the trick but its not supported anymore and only hacked together…
maybe you could have a look or two? ;) thanks in advance
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
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
I'd like to add a custom thermostat (Danfoss Eco 2) that I currently use through an iOS app. I was wondering if there was somebody who could push me in the right direction towards my goal, I'm pretty new to Homebridge and IoT.
I guess I need to somehow intercept my iOS app's communication with the thermostat when I send commands, and then try to replicate this somehow in Homebridge. Or is there another way?
I tried to follow the link from this repos readme, but it returns a 404: https://github.com/homebridge/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js
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()
});
}
});
});
}
});
When connecting to multiple BLE peripherals, plugin can sometimes discover only a handful of configured peripherals and then stop scanning.
The issue is timing dependent. Sometimes all BLE devices can be discovered simultaneously and at once. Then everything works as expected. However, if some devices take longer to discover (typically those with weaker signal) these poor things are never discovered and connected to. Scanning for new devices is not resumed after each connect(...)
operation. This happens because of a somewhat less documented feature of the Noble library - scanning automatically stops once connect(...)
is called.
Successful runs, when all devices are discovered at the same time looks like this:
[Bluetooth] Started | poweredOn
[Bluetooth] Discovered | Adafruit Bluefruit LE - FE:00:22:36:1D:49
[Bluetooth] Discovered | Adafruit Bluefruit LE - 15:34:95:60:FA:79
[Bluetooth] [Bluefruit] Connected | Adafruit Bluefruit LE - FE:00:22:36:1D:49
...
[Bluetooth] [Orangefruit] Connected | Adafruit Bluefruit LE - 15:34:95:60:FA:79
...
Unsuccessful runs, when some of the devices are not discovered looks like this. Usually, the peripheral with weaker signal ([Orangefruit]
in this case) is not discovered:
[Bluetooth] Started | poweredOn
[Bluetooth] Discovered | Adafruit Bluefruit LE - FE:00:22:36:1D:49
[Bluetooth] [Bluefruit] Connected | Adafruit Bluefruit LE - FE:00:22:36:1D:49
...
Hi,
I've been hoping to connect my lock via bluetooth (which it currently uses on my phone) instead of zwave - as this seemed to drain the battery really quick.
installed homebridge and it started ok, thermostat loaded........
installed homebridge-bluetooth
When i went to start home bridge it failed with the following:
Load homebridge-bluetooth.Bluetooth
/usr/local/lib/node_modules/homebridge-bluetooth/source/platform.js:16
if (!config.accessories || !(config.accessories instanceof Array)) {
^
TypeError: Cannot read property 'accessories' of null
at new BluetoothPlatform (/usr/local/lib/node_modules/homebridge-bluetooth/source/platform.js:16:14)
at Server._loadDynamicPlatforms (/usr/local/lib/node_modules/homebridge/lib/server.js:315:30)
at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:82:8)
at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10)
at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
Phil
I have a GarageMate (https://www.bluemate.com/) Bluetooth device that triggers my garage door opener, and I've been able to successfully pair it with my Raspberry Pi running homebridge. Using the gatttool utility, I was able to obtain the primary services and characteristics of the GarageMate device. Now, I'm attempting to update my config.json configuration file with the proper information. Unfortunately, it's not going well. The homebridge-bluetooth platform aborts.
GarageMate explained that reading Core Characteristic 0x2A57 from Core Service 0x1815 would activate the device. These are the UUID values I was able to obtain from gatttool:
attr handle: 0x0039, end grp handle: 0xffff uuid: 00001815-0000-1000-8000-00805f9b34fb
handle: 0x003a, char properties: 0x0a, char value handle: 0x003b, uuid: 00002a57-0000-1000-8000-00805f9b34fb
The GarageMate implements a momentary contact closure via two wires to the garage door opener. It doesn't understand in any manner whether the door is open or closed or blocked. In my understanding, it's a simple button-press. I'd expect to configure it as follows:
"name": "GarageMate",
"address": "01:23:45:67:89:AB",
"services": [ {
"name": "Garage Door",
"type": "Automation_IO",
"UUID": "00001815-0000-1000-8000-00805f9b34fb",
"characteristics": [ {
"type": "Button",
"UUID": "00002a57-0000-1000-8000-00805f9b34fb"
} ]
} ]
Thank you for your assistance!
If you restart the homebridge after installing the plug-in, the same content is repeated in the log and will not run.
[3/26/2020, 8:32:20 PM] [HB Supervisor] Homebridge Process Ended. Code: 1, Signal: null
[3/26/2020, 8:32:25 PM] [HB Supervisor] Restarting Homebridge...
[3/26/2020, 8:32:25 PM] [HB Supervisor] Starting Homebridge with extra flags: -I
[3/26/2020, 8:32:25 PM] [HB Supervisor] Started Homebridge with PID: 2335
[3/26/2020, 8:32:29 PM] Loaded config.json with 0 accessories and 1 platforms.
[3/26/2020, 8:32:29 PM] ---
[3/26/2020, 8:32:29 PM] Loaded plugin: homebridge-bluetooth
Homebridge API version: 2.4
internal/modules/cjs/loader.js:985
throw err;
^
Error: Cannot find module 'bluetooth-hci-socket'
Require stack:
Hi! I don’t know if you still monitor this.
I’m planning on buying this:
https://www.securemeters.com/uk/product/electric-water-heating-controls/e7/
it’s Bluetooth controlled with a proprietary app. I have a raspberry Pi, a Mac and an iPhone.
Will your plugin allow me to scan this device and essentially create an on/off BT plugin for homebridge?
Sorry for over simplifying!
Is it possible to use plugin for presence detection of my iPhones? And if yes, how?
Hi, could you give an example of a garage door with Bluetooth?
Hey
Anyone ever got this working with UNO and hm-10 dongle?
Got any example code?
Regards
Matt
Good Day,
After some reinstalls of homebridge I was able to get your plugin installed. However, I seems to be getting the following error when running home bridge with your accessory sample:
[11/12/2016, 11:37:05 PM] ---
[11/12/2016, 11:37:05 PM] Loaded config.json with 1 accessories and 0 platforms.
[11/12/2016, 11:37:05 PM] ---
[11/12/2016, 11:37:05 PM] Loading 1 accessories...
[11/12/2016, 11:37:05 PM] [Arduino 101] Initializing BLE Accessory accessory...
/usr/local/lib/node_modules/homebridge-bluetooth/index.js:18
this.lights.service = trim_uuid(config.lights.service);
^
TypeError: Cannot read property 'service' of undefined
at new BLEAccessory (/usr/local/lib/node_modules/homebridge-bluetooth/index.js:18:48)
at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:262:29)
at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:78:38)
at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10)
at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
Any thoughts?
I'm getting an error with the Bluetooth-hci-socket about operating system not supported
I wan't to use a tethercell with this plugin. But this BT device needs authorization with passcode 00000000.
Any advice on how to create a working config?
Details about the Device could be found here.
https://github.com/sandeepmistry/node-tethercell/blob/master/tethercell.txt
Best regards
Kai
Currently, the plugin only logs the name and address when a new BLE device is discovered. Per discussion in #2 it would be helpful to output the RSSI (signal strength in dB) as well.
RSSI can be used to tell which peripheral device is closer to the central and also detect possible problems with a weak signal.
I use ESP32, got BLE working correctly and send periodically Notification Values.
On a mobile with BLE Scanner: The sensor is seen, periodically NOTIFY update values are received.
On the raspberry: Sensor is connected, Service and Characteristic is "connected".
In the Homekit (also tested in the EVE App): Sensor is seen, correct service and characteristic. I can start "identify" the sensor with positive response. I see the action "Identify" in the Raspi log too.
But ... never get values or value updates. I would expect the same behavior, like the BLE Scanner do. I'm confused. please help.
Hi,
Could this be used to trigger the Siri remote to execute buttons ?
Hey,
Could i command my bluetooth tv with it ?
Thank you !
Upon running npm install -g noble
I get below error:
make: *** [binding.target.mk:109: Release/obj.target/binding/src/BluetoothHciSocket.o] Error 1
make: Leaving directory '/usr/local/lib/node_modules/noble/node_modules/bluetooth-hci-socket/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:314:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 5.4.51-v7+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/noble/node_modules/bluetooth-hci-socket
gyp ERR! node -v v12.19.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: xpc-connection@~0.1.4 (node_modules/noble/node_modules/xpc-connection):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/noble/node_modules/bluetooth-hci-socket):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
+ [email protected]
updated 1 package in 47.272s
If I run it with sudo
(which I believe I am not supposed to, as my node_modules is owned by my current user), I get this error:
pi@homebridge:~ $ sudo npm install -g noble
> [email protected] install /usr/local/lib/node_modules/noble/node_modules/usb
> prebuild-install --verbose || node-gyp rebuild
prebuild-install info begin Prebuild-install version 5.3.6
prebuild-install WARN install EACCES: permission denied, access '/root/.npm'
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/12.19.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/noble/node_modules/usb/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/noble/node_modules/usb/.node-gyp'
gyp ERR! System Linux 5.4.51-v7+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/noble/node_modules/usb
gyp ERR! node -v v12.19.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
> [email protected] install /usr/local/lib/node_modules/noble/node_modules/bluetooth-hci-socket
> node-gyp rebuild
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/12.19.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/noble/node_modules/bluetooth-hci-socket/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/noble/node_modules/bluetooth-hci-socket/.node-gyp'
gyp ERR! System Linux 5.4.51-v7+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/noble/node_modules/bluetooth-hci-socket
gyp ERR! node -v v12.19.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: xpc-connection@~0.1.4 (node_modules/noble/node_modules/xpc-connection):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/noble/node_modules/usb):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `prebuild-install --verbose || node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/noble/node_modules/bluetooth-hci-socket):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
+ [email protected]
updated 1 package in 13.782s
Any ideas on how I can proceed?
Hi!
Just wanted to share that I am running a Macbook Pro Early 2011 which does not support BLE.
On a whim I bought this from Amazon which works perfectly with my Mac. I did remove the AirPort Card from the MacBook Pro (it's on ethernet anyway) to force it to use this device by default but it is working very well with this plugin. Thanks again!
https://www.amazon.co.uk/gp/product/B00LSGUBLI/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1
I have a Mira Mode dual-head shower that I can control via bluetooth, from my phone (preheat, set/view temp, valve select, on/off, etc).
Could this plugin be used to connect that?
How do I decode the data/encode the commands to send to the BLE device?
Can those commands be sniffed when I perform them from my phone?
I tried to upgrade my NodeJS from 9.9.0 to 12.16.2 but the rebuild after fails due to the node_module bluetooth-hci-socket in the homebridge-bluetooth folder.
There is a workaround to accomplish the upgrade for the default /usr/local/lib/node_modules/bluetooth-hci-socket. Maybe this is adaptable to the bluetooth-hci-socket of the homebridge-bluetooth plugin?
Now, a step further ... I connect my sensor from iPhone BLE Scanner. Reading the values, the App sends "0C4", (log on my sensor) the sensor gives back the values, all things ok, so fare.
On Raspberry:
The log on the raspberry tell me, Service and Characteristic on the sensor are connected, Homebridge events to get the characteristic too. if I push a request on the homekit app on my mobile, I should see the same or equal behavior (the plugin send 0C4), but nothing happened. The plugin sends nothing.
I tried the node red version to communicate with the sensor - all things good, so noble couldn't be the problem. Any ideas?
Is it somehow possible to connect my iPhone Bluetooth as Device.
The Idee the homebridge sees when I am home and I can control light or alarm system!
So, the August SmartLock Pro has homekit compatibility out of the box. But is is really bulky and doesn't fit my door, there just isn't enough room to fit.
August Smart Lock (regular one, the smaller size one, the cheaper one) https://store.august.com/products/august-smart-lock-3rd-generation will fit but it doesn't have Homekit compatibility!
Would this plugin be able to communicate with the SmartLock using bluetooth and make it Homekit compatible?
Hello,
I'm sure I'm missing something or this is not the right place to ask, nevertheless...
I Have a Raspberry Pi 4 running Home Assistant and a Schlage Sense lock (i.e. bluetooth).
So you got my question : would your homebridge (I say your because there was also a Homebridge addon for Home Assistant but I can't say if it has something to do with yours)... Would it be usefull to install your Homebridge on the Pi ? Would it make the Schlage lock visible as a HomeKit lock on the Wifi network ( which, I hope, would allow Home Assistant to see it)?
The Pi is running Ubuntu Server 20.04 and Home Assistant is running on Docker on the Ubuntu Server.
Thanks for your help
Regards
V.
I'm having trouble getting this running on the Pi.
I had modified your code to always convert data to utf8. This works perfectly for my devices and running this plugin on my mac. However, when used on the Pi, I get the following error and I can't seem to figure out why as the utf8 module was installed.
/usr/local/lib/node_modules/homebridge-lifebot/source/characteristic.js:156
buffer = Buffer.from(value, 'utf8');
^
TypeError: utf8 is not a function
at Function.from (native)
at Function.from (native)
at BluetoothCharacteristic.toBuffer (/usr/local/lib/node_modules/homebridge-lifebot/source/characteristic.js:156:19)
at BluetoothCharacteristic.set (/usr/local/lib/node_modules/homebridge-lifebot/source/characteristic.js:118:23)
at emitMany (events.js:108:13)
at emit (events.js:182:7)
at Characteristic.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:155:10)
at Bridge.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:740:22)
at Array.forEach (native)
at Bridge.Accessory._handleSetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:685:8)
Hi,
I'm trying to develop my own window covering BLE peripheral/accessory. So far I have:
Here's the config.json
:
{
"bridge": {
"name": "Raspberry Pi 2",
"username": "00:13:EF:80:00:12",
"port": 51826,
"pin": "031-45-154"
},
"description": "Raspberry Pi 2 Homebridge-Bluetooth",
"platforms": [
{
"platform": "Bluetooth",
"accessories": [
{
"name": "Smart Shades",
"name_note": "Name of the accessory as shown in the Home app on iOS.",
"address": "D0:5F:2E:E2:11:22",
"address_note": "Bluetooth address of the accessory. Non-matching devices are ignored.",
"services": [
{
"name": "Smart Blinds",
"name_note": "Name of the service as shown in the Home app on iOS.",
"type": "WindowCovering",
"type_note1": "Type of the service - i.e. Lightbulb, Switch, Lock, HumiditySensor, ...",
"type_note2": "Must match this list - https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js",
"type_note3": "Service.Lightbulb has a mandatory On characteristic and Brightness, Hue and Saturation are optional.",
"UUID": "A7B10010-EEEE-5377-FF6C-D104768A1214",
"UUID_note": "Bluetooth UUID of the service. Capitalization and dashes doesn't matter.",
"characteristics": [
{
"type": "CurrentPosition",
"type_note1": "Type of the characteristic - i.e. On, Brightness, CurrentHumidity, CurrentTemperature, ...",
"type_note2": "Must match this list - https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js",
"type_note3": "Characteristic.On is a BOOL value and expects READ, WRITE and NOTIFY permissions.",
"UUID": "A7B10011-EEEE-5377-FF6C-D104768A1214",
"UUID_note": "Bluetooth UUID of the characteristic. Capitalization and dashes doesn't matter."
},
{
"type": "TargetPosition",
"type_note1": "Type of the characteristic - i.e. On, Brightness, CurrentHumidity, CurrentTemperature, ...",
"type_note2": "Must match this list - https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js",
"type_note3": "Characteristic.Brightness is an INT value and expects READ, WRITE and NOTIFY permissions.",
"UUID": "A7B10012-EEEE-5377-FF6C-D104768A1214",
"UUID_note": "Bluetooth UUID of the characteristic. Capitalization and dashes doesn't matter."
}
],
"characteristics_note1": "List of Bluetooth characteristics that will be exposed to HomeKit.",
"characteristics_note2": "Characteristics with non-matching UUIDs are ignored."
}
],
"services_note1": "List of Bluetooth services that will be exposed to HomeKit.",
"services_note2": "Services with non-matching UUIDs are ignored."
}
]
}
]
}
This is what happens when I launch Homebridge and start interacting with my iPhone:
#include <SPI.h>
#include <BLEPeripheral.h>
const int pinLED = 13;
BLEPeripheral ble = BLEPeripheral(6,7,4);
BLEService informationService("180A");
BLECharacteristic modelCharacteristic("2A24", BLERead, "101");
BLECharacteristic manufacturerCharacteristic("2A29", BLERead, "Arduino");
BLECharacteristic serialNumberCharacteristic("2A25", BLERead, "2.71828");
BLEService windowCoveringService("A7B10010-EEEE-5377-FF6C-D104768A1214");
BLEUnsignedCharCharacteristic currentPositionCharacteristic("A7B10011-EEEE-5377-FF6C-D104768A1214", BLERead | BLENotify);
BLEUnsignedCharCharacteristic targetPositionCharacteristic("A7B10012-EEEE-5377-FF6C-D104768A1214", BLEWrite | BLERead | BLENotify);
//BLEUnsignedIntCharacteristic positionStateCharacteristic("A7B10013-EEEE-5377-FF6C-D104768A1214", BLERead | BLENotify);
void setup() {
Serial.begin(115200);
pinMode(pinLED, OUTPUT);
digitalWrite(pinLED, true);
ble.setLocalName("Smart Blinds");
ble.setAdvertisedServiceUuid(windowCoveringService.uuid());
ble.addAttribute(informationService);
ble.addAttribute(modelCharacteristic);
ble.addAttribute(manufacturerCharacteristic);
ble.addAttribute(serialNumberCharacteristic);
ble.addAttribute(windowCoveringService);
ble.addAttribute(currentPositionCharacteristic);
ble.addAttribute(targetPositionCharacteristic);
//ble.addAttribute(positionStateCharacteristic);
currentPositionCharacteristic.setValue(100);
//positionStateCharacteristic.setValueLE(positionState);
ble.setEventHandler(BLEConnected, centralConnect);
ble.setEventHandler(BLEDisconnected, centralDisconnect);
targetPositionCharacteristic.setEventHandler(BLEWritten, characteristicWrite);
currentPositionCharacteristic.setEventHandler(BLESubscribed, characteristicSubscribe);
delay(5000);
ble.begin();
Serial.println("Bluetooth on");
}
void loop() {
ble.poll();
}
void centralConnect(BLECentral& central) {
Serial.print("Central connected | ");
Serial.println(central.address());
}
void centralDisconnect(BLECentral& central) {
Serial.print("Central disconnected | ");
Serial.println(central.address());
}
void characteristicWrite(BLECentral& central, BLECharacteristic& characteristic) {
Serial.print("Characteristic written | ");
Serial.println(characteristic.uuid());
unsigned char targetPosition = (unsigned char) targetPositionCharacteristic.value();
Serial.print("Target position set: ");
Serial.println(targetPosition);
setBlinds(targetPosition);
}
void characteristicSubscribe(BLECentral& central, BLECharacteristic& characteristic) {
Serial.println("Characteristic event, subscribed");
//Central subscribes just fine
}
void setBlinds(unsigned char targetPosition) {
//This is where the code to drive the motor will go
currentPositionCharacteristic.setValue(0);
//When the current position value is set, no notification is sent to the central
Serial.print("Current position: ");
Serial.println(currentPositionCharacteristic.value());
digitalWrite(pinLED, false);
}
When I attempt to open/close the blinds using iOS, the value is written from the central (Homebridge) to the peripheral (RedBear Blend Micro) TargetPosition characteristic as per the first screenshot. Interestingly, TargetPosition characteristic also sends the notification back to the central.
My issue is that whatever I tried, the CurrentPosition characteristic just refuses to send the notification back to the central when its value changes to let the central know that the operation has finished. The central is subscribed to the characteristic because serial prints out some text when the event handler is triggered at the point when the central subscribes.
As the central doesn't get an updated value for the CurrentPosition characteristic, presumably HomeKit has no idea where the blinds are so it simply displays a spinner next to the icon which just doesn't stop spinning (infinite loop).
Where am I going wrong?
Any help at all would be appreciated!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.