webdeck / homebridge-indigo

Homebridge Plugin for Indigo
Apache License 2.0
13 stars 6 forks source link

Question: Can events work? #7

Closed brendanjerwin closed 7 years ago

brendanjerwin commented 8 years ago

Is it possible to get switch change events to Homekit?

webdeck commented 8 years ago

The next feature I will be working on is having a companion plugin in Indigo that can notify homebridge of device state changes (since there is no good way to do that via the RESTful API.)

brendanjerwin commented 8 years ago

so looking forward to it!

ghost commented 7 years ago

Would that also possibly enable motion detectors, such as the EagleEye?

blysik commented 7 years ago

I have that question also. Is the work you're doing going to allow motion detectors to work? Thanks!

kcjonson commented 7 years ago

I don't know how feasible this is, but if the homebridge-indigo could start a small a basic HTTP server that listens for POST requests detailing change updates, it might be relatively trivial to get Indigo to play along. I've been playing around with getting events out of Indigo into a node process, and for the sake of experimentation wrote a small Applescript snippet that can be used as an action

set brightLevel to brightness of device "Master Bathroom Overhead Lights"
do shell script "curl -d '{\"addressStr\":\"18.EB.92\", \"property\":\"brightness\", \"value\":\"" & brightLevel & "\"}' -H 'Content-Type: application/json' http://localhost/api/indigo/push"

Since I've never written a lick of python creating a plugin that would do this for all devices is a bit out of my reach, but it illustrates that if the plugin could listen for changes in such a manner, communication is pretty quick. Certainly a better alternative to polling the device api.

My thought is that the task of getting device events to work is twofold 1) Make the homebridge plugin open an http port and define an api to be notified of changes 2) Convince Indigo to post these changes without having to paste around a bunch of Actionscript for every device.

kcjonson commented 7 years ago

Hum, you seem to be one step ahead of me

    // Start the accessory update listener, if configured
    if (config.listenPort) {
        this.app = express();
        this.app.use(bodyParser.json());
        this.app.use(bodyParser.urlencoded({ extended: true }));
        this.app.get("/devices/:id", this.updateAccessory.bind(this));
        this.app.post("/devices/:id", this.updateAccessoryFromPost.bind(this));
        this.app.listen(config.listenPort,
            function() {
                this.log("Listening on port %d", config.listenPort);
            }.bind(this)
        );
    }

Is this actually working?

webdeck commented 7 years ago

Yes, support is complete in homebridge-indigo. Colorado Fourwheeler is working on the Homebridge Buddy Indigo plugin to use it.

kcjonson commented 7 years ago

Awesome, glad to hear that! Sorry for thinking aloud and causing notification chatter.