elupus / hass_nibe

Home Assistant Nibe Uplink Integration
183 stars 54 forks source link

Nibe HACS integration failed #80

Closed papagooo closed 3 years ago

papagooo commented 3 years ago

Hi Unfortunately I was not able after a long trial and error phase to successfully install and use nibe uplink. Instruction is not really helpfull as a lot of steps are not specifically described and if s.th. happens that differs from the minimal description provided one is lost. Well, this is the first integration that I could not get to run.

Operating System: HassOS 4.17 HA: 0.118.5

Logger: aiohttp.server Source: custom_components/nibe/config_flow.py:68 First occurred: 8:09:36 PM (3 occurrences) Last logged: 8:11:11 PM

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request resp = await self._request_handler(request) File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle resp = await handler(request) File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 136, in post return await super().post(request) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 60, in wrapper result = await method(view, request, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 69, in post result = await self._flow_mgr.async_init( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 130, in async_init result = await self._async_handle_step( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 213, in _async_handle_step result: Dict = await getattr(flow, method)(user_input) File "/config/custom_components/nibe/config_flow.py", line 68, in async_step_user config = self.hass.data[DATA_NIBE].config KeyError: 'nibe'

elupus commented 3 years ago

Add an empty nibe section in your config.

papagooo commented 3 years ago

restartet from scratch.

  1. added empty nibe section in your config
  2. configured Uplink parameter with my credentials from nibe api web page
  3. restartet HA

Don't see any nibe device.

Log again: Logger: homeassistant.config_entries Source: custom_components/nibe/init.py:280 First occurred: 10:40:11 PM (1 occurrences) Last logged: 10:40:11 PM

Error setting up entry for nibe aiohttp.client_exceptions.ClientResponseError: 404, message="{'httpStatusCode': 404, 'errorCode': 2, 'timestamp': '2020-12-15T21:40:10.6035347Z', 'details': ['The system was not found'], 'data': None}", url=URL('https://api.nibeuplink.com/api/v1/systems/6765420268002')

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 236, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/config/custom_components/nibe/init.py", line 227, in async_setup_entry await async_setup_systems(hass, data, entry) File "/config/custom_components/nibe/init.py", line 176, in async_setup_systems await asyncio.gather(*tasks) File "/config/custom_components/nibe/init.py", line 280, in load self.system = await self.uplink.get_system(self.system_id) File "/usr/local/lib/python3.8/site-packages/nibeuplink/uplink.py", line 175, in get_system return await self.get(f"systems/{system_id}") File "/usr/local/lib/python3.8/site-packages/nibeuplink/uplink.py", line 73, in get return await self.session.request( File "/usr/local/lib/python3.8/site-packages/nibeuplink/session.py", line 186, in request await raise_for_status(response) File "/usr/local/lib/python3.8/site-packages/nibeuplink/session.py", line 26, in raise_for_status raise UplinkResponseException(data.get("errorCode"), data) from e nibeuplink.exceptions.UplinkResponseException: UNKNOWN_SYSTEM: Unknown system. {'httpStatusCode': 404, 'errorCode': 2, 'timestamp': '2020-12-15T21:40:10.6035347Z', 'details': ['The system was not found'], 'data': None}

elupus commented 3 years ago

It seems the system identifier used was wrong above.

nbeernink commented 3 years ago

I'm getting a similar error. After adding the repo in HACS, I try to add the integration and get the config flow error before I am able to enter the credentials.

Empty nibe key is present in configuration.yaml and hassio has been restarted.

I can view heatpump info via the android app and website so I presume my connection string is set up correctly.

elupus commented 3 years ago

Please check log for errors.

nbeernink commented 3 years ago
Logger: aiohttp.server
Source: helpers/network.py:117
First occurred: 18 March 2021, 18:16:55 (2 occurrences)
Last logged: 8:04:37

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 129, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 117, in post
    return await super().post(request)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 60, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 69, in post
    result = await self._flow_mgr.async_init(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 133, in async_init
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 216, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/config/custom_components/nibe/config_flow.py", line 66, in async_step_user
    url = "{}{}".format(self.hass.helpers.network.get_url(prefer_external=True), AUTH_CALLBACK_URL)
  File "/usr/src/homeassistant/homeassistant/helpers/network.py", line 117, in get_url
    raise NoURLAvailableError
homeassistant.helpers.network.NoURLAvailableError

The callback-url should be set in the config flow though? Which seems to error out. Perhaps this is a different issue?

elupus commented 3 years ago

Absolutely a different issue. You don't have any external url set for home assistant. I'm a bit surprised about the error though. It should should find out where your browser is accessing from. You don't have some proxy in between or something?

nbeernink commented 3 years ago

Thank you elupus. :) I did some more research and figured it out. Described my problem in #88 It's definitely not related to this issue.

Anders7107 commented 3 years ago

Hi,

First of all, I´m entirely new to this like You will probaly understand from my questions and deeds. But somehow I managed to set up Home Assistant on a Raspberry Pi and to my surprise it worked and I could see different sensors and things around the house, everything from Netatmo readings to information from my Brother printers and MFC units.

I was able to set up HACS and implement Nibe as a custom integration. But when I try to add it into integrations in Home Assistant I´m out of luck. First try I get a fault message and second time I try the installation just keeps going in a never ending loop.

This is what I get from the log:

Logger: aiohttp.server Source: custom_components/nibe/config_flow.py:68 First occurred: 6:09:40 PM (1 occurrences) Last logged: 6:09:40 PM

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request resp = await self._request_handler(request) File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle resp = await handler(request) File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 129, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 117, in post return await super().post(request) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 60, in wrapper result = await method(view, request, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 69, in post result = await self._flow_mgr.async_init( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 133, in async_init result = await self._async_handle_step( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 216, in _async_handle_step result: Dict = await getattr(flow, method)(user_input) File "/config/custom_components/nibe/config_flow.py", line 68, in async_step_user config = self.hass.data[DATA_NIBE].config KeyError: 'nibe'

Probably I missed something during the installation but what? I never got to set any settings for the Nibe API.

There is a folder called Nibe in the config/custom_components folder

I greatful if somebody could point out where I went wrong.

Also a lot of thanks for all the jobs spent into these projects.

elupus commented 3 years ago

You need to add an empty nibe key in your config. Check the readme. I thought I had fixed that. But seems not.

Ps. Do t close this issue even though you resolve it. I should fix this issue.

Anders7107 commented 3 years ago

Hi,

many thanks for the quick advice. As said I´m not very scilled in this. But ok, I added an empty Nibe key into the config as I understood it from the readme file. Apparently it worked as I then got to input the credentials for Nibe and came to a Nibe page where I could confirm reading/writing and not being a robot.

So far everything is fine but for some reason, after going through the entire procedure nothing turns up in the integrations? I did restart of the Home Assistant but nothing turns up.

Something still missing in order to be able to read the values from Nibe?

elupus commented 3 years ago

You should have gotten one or two climate entity and possibly fans.

If you want all data, you need to turn in categories. check readme.

Den lör 27 mars 2021 19:57Anders7107 @.***> skrev:

Hi,

many thanks for the quick advice. As said I´m not very scilled in this. But ok, I added an empty Nibe key into the config as I understood it from the readme file. Apparently it worked as I then got to input the credentials for Nibe and came to a Nibe page where I could confirm reading/writing and not being a robot.

So far everything is fine but for some reason, after going through the entire procedure nothing turns up in the integrations? I did restart of the Home Assistant but nothing turns up.

Something still missing in order to be able to read the values from Nibe?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/elupus/hass_nibe/issues/80#issuecomment-808786684, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADV5IDULATNZYF5GHFPQ2TTFYTBBANCNFSM4U43Q6WQ .

Anders7107 commented 3 years ago

Something still clearly missing from my side it seems. Everything works out fine through the process but in the end nothing.

Tried to read an understand the readme once more. The SystemId mentioned for config, what should that be? I tried inserting the indentifier code from the uplink api but it was not accepted. Should the SystemId be within < > or not?

Sorry for the beginners questions, like You see this is all new to me. But since I got the other issues up and running I intend to try with this one also.

elupus commented 3 years ago

The system id should not be within <> it should be just the numbers. You should see the system id under the device under devices view in home assistant gui. Does your device show up under nibeuplink.com? The new style myuplink is not supported.

Anders7107 commented 3 years ago

Hi, ok, thanks, the SystemId was simply the 5 digit number from Nibe Uplink.

I have the "old" version of Uplink (not myUplink) so should work ok. I see the system from the Uplink side, no problem with that.

I made some more entries into the configuration file also and that part seems to be ok. Everything goes smoothly when doing the integration but in the end once everything has gone through the browser opens aanother window for HA saying " Authorize home assistant for Nibe - This step requires you to visit an external website to be completed. " If I click this link I again get to write the login credentials to Nibe, procedure goes through and in the end a new browser window opens again.

I tried from my IPAD also, in case something with the browser (I run Chrome) but it would not change anything.

I have the Nibe Uplink visible in HACS/Integrations but in the config/integrations it does not turn up. I assume it should?

elupus commented 3 years ago

Yes. That would indicate it never completed. Did you setup your callback/redirect urls properly?

Anders7107 commented 3 years ago

The callback url I have as simple as possible, http://homeassistant.local:8123

Is the redirect url something different? Where should that be set?

I had a longer version as callback url first but i did not change anything,

elupus commented 3 years ago

That is wrong. You need the api/nibe/auth part mentioned in documentation. Host/port also must match exactly with how you access home assistant in your browser.

Anders7107 commented 3 years ago

Ok, the good part here is that something is clearly wrong, the bad part is that this is way over my skills.

This api/nibe/auth part, should that be part of the adress or is there some step that I have not completed during the way in order to get something needed?

I set up the API on Nibes sides but nothing more than that. Only things I got from that was two codes, "identifier" and "secret"

elupus commented 3 years ago

When you set up on nibe pages. You need to enter a field called "Callback Url". This should contain the url to your home assistant instance with mentioned suffix. So in your case:

http://homeassistant.local:8123/api/nibe/auth

Then this value must ALSO be entered while setting up inside home assistant.

Anders7107 commented 3 years ago

Ok, many thanks for sorting the things out. I will try once more with that and see if I can get it through.

Inside HA, is this same to be entered in some of the config files or somewhere else?

In the autenthication part of course but should it be somewhere else also.

Many thanks eluplus for all the assistance and help to such a beginner like me!

Anders7107 commented 3 years ago

Now it went through!

Many thanks for the assistance and patience!

elupus commented 3 years ago

Good that it worked :). Remember my earlier comment about "categories" setting if you want all available data.

Anders7107 commented 3 years ago

Yes, it was great that it worked out!

I intended earlier to use modbus for this purpose but will see how far I can get this way.

I will add the categories little bit later, main thing that the pump is now visible.

ThunderMikey commented 1 year ago

For me, the error was caused by CORS policy.

Access to fetch at 'http://<home_assitant_url>/auth/token' from origin 'http://<home_assitant_url>' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `private`.

For Chrome, the solution is simple. Go to "Site settings" on the left of the browser URL bar, and allow "Insecure content". You can always disallow afterwards.

treb0r1979 commented 1 year ago

Hi I am using Nibe Uplink integration in Home assistant (SMO 40). Until HA core 2023.4.6 everything worked ok, but after update to 2023.5.0 (and 2023.5.1, 2023.5.2 and 2023.5.3) all entities are unavailable. Did somone faced the same problem? After downgrade of core to 2023.4.6 everything works normally. Below I am placing errors from the LOG:

Logger: homeassistant.config_entries Source: loader.py:1045 First occurred: 11:30:09 (2 occurrences) Last logged: 11:30:09

Error setting up entry for nibe Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/nibe/init.py", line 227, in async_setup_entry await async_setup_systems(hass, data, entry) File "/config/custom_components/nibe/init.py", line 176, in async_setup_systems await asyncio.gather(*tasks) File "/config/custom_components/nibe/init.py", line 290, in load device_registry = await self.hass.helpers.device_registry.async_get_registry() File "/usr/src/homeassistant/homeassistant/loader.py", line 1045, in getattr value = getattr(self._module, attr) AttributeError: module 'homeassistant.helpers.device_registry' has no attribute 'async_get_registry'

elupus commented 1 year ago

Hi I am using Nibe Uplink integration in Home assistant (SMO 40). Until HA core 2023.4.6 everything worked ok, but after update to 2023.5.0 (and 2023.5.1, 2023.5.2 and 2023.5.3) all entities are unavailable. Did somone faced the same problem? After downgrade of core to 2023.4.6 everything works normally. Below I am placing errors from the LOG:

Logger: homeassistant.config_entries Source: loader.py:1045 First occurred: 11:30:09 (2 occurrences) Last logged: 11:30:09

Error setting up entry for nibe Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/nibe/init.py", line 227, in async_setup_entry await async_setup_systems(hass, data, entry) File "/config/custom_components/nibe/init.py", line 176, in async_setup_systems await asyncio.gather(*tasks) File "/config/custom_components/nibe/init.py", line 290, in load device_registry = await self.hass.helpers.device_registry.async_get_registry() File "/usr/src/homeassistant/homeassistant/loader.py", line 1045, in getattr value = getattr(self._module, attr) AttributeError: module 'homeassistant.helpers.device_registry' has no attribute 'async_get_registry'

Perhaps you should try to update before reporting issues..