mylylyl / homebridge-soma-shades

Homebridge plugin for SOMA Shades
8 stars 2 forks source link

Support SOMA Tilt v2 #9

Closed ebaauw closed 2 years ago

ebaauw commented 3 years ago

Is your feature request related to a problem? Please describe:

SOMA Tilt v2 seems to be discovered alright; accessory is created with Window Covering and Battery services, but it doesn't work. The log suggests the plugin doesn't like the services it exposes.

The TILT can be controlled from the SOMA app, and from the SOMA Connect bridge.

I made sure to close the SOMA app, and shut down the SOMA Connect bridge.

Describe the solution you'd like:

Support for the TILT v2, obviously.

Happy to contribute. I'm very experienced in Homebridge, but haven't done anything Bluetooth before. Where did you get the Bluetooth API for the Shades?

Describe alternatives you've considered:

Native SOMA Connect bridge exposes the SOMA Tilt v2 alright, but no Battery service. Also they defined the Close Upwards and Morning Mode characteristics as write-only. I don't know any HomeKit app that likes that.

The Connect bridge is based on HAP-NodeJS alright, but they seem to have packed everything into a single executable - I cannot find any Javascript files to tamper with.

Additional context:

[Jul 29 23:12:54] [Soma] Launched child bridge with PID 21061
[Jul 29 23:12:54] [Soma] Loaded homebridge-soma-shades v1.2.0 child bridge successfully
[Jul 29 23:12:54] [Soma] Finished initializing platform
[Jul 29 23:12:54] [Soma] on DID_FINISH_LAUNCHING. Looking for new accessories
[Jul 29 23:12:54] [Soma] delay discovery for 15 seconds
[Jul 29 23:13:09] [Soma] noble is not running. waiting for it to power on...
[Jul 29 23:13:09] [Soma] noble is powered on
[Jul 29 23:13:09] [Soma] start noble scanning
[Jul 29 23:13:09] [Soma] peripheral xxxxxxxxxxxx is not in config
(...)
[Jul 29 23:13:22] [Soma] peripheral xxxxxxxxxxxx is not in config
[Jul 29 23:13:23] [Soma] discovered peripheral f87e821702d6, adding to accessories
[Jul 29 23:13:23] [Soma] adding new accessory: Office
[Jul 29 23:13:23] [Soma] peripheral f87e821702d6 is not connected to get info characteristics
[Jul 29 23:13:23] [Soma] peripheral f87e821702d6 is not connected
[Jul 29 23:13:23] [Soma] discovered all peripherals
[Jul 29 23:13:23] [Soma] peripheral f87e821702d6 is connected
[Jul 29 23:13:23] [Soma] peripheral f87e821702d6 is not initialized
[Jul 29 23:13:23] [Soma] peripheral f87e821702d6 is getting services
[Jul 29 23:13:23] [Soma] peripheral f87e821702d6 disconnected
[Jul 29 23:13:33] [Soma] peripheral f87e821702d6 failed to discover services: Error: timed out
[Jul 29 23:13:33] [Soma] peripheral f87e821702d6 has invalid services
[Jul 29 23:13:33] [Soma] accessory Office failed to get device information: Error: invalid services
[Jul 29 23:15:30] [Soma] Office failed to set position because shade is at 0 already
[Jul 29 23:15:30] [Soma] moving Office up to 1
[Jul 29 23:15:30] [Soma] peripheral f87e821702d6 is not connected for getTargetPosition
[Jul 29 23:15:30] [Soma] peripheral f87e821702d6 is not connected
[Jul 29 23:15:39] [Soma] moving Office up to 61
[Jul 29 23:15:39] [Soma] peripheral f87e821702d6 is not connected
[Jul 29 23:15:39] [Soma] peripheral f87e821702d6 is not connected for getTargetPosition
[Jul 29 23:15:40] [Soma] peripheral f87e821702d6 failed to connect Error: timed out
[Jul 29 23:15:40] [Soma] Office failed to set target position: Error: Error: timed out
[Jul 29 23:15:49] [Soma] peripheral f87e821702d6 failed to connect Error: timed out
[Jul 29 23:15:49] [Soma] Office failed to set target position: Error: Error: timed out
[Jul 29 23:15:57] [Soma] peripheral f87e821702d6 disconnected
[Jul 29 23:15:57] [Soma] peripheral f87e821702d6 disconnected
ebaauw commented 3 years ago

As other alternative, I'm considering writing a plugin against the HTTP API provided by the SOMA Connect bridge. I don't think that Homebridge will run on the same Pi as the Connect bridge though; the soma-connect executable seems to open the mDNS port 5353 exclusively.

They don't provide any notifications, so I would need to poll the Connect bridge. The HTTP API doesn't provide a single call to get the state of all devices. Even position and battery for a single device need to be read using two different calls. A plugin against the HTTP API will be an interesting stress test for the Connect.