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

IndexError: list index out of range (Hue Play Gradient) #20

Closed
Garulf opened this issue May 14, 2021 · 3 comments
Closed

IndexError: list index out of range (Hue Play Gradient) #20

Garulf opened this issue May 14, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@Garulf
Copy link

Garulf commented May 14, 2021

Just recently the integration stopped working for some unknown reason.

I just recently (FINALLY) installed the new Hue Play Gradient lightstrip. I'm assuming the issue is related to this.

Error log
2021-05-14 01:51:09 ERROR (MainThread) [homeassistant.components.media_player] Error adding entities for domain media_player with platform huesyncbox
Traceback (most recent call last):
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 364, in async_add_entities
    await asyncio.gather(*tasks)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 558, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 581, in add_to_platform_finish
    self.async_write_ha_state()
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 334, in async_write_ha_state
    self._async_write_ha_state()
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 370, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/components/media_player/__init__.py", line 868, in state_attributes
    value = getattr(self, attr)
  File "/Volumes/HomeAssistant/custom_components/huesyncbox/media_player.py", line 338, in media_title
    return f"{self.get_mode().capitalize()} - {self.sound_mode.capitalize()}"
  File "/Volumes/HomeAssistant/custom_components/huesyncbox/media_player.py", line 315, in sound_mode
    attributes = self.device_state_attributes
  File "/Volumes/HomeAssistant/custom_components/huesyncbox/media_player.py", line 210, in device_state_attributes
    'entertainment_area': self._get_selected_entertainment_area()
  File "/Volumes/HomeAssistant/custom_components/huesyncbox/media_player.py", line 193, in _get_selected_entertainment_area
    id = parts[1]
IndexError: list index out of range
2021-05-14 01:51:09 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up huesyncbox platform for media_player
Traceback (most recent call last):
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 239, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 364, in async_add_entities
    await asyncio.gather(*tasks)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 558, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 581, in add_to_platform_finish
    self.async_write_ha_state()
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 334, in async_write_ha_state
    self._async_write_ha_state()
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 370, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/components/media_player/__init__.py", line 868, in state_attributes
    value = getattr(self, attr)
  File "/Volumes/HomeAssistant/custom_components/huesyncbox/media_player.py", line 338, in media_title
    return f"{self.get_mode().capitalize()} - {self.sound_mode.capitalize()}"
  File "/Volumes/HomeAssistant/custom_components/huesyncbox/media_player.py", line 315, in sound_mode
    attributes = self.device_state_attributes
  File "/Volumes/HomeAssistant/custom_components/huesyncbox/media_player.py", line 210, in device_state_attributes
    'entertainment_area': self._get_selected_entertainment_area()
  File "/Volumes/HomeAssistant/custom_components/huesyncbox/media_player.py", line 193, in _get_selected_entertainment_area
    id = parts[1]
IndexError: list index out of range
@Garulf Garulf added the bug Something isn't working label May 14, 2021
@Garulf
Copy link
Author

Garulf commented May 14, 2021

I changed line 196 to:

id = parts[0]

and it seems to be working fine now.
hue_target = self._huesyncbox.api.execution.hue_target
was returning a list with one item. Similar to this: ['47XX285f-XXXX-492e-XXXX-51bXXXXa590c']

So string split was not affecting anything and a one item list was being returned.

Looks like the 'Set_entertainment_area" service fails now however....

with this error:

Error log
2021-05-14 03:23:00 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 15: Invalid Value
Traceback (most recent call last):
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 363, in _async_step
    await getattr(self, handler)()
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 563, in _async_call_service_step
    await service_task
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/core.py", line 1481, in async_call
    task.result()
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/core.py", line 1516, in _execute_service
    await handler.job.target(service_call)
  File "/Volumes/HomeAssistant/custom_components/huesyncbox/__init__.py", line 171, in async_set_entertainment_area
    await entry.entity.async_select_entertainment_area(call.data.get(ATTR_ENTERTAINMENT_AREA))
  File "/Volumes/HomeAssistant/custom_components/huesyncbox/media_player.py", line 173, in async_select_entertainment_area
    await self._huesyncbox.api.execution.set_state(hue_target=group.id)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/aiohuesyncbox/execution.py", line 155, in set_state
    await self._put(data)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/aiohuesyncbox/execution.py", line 35, in _put
    await self._request('put', '/execution', data=data)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/aiohuesyncbox/huesyncbox.py", line 185, in request
    _raise_on_error(data)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/aiohuesyncbox/huesyncbox.py", line 195, in _raise_on_error
    raise_error(data['code'], data["message"])
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/aiohuesyncbox/errors.py", line 38, in raise_error
    raise cls("{}: {}".format(code, message))
aiohuesyncbox.errors.RequestError: 15: Invalid Value
2021-05-14 03:23:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [4684096176] Error handling message: Unknown error
Traceback (most recent call last):
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/components/websocket_api/decorators.py", line 21, in _handle_async_response
    await func(hass, connection, msg)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/components/websocket_api/commands.py", line 482, in handle_execute_script
    await script_obj.async_run(msg.get("variables"), context=context)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 1209, in async_run
    await asyncio.shield(run.async_run())
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 345, in async_run
    await self._async_step(log_exceptions=False)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 363, in _async_step
    await getattr(self, handler)()
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 563, in _async_call_service_step
    await service_task
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/core.py", line 1481, in async_call
    task.result()
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/homeassistant/core.py", line 1516, in _execute_service
    await handler.job.target(service_call)
  File "/Volumes/HomeAssistant/custom_components/huesyncbox/__init__.py", line 171, in async_set_entertainment_area
    await entry.entity.async_select_entertainment_area(call.data.get(ATTR_ENTERTAINMENT_AREA))
  File "/Volumes/HomeAssistant/custom_components/huesyncbox/media_player.py", line 173, in async_select_entertainment_area
    await self._huesyncbox.api.execution.set_state(hue_target=group.id)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/aiohuesyncbox/execution.py", line 155, in set_state
    await self._put(data)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/aiohuesyncbox/execution.py", line 35, in _put
    await self._request('put', '/execution', data=data)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/aiohuesyncbox/huesyncbox.py", line 185, in request
    _raise_on_error(data)
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/aiohuesyncbox/huesyncbox.py", line 195, in _raise_on_error
    raise_error(data['code'], data["message"])
  File "/Volumes/HomeAssistant/.venv/lib/python3.9/site-packages/aiohuesyncbox/errors.py", line 38, in raise_error
    raise cls("{}: {}".format(code, message))
aiohuesyncbox.errors.RequestError: 15: Invalid Value

@mvdwetering
Copy link
Owner

mvdwetering commented May 14, 2021

There seem to be some API updates on the box.
I had already been working on some other fixes and improvements for this integration and the first one was already solved when I simplified some code. I just also fixed the second issue you mentioned.

I tagged version 1.11.0 which should be available soon. Could you check if that solves the issues?

EDIT: release is available now

@Garulf
Copy link
Author

Garulf commented May 14, 2021

I can confirm no errors and everything works beautifully after updating to 1.11.0.

Thank you!

@Garulf Garulf closed this as completed May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants