meichthys / uptime_kuma

Uptime Kuma HACS integration
116 stars 23 forks source link

unable to connect to kuma #111

Open Johnny5AtGithub opened 1 month ago

Johnny5AtGithub commented 1 month ago

Hi,

I’ve just installed your addon through HACS, but I've been trying and trying to connect to my uptime kuma without any success. To be fair, at first I used my accounts' password, before I found the instructions and saw that I needed an API key. So I made that API key. Unfortunately, it still keeps saying it could not connect immediately. I played around a bit with or without http:// but nothing had any effect. Then I went to the HA logs and I found this.

It looks to me like a syntax error embedded in the source code or something. Any idea how to resolve this?

Logger: custom_components.uptime_kuma
Source: custom_components/uptime_kuma/config_flow.py:58
integration: Uptime Kuma ([documentation](https://github.com/meichthys/uptime_kuma/blob/main/README.md), [issues](https://github.com/meichthys/uptime_kuma/issues))
First occurred: 09:25:13 (1 occurrences)
Last logged: 09:25:13

could not convert string to float: 'html>'
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/prometheus_client/parser.py", line 115, in _parse_sample
    label_start, label_end = text.index("{"), text.rindex("}")
                             ^^^^^^^^^^^^^^^
ValueError: substring not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/uptime_kuma/config_flow.py", line 58, in _validate_input
    await uptime_robot_api.async_get_monitors()
  File "/usr/local/lib/python3.12/site-packages/pyuptimekuma/decorator.py", line 68, in wrapper
    response = UptimeKumaApiResponse.from_prometheus(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyuptimekuma/models.py", line 76, in from_prometheus
    for family in parsed:
  File "/usr/local/lib/python3.12/site-packages/prometheus_client/parser.py", line 14, in text_string_to_metric_families
    yield from text_fd_to_metric_families(StringIO.StringIO(text))
  File "/usr/local/lib/python3.12/site-packages/prometheus_client/parser.py", line 210, in text_fd_to_metric_families
    sample = _parse_sample(line)
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prometheus_client/parser.py", line 133, in _parse_sample
    value, timestamp = _parse_value_and_timestamp(text[name_end:])
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prometheus_client/parser.py", line 107, in _parse_value_and_timestamp
    value = float(values[0])
            ^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: 'html>'

Edit: Sorry I did not search before making the ticket, But I'm adding info now :) --> I have tried with or without SSL checked. --> I have tried via the nginx proxy name with a valid SSL certificate and by making a direct connection on IP and port --> The metrics endpoint is operational. I needed to use my username with the API key I have been entering into your add-on image

The API key used is set up image

Additional question: I see mentions that I need to input an API key instead of my password, but on one of the other threads there is mention I need API turned off in uptime kuma, I see no generic setting to turn an entire API on or off. What is meant? sometimes the instruction is to create an API key, but API in general is supposed to be off?

Johnny5AtGithub commented 1 month ago

The unsung HERO!!!! It's the trailing slash!!!

https://github.com/meichthys/uptime_kuma/issues/55#issuecomment-2035823765

So, for the record, when in the chrome browser you always show full URL enabled (right click in the URL bar) and you select your URL WITHOUT a trailing slash, control+c copies your URL WITH A SLASH!!!

So now you have a compacted problem report, checklist on what to check and a solution. This ticket may be closed.