homebridge-http-switch icon indicating copy to clipboard operation
homebridge-http-switch copied to clipboard

Handling timeouts gracefully

Open ashishgururani opened this issue 3 years ago • 3 comments

I have the following...

"accessories": [
        {
            "accessory": "HTTP-SWITCH",
            "name": "Fireplace",
            "switchType": "stateful",
            "timeout": 2000,
            "onUrl": "http://10.1.1.90/api/switchOn",
            "offUrl": "http://10.1.1.90/api/switchOff",
            "statusUrl": "http://10.1.1.90/api/switchStatus"
        }
    ],

If this device is unplugged or unreachable, everything in homebridge/home app goes red with "No Response". Is there something that can be done to handle the timeout gracefully? I first didn't have the timeout attribute and it was doing the same thing. I thought adding 2 seconds might help but the behavior is the same.

Otherwise everything works great. Thanks for your support in creating this very useful plugin!

ashishgururani avatar Nov 20 '20 15:11 ashishgururani

So your issue is that the API endpoint (the device 10.1.1.90) is offline "sometimes" right? And you want the http switch plugin to just ignore that and server the last known state?

Supereg avatar Dec 04 '20 11:12 Supereg

Thank you for responding. Essentially yeah, currently when the API endpoint (the device 10.1.1.90) is sometimes offline, all other devices on the homebridge say "No response". I have like 20 devices from smarthings plugin, 1 device from myQ garage opener and 6 devices from ring alarm plugin connected to homebridge. I would like this scenario to be handled gracefully - I think homebridge is single threaded and if the call is stuck on this plugin all the other ones show "No response" also. When the endpoints cannot be reached I would like it to timeout (within the specified timeout value) - what it does then I am not that particular about - it could return with Error or No Response or the previous status or something else - the important part is that is returns with something so it does not hold up the other plugins.

I quickly looked over the code, I see some timeout being used but it looks like it is used only for stateless.

ashishgururani avatar Dec 04 '20 15:12 ashishgururani

I think this is fixed now. Not sure if something was done to the code but appears to be working better lately. Now, only this device says "No Response" and the other devices are fine in the home app. Thank you if you did something! Well, Thank you regardless for the great plugin.

ashishgururani avatar Jan 14 '22 16:01 ashishgururani