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

GarageMate Bluetooth accessory - How to configure? #9

Closed
keith721 opened this issue Mar 13, 2017 · 10 comments
Closed

GarageMate Bluetooth accessory - How to configure? #9

keith721 opened this issue Mar 13, 2017 · 10 comments
Labels

Comments

@keith721
Copy link

keith721 commented Mar 13, 2017

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!

@keith721 keith721 changed the title GarageMate Bluetooth accessory - How to contigure? GarageMate Bluetooth accessory - How to configure? Mar 13, 2017
@vojtamolda
Copy link
Owner

Hello @keith721,

Your config.json is almost correct. All the "type" fields must match a HomeKit service/characteristic from HomeKitTypes.js. This config.json will consider the device to be a HomeKit switch:

"name": "GarageMate",
"address": "01:23:45:67:89:AB",
"services": [ {
    "name": "Garage Door",
    "type": "Switch",
    "UUID": "00001815-0000-1000-8000-00805f9b34fb",
    "characteristics": [ {
        "type": "On",
        "UUID": "00002a57-0000-1000-8000-00805f9b34fb"
      } ]
   } ]

You can find more details about these by reading the defintion of Service.Switch and it's only mandatory member Characteristic.On.

Try if this works and get back here. Characteristic.On is should support read, write and notify operations. If the GarageMate really triggers the door only by reading the characteristic, then get ready for a a lot of opening. The switch state is read every time you try to access it in the Home app on your iphone/ipad.

To be honest the plugin was never intended to be this general and allow BLE service to map onto a HomeKit service with some form of a translation happening in between. I like to push the boundaries and the change to the codebase of this plugin in order to incorporate this kind of general mapping is substantial, but it's definitely doable.

If you take a look at the examples, all of them have access to the source code running on the BLE peripheral and make the BLE services/characteristics match HomeKit. In this case I doubt GarageMate will release and open-source their firmware, so that's not an option.

@keith721
Copy link
Author

After reviewing Service.Switch and Characteristic.On, it appears the GarageMate device should be configured as Service.StatelessProgrammableSwitch instead of Service.Switch. Hopefully, this would avoid "a lot of opening".

I'll work with this when I return home this evening and have access to the GarageMate device. If all else fails, I can always attempt to implement similar behavior using an Arduino. Thank you!

@vojtamolda
Copy link
Owner

Yeah. You're right. The StatelessProgrammableSwitch seems like a better choice. To be honest, there's so many services in HomeKit I didn't even know this one existed... 😄

Good luck and have fun in the evening!

@keith721
Copy link
Author

keith721 commented Mar 13, 2017 via email

@vojtamolda
Copy link
Owner

😊

@keith721
Copy link
Author

keith721 commented Mar 13, 2017

I got it configured and the config parsed and loaded successfully, but it's "not supported" in the Home app on my iPhone. :(

[3/13/2017, 6:58:07 PM] [Bluetooth] Started | poweredOn
[3/13/2017, 6:58:07 PM] [Bluetooth] [GarageMate] Connected | GarageMate (98:7B:F3:62:C1:43)
[3/13/2017, 6:58:08 PM] [Bluetooth] [GarageMate] [Information] Connected
[3/13/2017, 6:58:08 PM] [Bluetooth] [GarageMate] [Information] [Model] Connected
[3/13/2017, 6:58:08 PM] [Bluetooth] [GarageMate] [Information] [SerialNumber] Connected
[3/13/2017, 6:58:08 PM] [Bluetooth] [GarageMate] [Information] [Manufacturer] Connected
[3/13/2017, 6:58:12 PM] [Bluetooth] [GarageMate] [Information] [Manufacturer] Disconnected
[3/13/2017, 6:58:12 PM] [Bluetooth] [GarageMate] [Information] [Model] Disconnected
[3/13/2017, 6:58:12 PM] [Bluetooth] [GarageMate] [Information] [SerialNumber] Disconnected
[3/13/2017, 6:58:12 PM] [Bluetooth] [GarageMate] Disconnected
[3/13/2017, 6:58:13 PM] [Bluetooth] [GarageMate] Connected | GarageMate (98:7B:F3:62:C1:43)
[3/13/2017, 6:58:13 PM] [Bluetooth] [GarageMate] [Information] Connected
[3/13/2017, 6:58:13 PM] [Bluetooth] [GarageMate] [Information] [Model] Connected
[3/13/2017, 6:58:13 PM] [Bluetooth] [GarageMate] [Information] [SerialNumber] Connected
[3/13/2017, 6:58:13 PM] [Bluetooth] [GarageMate] [Information] [Manufacturer] Connected
[3/13/2017, 6:58:18 PM] [Bluetooth] [GarageMate] [Information] [Manufacturer] Disconnected
[3/13/2017, 6:58:18 PM] [Bluetooth] [GarageMate] [Information] [Model] Disconnected
[3/13/2017, 6:58:18 PM] [Bluetooth] [GarageMate] [Information] [SerialNumber] Disconnected
[3/13/2017, 6:58:18 PM] [Bluetooth] [GarageMate] Disconnected
[3/13/2017, 6:58:19 PM] [Bluetooth] [GarageMate] Connected | GarageMate (98:7B:F3:62:C1:43)
[3/13/2017, 6:58:19 PM] [Bluetooth] [GarageMate] [Information] Connected
[3/13/2017, 6:58:19 PM] [Bluetooth] [GarageMate] [Information] [Model] Connected
[3/13/2017, 6:58:19 PM] [Bluetooth] [GarageMate] [Information] [SerialNumber] Connected
[3/13/2017, 6:58:19 PM] [Bluetooth] [GarageMate] [Information] [Manufacturer] Connected
noble warning: unknown handle 64 disconnected!
noble: unknown peripheral d0034b1f24e5 connected!
noble: unknown peripheral d0034b1f24e5 disconnected!
[3/13/2017, 6:58:24 PM] [Bluetooth] [GarageMate] [Information] [Manufacturer] Disconnected
[3/13/2017, 6:58:24 PM] [Bluetooth] [GarageMate] [Information] [Model] Disconnected
[3/13/2017, 6:58:24 PM] [Bluetooth] [GarageMate] [Information] [SerialNumber] Disconnected
[3/13/2017, 6:58:24 PM] [Bluetooth] [GarageMate] Disconnected

Here's the relevant portion of my config.json:

	    "platform" : "Bluetooth",
	    "name" : "Bluetooth",
	    "accessories" : [ {
		"name" : "GarageMate",
		"address" : "98:7B:F3:62:C1:43",
		"services" : [ {
		    "name" : "Garage Door",
		    "type" : "StatelessProgrammableSwitch",
		    "UUID" : "00001815-0000-1000-8000-00805f9b34fb",
		    "characteristics": [ {
			"type" : "ProgrammableSwitchEvent",
			"UUID" : "00002a57-0000-1000-8000-00805f9b34fb"
		    } ]
		} ]
	    } ]

@vojtamolda
Copy link
Owner

First, HomeKit is still being actively developed on all fronts and you're right that the current iOS (10.2) doesn't support the StatelessProgrammableSwitch service. However, according to this issue the support will be added in 10.3. And there's not much else one can do about this than to wait for Apple.

Second, even if iOS would support the switch I don't think it would work with the GarageMate. I tried googling to fill my knowledge gap about switches. StatelessProgrammableSwitch is a simple push button that returns back to it's original position after being pressed. It's meant as an event generator for the HomeKit ecosystem that can trigger other things. That's why it supports only READ and NOTIFY operations. There's a detailed (and loooong) discusion here.

Third, there's a very weird sequence of rapid BLE connect-disconnect events in your log. This shouldn't happen. Normally the plugin should connect only once and stay connected to the peripheral. I'm not sure why is this happening and the disconnect happens after reading the manufacturer string, which is quite innocent operation. Can you try running Homebridge in debug mode and posting the log here, please?

DEBUG=* homebridge

It's a shame the GarageMate doesn't work. Make this puzzle piece fit the rest of the HomeKit ecosystem is much harder nut to crack than I expected. So maybe going for the DIY solution and using the Arduino 101 or a similar board will get the door working for you faster...

@keith721
Copy link
Author

I also noticed the GarageMate did not provide the Device Information service 0x180A or its characteristics of Manufacturer Name 0x2A29, Model Number 0x2A24, and Serial Number 0x2A25. Because of this, I ordered an Arduino UNO, HM-10 BLE Bluetooth 4.0 module, and switch/relay board. I've already developed the Arduino sketch to emulate the GarageMate device. My hope is that using the more up-to-date CurieBLE library may resolve the disconnect/reconnect issues.

@vojtamolda
Copy link
Owner

Those services are not mandatory and the plugin can work fine without them. But anyway, I'll be happy to merge a pull request with a new example if you want to make it.

@keith721
Copy link
Author

It will be some weeks before my parts arrive. When I've had some opportunity to test the script and work out any bugs, I'll be happy to submit it here. Meanwhile, I believe I can close this question. Thanks again for your generous assistance!

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