kvj / hass_nuki_ng

Better support for Nuki devices in the Home Assistant
MIT License
176 stars 33 forks source link

Callback not working (only polling) #42

Closed hnykda closed 2 years ago

hnykda commented 2 years ago

Hi,

my understanding was that the mentioned callback should update the sensors states (e.g. door state sensor) immediately after the door is open/closed.

Unfortunately, even though the callback is listed in callbacks and the state is updated via polling (e.g. if I keep the door open for >30 secs - the default polling interval - the door state sensor is changed), the update isn't immediate (which is what I would like to achieve).

Is there a way how to get "immediate" updates of sensors?

alexdelprete commented 2 years ago

All users have immediate updates, when the callback is working, this was the primary reason why the component was developed. Your problem is that the callback isn't working, but if you don't provide info we can't try to help you. Check logs for errors, and make sure HA is not hardened via SSL on local network: the bridge can't call an https url, it's a limitation of the bridge.

hnykda commented 2 years ago

Got it, sorry, I just wasn't sure. Thanks for a quick response! I am not using HTTPS/SSL and the address in the callback looks correct. What info would you please need?

This is what the callback shows (the second one is the right one, first one is some old one). image ) Nothing is logged in the logs.

hnykda commented 2 years ago

I removed the previous callback (so only the one with ID1 is there) but the result is still the same. Nothing is logged in Core logs.

If I open the door for 5 sec and then close them, it is not recognized. I have to keep them for longer time (that 30 secs is close) for HA to pick it up.

hnykda commented 2 years ago

Ha, now looking at the callback, it doesn't have the right port in it :facepalm:

hnykda commented 2 years ago

OK, that was it. Apologies. But I would propose mentioning this in the README - I used the default "discovered" default values when adding the integration and the IP was correct, but the port wasn't there. Thank you a lot for helping!

alexdelprete commented 2 years ago

Ha, now looking at the callback, it doesn't have the right port in it 🤦

From your screenshot, the callback has 8123, it was autodetected but it was wrong? Strange...are you using a proxy or something?

hnykda commented 2 years ago

The first callback was wrong, that was from old Nuki card. The second one was the one added by this integration and that one has :8123 missing at the end of the IP. When I added :8123 to the Homeassistant URL when setting up the integration, I got it working.

I am not using any proxy or anything.

alexdelprete commented 2 years ago

In the post above, where you posted the screenshot, I see 8123, but in that post you say it's not working...

hnykda commented 2 years ago

The callback#0 has it in, but that's some very old callback IP that is wrong (it has 8123 in it, but the IP is wrong). The second one has correct IP (192.168.0.202) but it's missing the port.

alexdelprete commented 2 years ago

Sorry, I didn't notice the second callback.

The callback list has to have 1 entry, the one configured by the component. And it has to have the correct ip/port. That's the basic thing to check when debugging callback issues. If you notice multiple entries, there's a problem...

We should enforce callback list checks in the component, making sure the callback is correct and avoid multiple callbacks or at least making sure the component's callback is in first position.

hnykda commented 2 years ago

Agree, that would likely make it much safer. At least mentioning it in Readme could be probably a good idea. e.g. one could also simply try to ping the callback via curl (that's how I realized it's wrong)

alexdelprete commented 2 years ago

Well...the root cause of the problem is almost always the fact that users don't check the configuration before submitting. You didn't notice that the port was missing, otherwise it would've worked since the beginning. Autodetection is a feature to assist the user while configuring the component, but you always need to double-check what is detected. BTW: the fact that it detected the url without the port is really strange...did you configure internal_url and external_url in HA config?

Having said that, config control would be a wise thing to have less issues here. :)

hnykda commented 2 years ago

did you configure internal_url and external_url in HA config?

You are right - I did configured that there and without the port. So that was it. Thanks for your help and great work :bow:

alexdelprete commented 2 years ago

Thanks for confirming this.