filipvh / hass-nhc2

Niko Home Control II Home Assistant Integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I cannot connect- connection refused

Gavergracht opened this issue · comments

This is what I get when I want to connect : Verbinding geweigerd - niet geautoriseerd. Someone an idea ?

You are connecting with the NHC Hobby API login details? Not your NHC logins?

You are connecting with the NHC Hobby API login details? Not your NHC logins?

yes, I did. maybe something wrong with MQTT ? i am a noob, so maybe it is wrong istalled by me ? Can I test it ?

I've just updated my HA and nhc2 with the latest versions (from HA 2021.5.4 to HA 2021.9.6) and I am also now getting 'Connection refused - not authorised'. I know my credentials are correct (see below).
Here's what the log says - not very helpful.
2021-09-16 09:21:33 ERROR (Thread-4) [root] Uncaught thread exception Traceback (most recent call last): File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/local/lib/python3.9/threading.py", line 910, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3452, in _thread_main self.loop_forever(retry_first_connection=True) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1779, in loop_forever rc = self.loop(timeout, max_packets) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1181, in loop rc = self.loop_read(max_packets) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1572, in loop_read rc = self._packet_read() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 2310, in _packet_read rc = self._packet_handle() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 2942, in _packet_handle return self._handle_connack() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3029, in _handle_connack self.on_connect( File "/usr/local/lib/python3.9/site-packages/nhc2_coco/coco.py", line 120, in _on_connect raise Exception(MQTT_RC_CODES[rc]) Exception: Connection refused - not authorised

I've done some investigating by taking some of the example tests from nhc2-coco and running them on the same box as my HA is running on, with the same credentials, and they work fine. Therefore it looks like something to do with HA, or how nhc2-coco runs within HA. I will have a look on the HA forums, but does anyone have any ideas what's going on here please?

SOLVED - for me at least.

In the end, all I did was delete the Niko integration from the 'Integrations' tab only, restarted HA, and all the devices magically came back. I had to put them all back in their areas etc, but that's not too big a deal even with 74 devices.

I did not remove the nhc2 folder in custom_components or the entry in configuration.yaml before restarting, and I did not have to reinstall the integration after restarting - it was just there.

I would love to know why this happened!

SOLVED - for me at least.

In the end, all I did was delete the Niko integration from the 'Integrations' tab only, restarted HA, and all the devices magically came back. I had to put them all back in their areas etc, but that's not too big a deal even with 74 devices.

I did not remove the nhc2 folder in custom_components or the entry in configuration.yaml before restarting, and I did not have to reinstall the integration after restarting - it was just there.

I would love to know why this happened!

What code is in your config.yaml ?

My config is very simple:
nhc2: host: 192.168.1.51 port: 8884 username: "hobby" password: "**my very long api password**"

Note that if you had the wrong password you would get a different error. My guess is that somehow HA was trying to connect twice, and not allowing the second (correct) connection.

Have you tried removing the Niko integration?

As part of fault finding this, I used MQTT Explorer on my Windows PC to connect to the NHC2 to check that my credentials were accepted. Then I made a simple test program based on nhc2-coco and tested the connectiion outside of HA, on Windows then on the Linux box running HA. Thus I was able to establish that HA was the problem. Let me know if you would like more details, I know how frustrating this problem is!

My config is very simple:
nhc2: host: 192.168.1.51 port: 8884 username: "hobby" password: "**my very long api password**"

Note that if you had the wrong password you would get a different error. My guess is that somehow HA was trying to connect twice, and not allowing the second (correct) connection.

Have you tried removing the Niko integration?

As part of fault finding this, I used MQTT Explorer on my Windows PC to connect to the NHC2 to check that my credentials were accepted. Then I made a simple test program based on nhc2-coco and tested the connectiion outside of HA, on Windows then on the Linux box running HA. Thus I was able to establish that HA was the problem. Let me know if you would like more details, I know how frustrating this problem is!

I haven't an integration at all, nothing works...

in config.yaml I added

nhc2:

  • host: 192.168.0.236
  • port: 8884
  • username: "hobby"
  • password:

but the code has faults in it ( I just started with HA and I am no programmer so I dont know anything from code)

You say 'the code has faults in it', can you give more details?
Some log extracts might help

OK. code is working now, thanks for helping me

How did you solve this error? (Connection refused - not authorised)
I read here and there that you don't need an API account but simply a "default" which is the profile for the touchscreen of Niko?
BUt here, I read you need a Niko API account?
Thx for any help.