Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.5.0 and v0.6.0 cannot connect to SignalRGB API #4

Open
WhimsySpoon opened this issue Aug 14, 2024 · 7 comments
Open

v0.5.0 and v0.6.0 cannot connect to SignalRGB API #4

WhimsySpoon opened this issue Aug 14, 2024 · 7 comments

Comments

@WhimsySpoon
Copy link
Contributor

WhimsySpoon commented Aug 14, 2024

Any commands from Home Assistant Core throw the exception below.

  • I have tried using a host name and an IP address for the connection on more than one device, but the result is the same.
  • I am runnign SignalRGB version 2.3.102.
  • v0.4.0 doesn't work due to v0.4.0 install error #3, but the issue goes away when rolling back to v0.3.0.
  • Issue also exists in v0.6.0.
  • The SignalRGB API is running and provides the following payload at :16038/api/v1/lighting:
{
"api_version": "1.0",
"data": {
"attributes": {
"name": "Gradient Wave"
},
"id": "-Me3BsMN_hIlzeJwFbMs",
"links": {
"self": "[/api/v1/lighting/effects/-Me3BsMN_hIlzeJwFbMs](http://[hostname]:16038/api/v1/lighting/effects/-Me3BsMN_hIlzeJwFbMs)"
},
"type": "effect"
},
"id": 36,
"method": "[/api/v1/lighting](http://[hostname]:16038/api/v1/lighting)",
"params": {},
"status": "ok"
}

The exception:

2024-08-14 09:55:39.995 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140310035532384] Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/signalrgb/client.py", line 130, in _request
    response.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://[hostname]:16038/api/v1/lighting/enabled

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 974, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/signalrgb/client.py", line 373, in enabled
    response_data = self._request(
                    ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/signalrgb/client.py", line 146, in _request
    error_data = e.response.json().get("errors", [{}])[0]
                 ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 978, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2763, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 626, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/config/custom_components/signalrgb/light.py", line 156, in async_turn_on
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/signalrgb/client.py", line 379, in enabled
    raise SignalRGBException(
signalrgb.client.SignalRGBException: Failed to set enabled state: Expecting value: line 1 column 1 (char 0)
2024-08-14 09:55:44.357 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140310035532384] Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/signalrgb/client.py", line 130, in _request
    response.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://[hostname]:16038/api/v1/lighting/enabled

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 974, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/signalrgb/client.py", line 373, in enabled
    response_data = self._request(
                    ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/signalrgb/client.py", line 146, in _request
    error_data = e.response.json().get("errors", [{}])[0]
                 ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 978, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2763, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 637, in async_handle_light_off_service
    await light.async_turn_off(**filter_turn_off_params(light, params))
  File "/config/custom_components/signalrgb/light.py", line 178, in async_turn_off
    await self.hass.async_add_executor_job(setattr, self._client, "enabled", False)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/signalrgb/client.py", line 379, in enabled
    raise SignalRGBException(
signalrgb.client.SignalRGBException: Failed to set enabled state: Expecting value: line 1 column 1 (char 0)
@WhimsySpoon WhimsySpoon changed the title v0.5.0 cannot connect to SignalRGB API v0.5.0 and v0.6.0 cannot connect to SignalRGB API Aug 14, 2024
@WhimsySpoon
Copy link
Contributor Author

Exception appears slightly different in 0.6.0:

[139853489545296] Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/signalrgb/client.py", line 130, in _request
    response.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://[hostname]:16038/api/v1/lighting/enabled

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 974, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/signalrgb/client.py", line 373, in enabled
    response_data = self._request(
                    ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/signalrgb/client.py", line 146, in _request
    error_data = e.response.json().get("errors", [{}])[0]
                 ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 978, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2763, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 626, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/config/custom_components/signalrgb/light.py", line 184, in async_turn_on
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/signalrgb/client.py", line 379, in enabled
    raise SignalRGBException(
signalrgb.client.SignalRGBException: Failed to set enabled state: Expecting value: line 1 column 1 (char 0)

@hyperb1iss
Copy link
Owner

Do you have the latest SignalRGB? The enabled and brightness states were just added a week ago, and they don't give us a way to determine the version easily from the API.

@WhimsySpoon
Copy link
Contributor Author

WhimsySpoon commented Aug 14, 2024

Looks like it was added in the beta. I'm running the latest stable, so might explain this.

Control Global brightness with Macros and the local API.

Will update to the beta and report back...

@hyperb1iss
Copy link
Owner

Oh geez yeah it's the beta. Sorry about that, I've just got automatic updates on!

I might be able to figure out the right behavior based on whether these properties even exist in the json responses, I'll have a peek after work today. Also grab 0.6.1, it fixes a nasty state tracking issue

@WhimsySpoon
Copy link
Contributor Author

Please don't apologise! This integration is amazing!!

I gave just installed the beta and 0.6.0 and 0.6.1 is now working perfectly - thank you!

Additionally, Brightness and on/off work without the need for the Good Night! effect.

I don't know how frequently SignalRGB promotes beta releases, but if it's likely to take a while, I'd be happy to submit a PR for the readme.md confirming that the beta is required to save the need for potential spaghetti code to handle the API version differences.

@hyperb1iss
Copy link
Owner

hyperb1iss commented Aug 14, 2024

Yeah that would be great, but it probably needs to adapt to different SignalRGB versions anyway so I'll still dig into it.

Have you tried hyper-light-card yet? I just made the first release!

@WhimsySpoon
Copy link
Contributor Author

PR for an updated readme is with you.

I have tried the new card and it's amazing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants