Supereg / homebridge-http-switch

Powerful http switch for Homebridge: https://github.com/homebridge/homebridge
ISC License
218 stars 36 forks source link

Config question #38

Closed AKWillows closed 4 years ago

AKWillows commented 5 years ago

Describe the bug I am trying to use a switch to send an http command to a local URL.

Expected behavior I was expecting that when switching the switch "On" on HomeKit, it would send the URL and then switch off after a set amount of time

To Reproduce Steps to reproduce the behavior: Switch the switch "on"

Version (output of npm list -g homebridge homebridge-http-switch)

Configuration "accessories": [ { "accessory": "HTTP-SWITCH", "name": "Night Switch", "switchType": "stateless", "timeout": 10, "onUrl": "http://_username:password_@192.168.1.44/api/HomebridgeTEST" } ],

Additional context It does not appear to send the http command. Here is the details from the Homebridge Log file [9/12/2019, 4:12:51 PM] [Night Switch] Error occurred setting state of switch: ESOCKETTIMEDOUT [9/12/2019, 4:12:51 PM] [Night Switch] { Error: ESOCKETTIMEDOUT at ClientRequest. (/usr/local/lib/node_modules/homebridge-http-switch/node_modules/request/request.js:816:19) at Object.onceWrapper (events.js:286:20) at ClientRequest.emit (events.js:198:13) at Socket.emitRequestTimeout (_http_client.js:662:40) at Object.onceWrapper (events.js:286:20) at Socket.emit (events.js:198:13) at Socket._onTimeout (net.js:442:8) at ontimeout (timers.js:436:11) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) code: 'ESOCKETTIMEDOUT', connect: false } [9/12/2019, 4:12:51 PM] [Night Switch] Resetting switch to OFF

Supereg commented 5 years ago

Have you any other information about your web service. It seems that your http server doesn't respond in time (or isn't accessible at all). How long does it take until the error appears? Does it appear immediately when your toggle your switch to on?

Supereg commented 5 years ago

Any updates regarding your problem?

inseidler commented 4 years ago

Hi Supereg, I have an config issue as well I would like to read out the state from an xml :

This is written in the XML: TCW181B-CM 00:04:A3:AA:21:40 TCW181B-CM 3.07 Status Gara CLOSED 0 Hoftor OFF 2.0 Garage OFF 1.5 Haustür OFF 2.0 Licht OFF 2.5 OFF 2.0 OFF 2.0 OFF 2.0 OFF 1.0

I would like the part were it says closed or open to be interpreted. The commands to open the garage via http works fine! Hope to get support from you! The xml can be found via http://192.168.1.9/status.xml

I have tried with this config:

"accessory": "HTTP-SWITCH", "name": "Garagentor", "checkStatus": "polling", "pollingInterval": 10000, "statusUrl": "http://192.168.1.9/status.xml", "statusRegex": "^.off.: CLOSED.*$", "switchType": "stateless", "timeout": 500, "onUrl": "http://192.168.1.9/status.xml?pl2=1", "httpMethod": "GET"

Supereg commented 4 years ago

I'm not quite sure which part of your XML should represent the garage state. But your 'statusRegex' should first of all be named statusPattern and secondly you encoring that your given string will begin with ('^') and end with the given pattern ('$'). So assuming that the status is represented at the part Status Gara CLOSED you could just write Status Gar OPEN if the switch should be turned on when this string is contained in the response.