NIBE Uplink API component (non S-series)

Please pull the module and try again

You must set that callback URL in nibe uplink homepage (the localhost one).

Don’t add the systems to start with. It will list the available systems in the log if i remember correctly.

Thanks for being patient.

Edited my callback URL a bit and now I get to the captcha and when getting through that I get back to my Home Assistant.

Still get the <class ‘KeyError’> though. :frowning:

My auth URL if that helps:
https://api.nibeuplink.com/oauth/authorize?client_id=zzzzzz&scope=READSYSTEM&state=xxxxxx&redirect_uri=http%3A%2F%2F192.168.10.182%3A8123%2F&response_type=code

edit: marked as spam for some reason?

What did you paste back into HA? It should be a http://localhost…url that you got redirected back to.

I end up at http://192.168.10.182:8123/states

I can briefly see the adress bar showing another URL before that.

Still get “An error occured: <class ‘KeyError’>”

EDIT: why is every post marked as spam and hidden? This is getting ridiculous.

From log:

Log Details (ERROR)
Sat Jan 13 2018 10:42:29 GMT+0100 (CET)

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1031, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/configurator.py", line 224, in async_handle_service_call
    call.data.get(ATTR_FIELDS, {}))
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/home/homeassistant/.homeassistant/custom_components/nibe.py", line 138, in config_callback
    await uplink.get_access_token(uplink.get_code_from_url(data['url']))
  File "/srv/homeassistant/lib/python3.5/site-packages/nibeuplink/__init__.py", line 147, in get_code_from_url
    return query['code'][0]
KeyError: 'code'

edit: edited to make visible. marked as spam for some reason.

Yes that is the one

I’m also struggling to set this up unfortunately :-/

I had the early version up and running a couple of months ago but since HA 0.5.4 or something it’s been broken.
I’ve now replaced the old master with the branch on custom_components and installed nibeuplink (0.3.0).
I use Identifier and Secret from my Nibe application as client_id and client_secret + redirect_uri: http://localhost:8123

Auth seems to have worked (I got the long url http://localhost:8123/?code=Eij1!IA…&state=4f3dd… which I pasted into the dialog and it went away without complaining :slight_smile:

Without any system configured I get no errors but with system: 1 (where can I found my valid systemId?) I get the following error in the log:

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)
  File "/Users/mist/.homeassistant/custom_components/nibe.py", line 103, in async_setup_systems
    await asyncio.gather(*tasks)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/Users/mist/.homeassistant/custom_components/nibe.py", line 222, in load
    self.system = await self.uplink.get_system(self.system_id)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nibeuplink/__init__.py", line 284, in get_system
    return await self.get('systems/{}'.format(system_id))
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nibeuplink/__init__.py", line 162, in get
    return await self._get_internal(url, params)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nibeuplink/__init__.py", line 194, in _get_internal
    return await self.request(lambda:
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nibeuplink/__init__.py", line 183, in request
    response.raise_for_status()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/aiohttp/client_reqrep.py", line 718, in raise_for_status
    headers=self.headers)
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found'

Found it! :slight_smile:

Login to your account here: https://www.nibeuplink.com.
Once logged in, inspect the url and you’ll find your SystemId (xxxxx):

https://www.nibeuplink.com/System/xxxxx/Status/Overview

Is there an easier way to find this out?

The example config in the branch shows the property writeaccess. This doesn’t seem to be supported yet, even if it is set to false:

2018-01-13 13:01:56 ERROR (MainThread) [homeassistant.config] Invalid config for [nibe]: [writeaccess] is an invalid option for [nibe]. Check: nibe->nibe->systems->0->writeaccess. (See /Users/mist/.homeassistant/configuration.yaml, line 88). Please check the docs at https://home-assistant.io/components/nibe/
2018-01-13 13:01:56 ERROR (MainThread) [homeassistant.setup] Setup failed for nibe: Invalid config.
An error occured: <class 'aiohttp.client_exceptions.ClientResponseError'>

Have you found and set your SystemId?
I got the same error before I did that…

I tried Authorize again and picked up the URL from the history, pasted it and I am in!

I am now getting the no system error. I think I can handle it from here :slight_smile:

I tried to post a step-by-step guide on what I did to make it work, but the forum won’t let me post it since it contains links that was already posted above.

I’ll try to reformat it and post a simpler version tomorrow.

It probably would have been simpler if you chose an unreachable callback url. Normally it should match the requesting app, but since we copy and paste it, it can be anything. That way the browser would have stayed on the redirected url. That said, I (or somebody else…) should probably implement an api view in HA like some of the other oauth consumers, so this manual copy paste business can be forgotten.

Same problem what did you do?

Could you clarify where you are stuck?

Sorry same as before like post 66

Current tip of module branch should simplify activation. You need a different callback url set in nibe uplink though. Checkout readme.

@tunnis, if it’s the request error, then it’s a bug in the ha dependencies, look at that other issue I mentioned. It contains some workarounds. But step one might be a clean HA install in a new local environment.

So i should start over with nibe first and if that dont work a new install of hass. I have a pie with hassbian so you know what i´m using. Could it be problem with that?