Nextcloud integration

Hi,

Did anyone manage to add Nextcloud integration in Home Assistant? I’ve seen it just appeared in v0.108 (which I have installed), but I can’t get it working, I keep on getting a “Please check your config.” error notification whereas I’ve done exatly what is instructed on HA website.

Thanks

Share your config for it. Also, any errors related to it at developer tools > logs?

HA log:

2020-04-10 16:48:10 ERROR (SyncWorker_17) [homeassistant.components.nextcloud] Nextcloud setup failed - Check configuration
2020-04-10 16:48:10 ERROR (MainThread) [homeassistant.setup] Error during setup of component nextcloud
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 175, in _async_setup_component
    component.setup, hass, processed_config  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/nextcloud/__init__.py", line 102, in setup
    hass.data[DOMAIN] = get_data_points(ncm.data)
UnboundLocalError: local variable 'ncm' referenced before assignment

configuration.yaml (quite light as I will not share these information):

nextcloud:
  url: *(my_url)*
  username: *(my_username)*
  password: *(my_app_password_generated_in_nextcloud_web_UI)*

Thanks

Is this log of any help to find a solution to my issue?

Thanks.

Heyho! Had the same problem.
After activating “Monitoring” app in NC everything works.
You can check it by typing [NC url]/ocs/v2.php/apps/serverinfo/api/v1/info?format=json (when logged in as an admin user)

Thanks for the tip, but this app was already active in my instance. Although I tried to deactivate and reactivate it, I still have the same messages:

2020-04-14 14:21:44 ERROR (SyncWorker_9) [homeassistant.components.nextcloud] Nextcloud setup failed - Check configuration
2020-04-14 14:21:44 ERROR (MainThread) [homeassistant.setup] Error during setup of component nextcloud
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 175, in _async_setup_component
    component.setup, hass, processed_config  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/nextcloud/__init__.py", line 102, in setup
    hass.data[DOMAIN] = get_data_points(ncm.data)
UnboundLocalError: local variable 'ncm' referenced before assignment

Should I post it as an issue on Github?

@letsoulfly Thanks for pointing this out. I’ll add a step to the documentation to enable the monitoring ‘app’.

Same issue / error here… plugin is activated, still no joy

Hey, got the same error.

Turns out, that my url was the problem.
My Nextcloud runs on the same maschine as home assistant.
So at first i tried: https://localhost

Then i thought, hm maybe its because localhost is not a trusted domain in nextcloud.
So i tried https://raspberrypi where raspberrypi is is the hostname of my local machine (points at 192.168.xxx.yyy) and raspberrypi is a trusted domain in nextcloud.

That didn’t work too. But i remembered a difference when logging into nextcloud via my localnetwork (https://raspberrypi) and via the web (https://your-domain.xyz).
I always had to accept the certificate for my local network explicitly, but for access via the web i didn’t have to.
So i tried https://your-domain.xyz and it worked.

Seems to be an issue with the SSL-Certificate, since i configured the access via web with letsencrypt and got a real certificate there.

1 Like

2020-06-20 16:04:34 ERROR (SyncWorker_5) [homeassistant.components.nextcloud] Nextcloud setup failed - Check configuration
2020-06-20 16:04:34 ERROR (MainThread) [homeassistant.setup] Error during setup of component nextcloud
File “/var/homeassistant/lib/python3.7/site-packages/homeassistant/components/nextcloud/init.py”, line 102, in setup

any hint?

Solved:

created an additional apache site config for nextcloud without ssl (i can only be accessed from the local network)
by nextcloud config, added the sitename with it’s port
by hass changed the config entrey to a the non ssl site.

worked.

Had the integration up and working a few weeks ago, then it decided to quite working. All my entities still exist in HA, have checked and rechecked settings…it just won’t connect any more.

Have the following in the logs below…seems to be coming with last 3 lines…any one familiar with this part of the code?

## Log Details (ERROR)

Logger: homeassistant.components.sensor
Source: components/nextcloud/sensor.py:48
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 7:49:37 AM (1 occurrences)
Last logged: 7:49:37 AM

Error while setting up nextcloud platform for sensor

Traceback (most recent call last): 
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 192, in _async_setup_platform await asyncio.gather(*pending) 
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 301, in async_add_entities 
    await asyncio.gather(*tasks) 
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 346, in _async_add_entity 
    if entity.unique_id is not None: 
File "/usr/src/homeassistant/homeassistant/components/nextcloud/sensor.py", line 48, in unique_id 
    return f"{self.hass.data[DOMAIN]['instance']}#{self._name}" 
KeyError: 'instance'

Same error right here, have you found a solution to it?

It should be resolved in the 0.115.3 release. I logged a ticket for this a little while back. An update was made to fix it 0.115.1 and it looks like it regressed back in 0.115.2.