Supereg / homebridge-http-switch

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

Homebridge starts but is in the "Home" app not available #14

Closed 420Dope closed 6 years ago

420Dope commented 6 years ago

When i add this

        {
          "accessory": "HTTP-SWITCH",
          "name": "Test",
          "switchType": "stateful",
          "onUrl": "http://localhost/api/switchOn",
          "offUrl": "http://localhost/api/switchOff",
          "statusUrl": "http://localhost/api/switchState",
          "pullInterval": "10000",
          "statusPattern": "false",
          "auth": {
          "username": "user",
          "password": "pass"
          }
        }

to my config, homebridge starts normal but is in the "Home" app not available. The pullInterval and statusPattern works.

Supereg commented 6 years ago

What do you mean exactly by „not available“? Does the bridge not respond? Also could you provide any logs?

myphill commented 6 years ago

I have the same problem. pullInterval & statusPattern works just fine. When i try to switch the device in the homekit app, the device itself says "no response" and the logfile of the homekit server says

Error occurred setting state of the switch: undefined

Supereg commented 6 years ago

Okay, thanks. That should help. Gonna look into it.

Supereg commented 6 years ago

Okay, so I couldn't reproduce it on my end. However I pushed an update v0.5.5 which prints some more output when an error occurs.

@myphill could you update a check for any error message printed after 'Error occurred setting state of the switch: undefined'. Also do you have any special configuration?

Also @420Dope are we dealing with the same issues here?

Supereg commented 6 years ago

Okay so. There was a little problem displaying the error message correctly. Fully fixed now. Now it's up to you to check the logs and look for the real issue. At this point it has to do something with the http request failing for whatever reason.

myphill commented 6 years ago

Hey Supereg,

thanks for the update. The new error-feedbacks helped me sort out my mistake. I found out that for some reason the controlled device throws a 404 only when i connect from the homebridge server. I have a php script on a webserver running anyway to pull the status so i control via the php script now too. So the issue is resolved for me now. Thanks very much :))

420Dope commented 6 years ago

Sorry for the delay. After the update you pushed, the issue is still there. I have install homebridge on Windows. So i have to figure out where the logs are, but i find nothing about it on google...

420Dope commented 6 years ago

Hmm i donˋt become a log. I start Homebridge in command prompt and there is no error for the „Test“ device. The statusPattern works correctly. When i controll the device manually and take it off, the statusPattern shows ot correctly. Here the log from the command prompt where you can see the correct statusPattern:

C:\Users\Administrator>homebridge
[2018-9-23 14:58:55] Loaded config.json with 75 accessories and 0 platforms.
[2018-9-23 14:58:55] ---
[2018-9-23 14:58:56] Loaded plugin: homebridge-http-switch
[2018-9-23 14:58:56] Registering accessory 'homebridge-http-switch.HTTP-SWITCH'
[2018-9-23 14:58:56] ---
[2018-9-23 14:58:57] Loaded plugin: homebridge-sonoff-tasmota-http
[2018-9-23 14:58:57] Registering accessory 'homebridge-sonoff-tasmota-http.SonoffTasmotaHTTP'
[2018-9-23 14:58:57] ---
[2018-9-23 14:58:57] Loading 75 accessories...
[2018-9-23 14:58:57] [Steckdose Schlafzimmer] Initializing SonoffTasmotaHTTP accessory...
[2018-9-23 14:58:57] [Steckdose Schlafzimmer] Sonoff Tasmota HTTP Initialized
[2018-9-23 14:58:57] [Test] Initializing HTTP-SWITCH accessory...
[2018-9-23 14:58:57] [Test] Switch successfully configured...
.
.
.
Setup Payload:
XXXXXX
.
.
.
Or enter this code with your HomeKit app on your iOS device to pair with Homebridge:

    ┌────────────┐
    │ XXX-XX-XXX     │
    └────────────┘

[2018-9-23 14:58:57] Homebridge is running on port 50983.
[2018-9-23 14:59:07] [Test] Switch is currently ON
[2018-9-23 14:59:17] [Test] Switch is currently ON
[2018-9-23 15:00:17] [Test] Switch is currently ON
[2018-9-23 15:00:27] [Test] Switch is currently ON
[2018-9-23 15:00:37] [Test] Switch is currently OFF
[2018-9-23 15:00:47] [Test] Switch is currently OFF
[2018-9-23 15:00:57] [Test] Switch is currently ON
[2018-9-23 15:01:07] [Test] Switch is currently ON

In the command prompt al looks ok. The statusPattern works and shows the correct state from the device when i controll it manually. But all devices in the homekit app says "no response".

I have seen the "debug": true mode in your example.json and have add this in the accessory.

        {
          "accessory": "HTTP-SWITCH",
          "name": "Test",
          "switchType": "stateful",
          "onUrl": "http://localhost/api/switchOn",
          "offUrl": "http://localhost/api/switchOff",
          "statusUrl": "http://localhost/api/switchState",
          "pullInterval": "10000",
          "statusPattern": "false",
          "debug": "true",
          "auth": {
          "username": "user",
          "password": "pass"
          }
        }

When i start homebridge the log from the command prompt shows that:

[2018-9-23 15:14:13] [Test] Body of status response is: '<?xml version="1.0" encoding="UTF-8"?>
<e2powerstate>
        <e2instandby>
false   </e2instandby>
</e2powerstate>
'
[2018-9-23 15:14:13] [Test] Switch is currently ON

So i think the response are correctly understand from your plugin. I hope it can help you with this info. I have no idea what i can do...

Supereg commented 6 years ago

Could reiterate what exactly the problem is? You said it is "not available in the Home App". What do you mean by that. Does the switch not appear in the Home App or is there some sort of connection problem? If the first case is true does the Homebridge device itself appear in the Home App?

420Dope commented 6 years ago

Yes sure. Normally without the „Test“ Device from my first post, homebridge works fine with my accessories. The „Home“ app shows all my devices and i can control the divices. When i add the „Test“ Device from my first post and start homebridge, the command promt log looks fine and shows no errors. The pullnterval and statusPattern also works correct (look my previous post). But when i open the „Home“ app now, the Homebridge device itself and all my devices are there and says "no response", the „Test“ device is not in the „Home“ app. I hope it is understandable explained and it helps a little bit.

420Dope commented 6 years ago

Oh man, i am so sorry. I hope i don‘t have waste your time. After multiple test a have delete the homebridge itself from the „Home“ app and have change the identity (by change the „username“) and add it new to the „Home“ app. Now it works, I am so embarrassed. But now, i must give the homebridge always a new identity when i change something in the json.config. It was not like that before, it is normal?

Supereg commented 6 years ago

Yeah, I though about something like that. Doesn’t seem to be a problem of the plugin rather a problem with homebridge itself. I‘m not really sure what’s causing that, however I already heard of some other people having experienced this sort of problem. Have a look at the homebridge repo, maybe there is already an issue for that.

I do know that the HAP specifications require homebridge to change some value in the TXT of the Bonjour entry. If I got some spare time I could maybe look into the code of homebridge which handles the appearance of new accessories.

If this issue is persistent you could help me out and send me the content of the Bonjour service of homebridge before and after you add an service/plugin which then won’t show up. To view all Bojour services in your network you can use an app like Discovery. There you can look under the „local“ domain for an entry of the type „_hap._tcp“ (I guess, something like that).

I‘m closing this issue for now. However you can of course still post the Bonjour records into this thread.

420Dope commented 6 years ago

Ok thank you. Maybe at the weekend or something like that i can install the app and send you the things from the app. I have a new feature, but i make a new thread for the overview.