rudders / homebridge-http

HTTP Plugin for Homebridge
Apache License 2.0
178 stars 110 forks source link

Status not working? #92

Open jcalmeida opened 5 years ago

jcalmeida commented 5 years ago

Hi,

I have my RaspberryPi 3 B+ with the homebridge and homebridge-http plugin to control my lights.

The On and Off features work perfectly, but I noticed that if I turned on the lights in the switch, the Home app didn't sync, saying the lights are off when they're on, so I created a new endpoint for the status_url.

This is my homebridge config.json file: _{ "bridge": { "name": "Pi Homebridge", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "123-45-678" }, "platforms": [ ], "accessories": [ { "accessory": "Http", "name": "Hall Lamp", "on_url": "http://raspberrypi.local:3000/home-api/lights/hall?state=on", "off_url": "http://raspberrypi.local:3000/home-api/lights/hall?state=off", "status_url": "http://raspberrypi.local:3000/home-api/lights/hall/state", "status_on": { "status":"1" }, "status_off": { "status":"0" }, "httpmethod": "GET" } ] }

My http://raspberrypi.local:3000/home-api/lights/hall/state endpoint returns a json response like this: {"device":"lights","division":"hall","status":"0","message":"00010001 00000010"}, where status is "0" or "1".

My API logs are not detecting this endpoint being called. I assumed it was called when I opened the Home App, am I wrong? I can't seem to find the logs for the plug-in, only for the homebridge. Is there a different place rather than the homebridge.err and homebridge.log?

I'm running version 0.0.9 of the plugin, or at least is what sudo npm install -g homebridge-http gives me. However, index.js doesn't seem to be fully updated. It contains "this.status_url = config["status_url"];" but it doesn't contain " this.status_on = config["status_on"];"... weird.

Can anyone share any knowledge about this issue? Thank you.

jcalmeida commented 5 years ago

Update: I've updated manually my index.js to match the newest one. Can't figure out how to get it updated with npm install.

I've been looking through the code, and for what I've seen, I have to set "switchHandling": "yes", for it to call my status api everytime it opens the app.

So, now I'm a little bit closer to the solution, because my system is returning the correct state (on), but the home app is still showing the wrong state (off).

I'll keep you posted.

jcalmeida commented 5 years ago

Ok, there seems to be an issue with the custom json response. I think I had it configured correctly, but it wasn't working. As soon as I changed my response to just "1" or "0", and set the config file accordingly, it started to work.

I'll keep the issue open, waiting for your comments, because I would like to have the json response instead of the simple 1 or 0.

Thanks.

vesley commented 4 years ago

I have the same issue. My status URL responds with a JSON string. I configured the config.json with the correct filter. I see this on the log:

[beleuchtung] Power state is currently NaN

Is there anyway to debug the plugin?

jcalmeida commented 3 years ago

fixed on the latest version. Note: when install, use the git version, not the repository one. It still hasn't been released