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

Error in code api.py line 37 | TypeError: int() argument must be a string, #81

Closed
RPJacobs opened this issue Jan 2, 2025 · 11 comments
Closed

Comments

@RPJacobs
Copy link

RPJacobs commented Jan 2, 2025

Title:
TypeError in SmartThings Soundbar Integration during Update

Environment:

  • Home Assistant Version: 2024.12.5
  • Integration Version: Fresh install following README instructions

Issue Description:
After a fresh installation of the SmartThings Soundbar integration, the following error occurs when attempting to update the media_player.soundbar entity:

Error Log:

2025-01-02 16:29:37.688 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.soundbar fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 960, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1320, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/smartthings_soundbar/media_player.py", line 68, in update
    SoundbarApi.device_update(self)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/smartthings_soundbar/api.py", line 37, in device_update
    device_volume = min(int(device_volume) / entity._max_volume, 1)
                        ~~~^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
@RPJacobs
Copy link
Author

RPJacobs commented Jan 2, 2025

Update:
After debugging the received data, it appears that the issue is caused by a rate limiting error from the SmartThings API. The API response contains the following error:

2025-01-02 17:07:51.117 DEBUG (SyncWorker_6) [custom_components.smartthings_soundbar.api] Extracted device volume: {'requestId': '4897752529766255617', 'error': {'code': 'TooManyRequestError', 'message': 'Too Many Requests', 'details': [{'code': 'TooManyRequestError', 'message': 'attempt 2 limit 2 - retry in 8900 millis', 'details': []}]}}

@RPJacobs
Copy link
Author

RPJacobs commented Jan 2, 2025

Question:
Do I need a special Samsung account for this integration?

I’m wondering if a standard SmartThings account is sufficient, or if a specific type of account (e.g., Samsung Developer Account or Service Account) is required to increase rate limits or provide better API access management.

Additional Context:
Given the current error (TooManyRequestError), it seems like rate-limiting might be an issue. Would a different type of account offer higher limits or additional configuration options?

Could you please clarify the recommended account setup for this integration?

Thank you in advance for the information!

@nikita-devbox
Copy link

nikita-devbox commented Jan 5, 2025

Subscribed to the thread as I am also getting the same error and its overwhelming my HASS log (thanks for posting this RPJacobs 😊).

I am using the integration for the first time and just finished setting it up.
The state of the soundbar is OFF and the errors are present.

@PiotrMachowski
Copy link
Owner

PiotrMachowski commented Jan 5, 2025

@RPJacobs There is no need for any special Samsung account. The problem is caused by changes introduced by Samsung on SmartThings side. There was no rate limiting until now, also Personal Access Tokens are basically useless now, which effectively makes this integration useless for new users :(

@Denox78
Copy link

Denox78 commented Jan 5, 2025

Hey there,

I'm having the same issue on my side, can see my soundbards but it's read only mode.

See error log below :

Enregistreur: homeassistant.helpers.entity
Source: helpers/entity.py:960
S'est produit pour la première fois: 13:14:40 (110 occurrences)
Dernier enregistrement: 13:23:01

Update for media_player.q990c_chambre fails
Update for media_player.q990c_salon fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 960, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1320, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/smartthings_soundbar/media_player.py", line 68, in update
    SoundbarApi.device_update(self)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/config/custom_components/smartthings_soundbar/api.py", line 37, in device_update
    device_volume = min(int(device_volume) / entity._max_volume, 1)
                        ~~~^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

@PiotrMachowski
Copy link
Owner

@RPJacobs @nikita-devbox @Denox78 have you created a new PAT (after 31.12.2024)?

@Denox78
Copy link

Denox78 commented Jan 5, 2025

@RPJacobs @nikita-devbox @Denox78 have you created a new PAT (after 31.12.2024)?

Yes I deleted my old token and recreated a new one and updated the configuration.yaml

I had an issue with SmartThings not working anymore few days ago so I had to delete my token and recreate it

@PiotrMachowski
Copy link
Owner

@Denox78 I would suggest to try to use old PAT if possible (new policies apply only to new PATs)

@Denox78
Copy link

Denox78 commented Jan 5, 2025

@Denox78 I would suggest to try to use old PAT if possible (new policies apply only to new PATs)

I’ve deleted the PAT on Samsung side.

does it mean I’m f*ckd ?

@PiotrMachowski
Copy link
Owner

PiotrMachowski commented Jan 5, 2025

does it mean I’m f*ckd ?

🙁

at least until authentication is rewritten on HA side

@PiotrMachowski
Copy link
Owner

I have added handling missing data on the integration side in v1.0.6

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

4 participants