dragouf / homebridge-awox

control awox smartlight with homebridge
MIT License
5 stars 1 forks source link

Does this package work? #1

Open codafish-gmbh opened 6 years ago

codafish-gmbh commented 6 years ago

Hi there,

first of all: I am very happy that I found a Homebridge plugin that hopefully connects my Awox bulbs. I installed your Homebridge plugin "homebridge-awox".

During the installation process of your plugin (npm i homebridge-awox -g) the following errors occurred:

node-pre-gyp ERR! Tried to download(404): https://github.com/tessel/node-usb/releases/download/1.3.1/usb_bindings-v1.3.1-node-v51-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for usb@1.3.1 and node@7.9.0 (node-v51 ABI, glibc) (falling back to source compile with node-gyp)
> bluetooth-hci-socket@0.5.1 install /usr/local/lib/node_modules/homebridge-awox/node_modules/bluetooth-hci-socket
> node-gyp rebuild

make: Verzeichnis „/usr/local/lib/node_modules/homebridge-awox/node_modules/bluetooth-hci-socket/build“ wird betreten
  CXX(target) Release/obj.target/binding/src/BluetoothHciSocket.o
../src/BluetoothHciSocket.cpp: In member function ‘void BluetoothHciSocket::emitErrnoError()’:
../src/BluetoothHciSocket.cpp:275:72: warning: ‘v8::Local<v8::Object> v8::Function::NewInstance(int, v8::Local<v8::Value>*) const’ is deprecated (declared at /home/pi/.node-gyp/7.9.0/include/node/v8.h:3657): Use maybe version [-Wdeprecated-declarations]
   Local<Value> error = errorConstructor->NewInstance(1, constructorArgs);
                                                                        ^
  SOLINK_MODULE(target) Release/obj.target/binding.node
  COPY Release/binding.node

Additionally the following warnings are displayed:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: xpc-connection@0.1.4 (node_modules/homebridge-awox/node_modules/xpc-connection):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for xpc-connection@0.1.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})

When I start Homebridge and turn the light on or off, the log contains an undefined in the beginning of the publishing message. Additionally the message can't find service appears:

[2017-12-28 13:16:11] [Dormitorio] Set power state on the 'Dormitorio' to true
[2017-12-28 13:16:11] [Dormitorio] lightOn...
[2017-12-28 13:16:11] [Dormitorio] publishing to: 'undefined/f4b85e3c9fc7/power' value: true
[2017-12-28 13:16:12] [Dormitorio] start scanning
[2017-12-28 13:16:12] [Dormitorio] found lamp with id: f4b85e3c9fc7 . and name:  SML_c9
[2017-12-28 13:16:12] [Dormitorio] connected to peripheral: f4b85e3c9fc7
[2017-12-28 13:16:13] [Dormitorio] cant find service...

Thank you very much for your help!!!

Cheers, Timo

codafish-gmbh commented 6 years ago

I just have seen, that this undefined-part in the route above is caused by a missing MQTT server configuration. I'have just installed the mosquitto server, but I still can't turn on or off the lights.

codafish-gmbh commented 6 years ago

Well, I now know that the issue has to do with your other plugin "smartphone-awox" (lib.js). The bulb can be found (peripheral.id and peripheral.advertisement.localName), but when it comes to peripheral.discoverServices, no services can be found (!services || services.length === 0).

Do you have an idea why?

dragouf commented 6 years ago

Hi @timoberlin, this homebridge plugin use my other library awox-smartlight. Don't know what you exactly mean by smartphone-awox.

I don't have any specs for awox protocol so all I did is reverse engineering on my lamp. Maybe services id exposed are different for your device. Can you try to install LightBlue on your iPhone and connect to your lamp and then write on the first service this value : AA0AFC3A86010A010100280D This should switch on your lamp.

If it works please give me the service id to where you sent this value.

codafish-gmbh commented 6 years ago

Hi Dragouf, I wanted to write "awox-smartlight", but I might have been thinking in my smartphone in that moment ;-)

I wrote the value to all services with the property "read write", but no change.

codafish-gmbh commented 6 years ago

btsnoop_hci.log

I attached a log file of the bluetooth traffic. The device I'm trying to control has the Mac address "c4be84c78420". Does this help?

codafish-gmbh commented 6 years ago

number 1081 in my log has payload 01 (switch on) or number 1615 with payload 00 (switch off) characteristic: UUID 217887F8-0AF2-4002-9C05-24C9-ECF71600 service: 33160FB9-5B27-4E70-B0F8-FF411E3AE078

the other characteristics seem to change the color of the bulb. img_0139 img_0140

codafish-gmbh commented 6 years ago

Have a look at this link: https://www.espruino.com/Puck.js+and+Bluetooth+Lightbulbs

It seems, that (at least in my case), the services and characteristics mentioned there match with the current specification of the SML_c9 bulb.

codafish-gmbh commented 6 years ago

Hi @dragouf! I hoped these information helped or do you need anything else? Thank you very much for your help!

codafish-gmbh commented 6 years ago

Hi @dragouf, I would be very happy if we could talk about this issue again. Maybe the information I provided were helpful? Cheers, Timo

dragouf commented 6 years ago

Hi,

Sorry if I didn’t replied. I was very busy. Anyway like you found you might has a different data sent to the lamp than the one I had. Anyway it’s seems you found someone who already reverse engineering the protocol so you can ask him for the frame to send. Then it will be easy to adapt my code since everything is inside constant at the beginning of the file.