nayaverdier / halohome

A python library to control Eaton HALO Home Smart Lights
MIT License
1 stars 1 forks source link

Reading external updates #2

Open oyvindkinsey opened 2 years ago

oyvindkinsey commented 2 years ago

When using the bridge, https://myaccount.avi-on.com/ is able to show updated values - this implies that there is a protocol for reading the device status, something which would be important for e.g. Home Assistant, where the light turning on might be a trigger needed to adjust the temperature via e.g Circadian Lighting.

What would the process be for reverse engineering this aspect of the system?

With a RAB bridging between the Avi-on Cloud and Avi-on Bluetooth Lighting Controls, the status of all devices is reported to the cloud in real time, allowing full remote monitoring of all system components

nayaverdier commented 2 years ago

I think the ideal solution would be to imitate the way the app updates its state, by subscribing to the bluetooth attributes. Reason being it'll work without external internet access, and without a bridge (I had to stop using the bridge because it started causing other devices to lose internet access despite being connected to my network, but that's a whole other issue).

Bleak supports the notify behavior (example) so it's just a matter of digging into the packets to figure out how to grab initial state, and determine which light and which state (brightness vs temperature) are being referenced in each packet. From what I saw before, it looked like the app was setting a BT attribute to some value, and then the mesh was updating the attribute(s) with a bunch of packets, I'd assume one for each light or maybe each light/attribute.

oyvindkinsey commented 2 years ago

Yes, that's what I was hoping would be possible - the app and bridge likely do exactly the same thing, though I'm not very impressed with the stability of the app. I'll play around with this when I have time, but I'm a n00b with python so would appreciate any hints wrt how to capture packets etc.

nayaverdier commented 2 years ago

If you have an android (maybe there's an iOS version as well, I'm not sure), I recommend this app: nRF Connect. When you open the avi-on app nRF Connect will notify asking whether you want to debug the connection. Within nRF Connect after connecting, you can go into the "Unknown Service" with id 0xFEF1 and then subscribe to the two characteristics c4edc000-9daf-11e3-8003-00025b000b00 and c4edc000-9daf-11e3-8004-00025b000b00.

At that point anything you do through the avi-on app should show up in the logs in nRF Connect (triple dot -> Show log). From there it's possible to decode the data with the csrmesh python library (and the device passphrase found in the API data), I can create some scripts to help with the decoding process.