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

MIPOW PLAYBULB adapter #677

Open
KaiRo-at opened this issue Dec 20, 2018 · 5 comments
Open

MIPOW PLAYBULB adapter #677

KaiRo-at opened this issue Dec 20, 2018 · 5 comments
Labels

Comments

@KaiRo-at
Copy link

I saw in WebThingsIO/gateway#165 that it's hard to get generic BLE support working because devices have different APIs behind the BLE connection. Niels Leenheer, creator of html5test, currently does a lot of presentations about WebBluetooth (e.g. the one at DACHFest I saw) and touting that e.g. MiPow Playbulb devices are nice to work with there. They have a nice collection of lights that work via BLE.
Niels has demo JS code (working with Chrome, which ships WebBluetooth) at https://github.com/BluetoothRocks/Lightbulb so following that it should not be hard to get an adapter done (and FWIW, he references the Open GATT Registry that has docs for more BLE devices).
I have got me some of those devices, so I'd be able to test, and as a Tech Speaker this would be great for doing demos as it works with what the RPi3 has on board by default - and the fewer pieces I need in a demo, the fewer points where things can fail. ;-)

@KaiRo-at
Copy link
Author

KaiRo-at commented Jan 8, 2019

Note that Niels' code at https://github.com/BluetoothRocks/Lightbulb/blob/master/lib/bluetooth-bulb.js#L8 only cares about reading/writing the color, which would be a great first step to get working, but depending on what model it is (I have a candle, sphere and comet available here), those devices have additional functions available, which would be also nice to support if we can figure out how.

If I wanted to look into getting something working there myself, how would I start?

@mrstegeman
Copy link
Contributor

I'd recommend copying an existing javascript-based adapter and using that as a starting point:

You'll probably want to use noble to do the Bluetooth comms. If you need any help with that, please let us know. I've been working with it a great deal lately.

Here are a couple general resources, as well:

@KaiRo-at
Copy link
Author

I started some work based on a fork of the example-adapter and put it into https://github.com/KaiRo-at/playbulb-adapter - it can do device discovery somewhat decently but the device functionality is very much faked still, and that's where I pretty much got stuck.
Also, I found out that things very much break down when I try to enable the homekit and this playbulb adapters at the same time as either noble or BLE itself is not really setup to handle things like that.

From what I've seen, we IMHO probably need 2 things going forward:

  1. Better documentation/examples for writing adapters, esp. where the discovery code would go, where we'd set up secure communication (bluetooth pairing or similar), where code for discovering, reading or setting properties and their values would go, etc.
  2. For Bluetooth specifically, a central service that talks to the bluetooth stack of the OS, and which several adapters can use to perform their BLE/GATT communications (over some sort of central API, REST or otherwise).

@mrstegeman
Copy link
Contributor

I think the biggest problem with using noble (or other libraries that use BlueZ) in multiple adapters is the state issue. For example, HomeKit constantly scans in the background to watch for events from devices, but BlueZ (or at least noble) freaks out when you try to communicate with a device while a scan is happening. It's very annoying.

  1. I agree that we need a centralized resource for writing an adapter, rather than pointing people to several different articles. Would you be interested in starting one on our wiki?
  2. Yes, that's probably a good idea, as well. We just did something similar for serial ports, although that one is far less complicated than a Bluetooth one would need to be.

@mrstegeman mrstegeman changed the title Add Support for MiPow Playbulb devices MiPow PLAYBULB adapter Mar 12, 2019
@mrstegeman mrstegeman changed the title MiPow PLAYBULB adapter MIPOW PLAYBULB adapter Mar 12, 2019
@mrstegeman mrstegeman reopened this Jan 29, 2020
@mrstegeman mrstegeman transferred this issue from WebThingsIO/gateway Jan 29, 2020
@madb1lly
Copy link

Hi @KaiRo-at and @mrstegeman, just a note to say that this sounds very similar to what I'd like to do with Happy Lighting / Triones bulbs: https://discourse.mozilla.org/t/wip-adapter-for-bluetooth-happylighting-triones-bulbs/49477
I've not progressed .... at all (!) yet, but it's still on my wish list.
Cheers 🙂

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

3 participants