Platform rest not ready yet: [Errno -3]

For two days now my (only) RESTful sensor ist unavailable (after working for months):

- platform: rest
  resource: !secret NC_res
  scan_interval: 60
  name: "Nextcloud JSON"
  authentication: basic
  username: !secret NC_user
  password: !secret NC_passwd
  headers:
    # occ config:app:set serverinfo token --value ...
    NC-Token: !secret NC_passwd
    User-Agent: Home Assistant
    Content-Type: application/json
  json_attributes_path: "$.ocs"
  json_attributes:
    - meta
    - data
  value_template: >
    {% if value_json %}
    {{ value_json.ocs.meta.status }}
    {% else %}
    timeout
    {% endif %}

Using the URL in a browser yields the expected result (=it gives me the finger since I’m not authenticated).
But the sensor doesn’t get updated, it stays unavailable with a last_updated >50h ago.
So it does not retry, even though it says it would do so in the background:

Source: helpers/entity_platform.py:224
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: 00:10:30 (1 occurrences)
Last logged: 00:10:30

Platform rest not ready yet: [Errno -3] Try again; Retrying in background in 30 seconds

Several restarts (of HA and NC) failed to change anything.

What changed in HA (from 2022.9.5 to 2022.9.6)? I spy nothing in the release notes…

That log message is only logged once, and it refers to trying to set up this integration, not necessarily calling that URL.

I believe the actual error message is “[Errno -3] Try again” which might indicate that the rest integration is unable to retrieve any data.

I would try increasing the log level to get more information from this integration.

logger:
  default: info
  logs:
    homeassistant.components.rest: debug

And, last question: Is there any reason you are not using the built-in NextCloud integration? I thought that it already provides the information you are trying to retrieve here manually?

I completely forgot about the nextcloud integration, dug into my configuration.yaml and found it - commented.

Checked the secrets, uncommented the entries and restarted HA.
Errorlog:

Source: components/nextcloud/__init__.py:105
First occurred: 21:40:48 (1 occurrences)
Last logged: 21:40:48

Error during setup of component nextcloud
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 235, in _async_setup_component
    result = await task
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/nextcloud/__init__.py", line 105, in setup
    hass.data[DOMAIN] = get_data_points(ncm.data)
UnboundLocalError: local variable 'ncm' referenced before assignment

That may be the reason why I tried the REST sensor in the first place.

The official documentation of the nextcloud integration is superficial, lacks examples.

So I’m back to the (still not working) REST sensor. Which worked for months until last week! :sob:

There should also be an error message in the log saying Nextcloud setup failed - Check configuration.

I just followed the instructions in the documentation and was able to set this up in 2 minutes. I checked with the URL pattern at the top of the doco that the API actually works and does provide lots of status information. The URL to be configured is just the base URL to your Nextcloud instance, and then I used an admin user account name and password.

My bad. Turned on the logging like you said and it spew certificate errors en masse.
The whole story was caused by a DNSSEC error of my provider.
I didn’t notice this while being in my home LAN 95% of the time (due to home office).
The used subdomains didn’t get resolved from the outside, causing LetsEncrypt to fail while trying to renew the certificates. The resulting certificate errors prevented HA from working correctly; now all’s well again.

1 Like