Supereg / homebridge-http-switch

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

getting esclamation mark in home app when clicking on switch icon #39

Closed dreale1 closed 5 years ago

dreale1 commented 5 years ago

Hi all

I am using http-switch to open/close my blinds (did not find anything better to steer the as they do not send back their position so i can only either open or close them with 2 different switches)

I use stateless-reverse mode and everything works fine besides that i get esclamation marks in the home app when I click on the icons (they still work fine)... the esclamation marks remain displayed after i clicked on it but go away when i exit and enter again the home app. However, esclamation mark comes back as soon as i Click again on it...

Does anybody know how I could get rid of the esclamation marks?

following my json file:

"bridge": {
    "name": "xsxsxsx",
    "username": "xsxsxsx",
    "port": xsxsx,
    "pin": "xxx-xx-xxx"
},
"accessories": [
    {
        "accessory": "HTTP-SWITCH",
        "name": "Switchon_EG",
        "switchType": "stateless-reverse",
        "offUrl": {
            "url": "http://xxx.xx.1.1xx/zrap/chctrl/ch1/",
            "method": "POST",
            "body": "cmd=on"
        }
    },

    {
        "accessory": "HTTP-SWITCH",
        "name": "Switchoff_EG",
        "switchType": "stateless-reverse",
        "offUrl": {
            "url": "http://xxx.xx.1.1xx/zrap/chctrl/ch1/",
            "method": "POST",
            "body": "cmd=off"
        }
    }

and a picture of my home app with the esclamation mark on the icon: IMG_2994

Supereg commented 5 years ago

Is there any derailed information when you open the settings page of the switch? Any message which explains the exclamation mark? Also did you find any log messages when you switching to on/off? The actual http request seems to get send though, doesn’t it?

dreale1 commented 5 years ago

When I open the settings page, I get a "No Response" Information. But as said, the switch works with no problem, the actual http request seems to get through every time:

ZU

Where can I find log messages? in Raspberry itself?

thanks

Supereg commented 5 years ago

Okay it seems like everything is fine until the http request is sent however after that the HomeKit request somehow fails.

For viewing logs the following command can be used: sudo journalctl -n 200 -f which displays pretty much all log messages your Pi is producing, starting by displaying the last 200 lines ('-n 200') and following/waiting for new entires ('-f'). So keep this open and watch when you press the button in the Home App. Also consider enabling the debug property in the configuration of the switch plugin in order to receive a more detailed view of what is happening. Any log output will be helpful. Though check that you don't include any personal data like passwords or something.

dreale1 commented 5 years ago

Thanks Andi, will check tonight

dreale1 commented 5 years ago

Hi , this is what i get in the log:

Sep 30 18:01:55 raspberrypi sudo[4255]: pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/bin/journalctl -n 200 -f Sep 30 18:01:55 raspberrypi sudo[4255]: pam_unix(sudo:session): session opened for user root by pi(uid=0)

However, when I start HomeBridge, I get following messages


**Or enter this code with your HomeKit app on your iOS device to pair with Homebridge:
┌────────────┐
│ xxx-xx-xxx │
└────────────┘

events.js:183 throw er; // Unhandled 'error' event ^

Error: listen EADDRINUSE :::51826 at Object._errnoException (util.js:1022:11) at _exceptionWithHostPort (util.js:1044:20) at Server.setupListenHandle [as _listen2] (net.js:1351:14) at listenInCluster (net.js:1392:12) at Server.listen (net.js:1476:7) at EventedHTTPServer.listen (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/eventedhttp.js:60:19) at HAPServer.listen (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:158:20) at Bridge.Accessory.publish (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:607:16) at Server._publish (/usr/local/lib/node_modules/homebridge/lib/server.js:126:16) at Server. (/usr/local/lib/node_modules/homebridge/lib/server.js:382:14)**


Besides these error messages, all plugins still work perfectly

any help is appreciated!

Supereg commented 5 years ago

The log messages are completely unrelated to homebridge.

However, when I start HomeBridge, I get following messages

You started homebridge by hand? Seems like homebridge is already running.

How did you install homebridge. Did you install it as a service? Or is homebridge started via an alternative method?

dreale1 commented 5 years ago

The log messages are completely unrelated to homebridge.

This is strange as I can verify by the time stamp that this was logged when I clicked on the icon... How should a log entry look like?

Homebridge is running Forever with package Forever:

Package Current Wanted Latest Location forever 0.15.3 0.15.3 1.0.0 homebridge 0.4.38 0.4.50 0.4.50 homebridge-fhem 0.4.5 0.4.19 0.5.8 npm 5.6.0 5.10.0 6.11.3

But I started HomeBridge additionally by hand via SSH to check on the error messages i posted in my comment.

Regarding your last question on how HomeBridge is installed... I actually don't know... I just installed it with a procedure found on the internet... sorry for my ignorance... can I check this somehow?

Supereg commented 5 years ago

Regarding your last question on how HomeBridge is installed... I actually don't know... I just installed it with a procedure found on the internet... sorry for my ignorance... can I check this somehow?

You did answer this question with the information above (Homebridge is running Forever with package Forever)

My command for viewing the logs assumed you have installed homebridge as a systemd service, but nevermind. I'm currently checking how exactly you can view log files with forever. It seems there is an command for logs.

dreale1 commented 5 years ago

Thanks a lot!

I added debug function in Json file, following the entries when loading homebridge:

[2019-9-30 18:51:42] [Switchon_wohnen] Initializing HTTP-SWITCH accessory...
[2019-9-30 18:51:42] [Switchon_wohnen] Switch successfully configured...
[2019-9-30 18:51:42] [Switchon_wohnen] Switch started with the following options: 
[2019-9-30 18:51:42] [Switchon_wohnen]   - switchType: stateless-reverse
[2019-9-30 18:51:42] [Switchon_wohnen]   - offUrls: [{"url":"http://xxx.xxx.x.xx/xxxxx/xxxxx/xxx/","method":"POST","body":"cmd=open","repeat":1,"delayBeforeExecution":0,"auth":{"sendImmediately":true},"headers":{},"strictSSL":false,"requestTimeout":20000}]
[2019-9-30 18:51:42] [Switchon_wohnen]   - timeout for stateless switch: 1000

maybe this helps?

Supereg commented 5 years ago

Ah, thanks. Seems you managed to read log files yourself. Great. I'm currently not interested in the startup messages. More interesting would be any log messages which appear right when you are turning the switch on/off in the Home App. Could you check for that. Since that's the point where the error occurs.

dreale1 commented 5 years ago

question is how... once homebridge is running i don't get any log info anymore (besides the 2 lines I got using command sudo journalctl -n 200 -f

also using DEBUG=* homebridge -D does not help, it only shows the detailed info during startup of homebridge but not when it is running...

Supereg commented 5 years ago

The global debug option is not really useful currently. So no need to specify it.

Hold. Could you please explain to me how exactly you are running homebridge, so I can better instruct you how to view log messages. Using forever or just with the command line?

dreale1 commented 5 years ago

using forever. In the case I have to reboot my Pi, I never need to start Homebridge via command line, it automatically starts

dreale1 commented 5 years ago

Hi Andi, I think I have it now, had to stop homebridge completely with sudo systemctl stop homebridge

and restart. following now the log when clicking on the icon:

[2019-9-30 21:06:05] [Switchoff_EG] setStatus() doing http request...
[2019-9-30 21:06:05] [Switchoff_EG] Error occurred setting state of switch: HTTP request returned with error code 302
[2019-9-30 21:06:05] [Switchoff_EG] Resetting switch to ON
[2019-9-30 21:06:11] [Switchon_EG] setStatus() doing http request...
[2019-9-30 21:06:11] [Switchon_EG] Error occurred setting state of switch: HTTP request returned with error code 302
[2019-9-30 21:06:11] [Switchon_EG] Resetting switch to ON
[2019-9-30 21:06:13] [Switchoff_EG] setStatus() doing http request...
[2019-9-30 21:06:13] [Switchoff_EG] Error occurred setting state of switch: HTTP request returned with error code 302
[2019-9-30 21:06:13] [Switchoff_EG] Resetting switch to ON
dreale1 commented 5 years ago

according to the API of the blinds, a POST method returns always 302 as status code, but it is not an error code... is this the problem?

Screenshot 2019-09-30 at 21 23 39
Supereg commented 5 years ago

A bit. The plugin currently expects 2xx status codes as those are all considered success.3xx status codes are representing different redirect statuses and thus the plugin does not really handle those as success codes. Why the heck does this http api return 302 😂😅

The only solution is probably for me to edit the status code handling 🤔

dreale1 commented 5 years ago

very strange indeed! 😅

But I am happy that we found the source of the problem! THANKS again for your help!

would be great if you can change something in the code handling... How big is the probability of success?

Supereg commented 5 years ago

v0.5.26 is live now, which will accept http responses with 3xx redirect codes

dreale1 commented 5 years ago

Thanks Andi, works perfectly now!! let me know how I can buy you some beers (maybe via PayPal?)

Supereg commented 5 years ago

Definitely not necessary, but if you want: https://www.paypal.me/Supereg Thanks, no problem.