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

AttributeError #58

Open
skiant opened this issue Sep 9, 2023 · 4 comments
Open

AttributeError #58

skiant opened this issue Sep 9, 2023 · 4 comments

Comments

@skiant
Copy link

skiant commented Sep 9, 2023

Please type any relevant information here

Heya! Love the work you've done on HA Commander, it's been wonderful to use.
I've added a Sonos Era 100 speaker in my setup and since then, every time I type ha to invoke a command, I get this error.

This happens whenever I played something on the Sonos via Spotify Connect, attributes on the media player entity are updated and include source: Spotify Connect and stays that way until I play something using another source.

If I play something using Sonos Radio for instance, the source attribute disappear on the media player entity.

Trace Log

Traceback (most recent call last):
  File C:\Users\skiant\AppData\Roaming\FlowLauncher\Plugins\HA-Commander-5.1.1\lib\flox\launcher.py, line 44, in run
    results = request_method(*request_parameters) or self._results
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File C:\Users\skiant\AppData\Roaming\FlowLauncher\Plugins\HA-Commander-5.1.1\lib\flox\__init__.py, line 131, in _query
    self.query(query)
  File C:\Users\skiant\AppData\Roaming\FlowLauncher\Plugins\HA-Commander-5.1.1\plugin\main.py, line 53, in query
    states = self.client.states()
             ^^^^^^^^^^^^^^^^^^^^
  File C:\Users\skiant\AppData\Roaming\FlowLauncher\Plugins\HA-Commander-5.1.1\plugin\homeassistant.py, line 122, in states
    entities.append(self.create_entity(entity))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File C:\Users\skiant\AppData\Roaming\FlowLauncher\Plugins\HA-Commander-5.1.1\plugin\homeassistant.py, line 147, in create_entity
    return _cls(self, entity)
           ^^^^^^^^^^^^^^^^^^
  File C:\Users\skiant\AppData\Roaming\FlowLauncher\Plugins\HA-Commander-5.1.1\plugin\homeassistant.py, line 328, in __init__
    getattr(self, current_source).icon = radiobox-marked
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'MediaPlayer' object has no attribute 'Spotify Connect'

@Garulf
Copy link
Owner

Garulf commented Sep 10, 2023

Interesting I'll take a look. Thanks for making me aware.

@skiant
Copy link
Author

skiant commented Sep 10, 2023

Thanks! Let me know if there's anything I can help with.

@Garulf
Copy link
Owner

Garulf commented Oct 19, 2023

I am now able to reproduce your issue, should have a fix later today.

@NylonDiamond
Copy link

I was experiencing an error that said 'MediaPlayer' object has no attribute 'uuid:7123ceda-9d21-1eb0-0080-00067886c60e'. I researched this issue and found a solution that might be helpful for others.

20:18:47 ERROR (launcher.py): 'MediaPlayer' object has no attribute 'uuid:7123ceda-9d21-1eb0-0080-00067886c60e'
Traceback (most recent call last):
  File "C:\Users\Jesse\AppData\Roaming\FlowLauncher\Plugins\HA-Commander-5.1.1\lib\flox\launcher.py", line 44, in run
    results = request_method(*request_parameters) or self._results
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Jesse\AppData\Roaming\FlowLauncher\Plugins\HA-Commander-5.1.1\lib\flox\__init__.py", line 131, in _query
    self.query(query)
  File "C:\Users\Jesse\AppData\Roaming\FlowLauncher\Plugins\HA-Commander-5.1.1\plugin\main.py", line 53, in query
    states = self.client.states()
             ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Jesse\AppData\Roaming\FlowLauncher\Plugins\HA-Commander-5.1.1\plugin\homeassistant.py", line 122, in states
    entities.append(self.create_entity(entity))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Jesse\AppData\Roaming\FlowLauncher\Plugins\HA-Commander-5.1.1\plugin\homeassistant.py", line 147, in create_entity
    return _cls(self, entity)
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\Jesse\AppData\Roaming\FlowLauncher\Plugins\HA-Commander-5.1.1\plugin\homeassistant.py", line 333, in __init__
    getattr(self, current_source).icon = "radiobox-marked"
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To debug the issue, I added some statements in the homeassistant.py file in the MediaPlayer class:

logging.warning(client)
logging.warning(entity)
logging.warning(self.attributes.get("source_list", []))

I noticed that one of my media players did not have a source list. Ex:
This one has the source list :

{'entity_id': 'media_player.lg_tv', 'state': 'off', 'attributes': {'source_list': ['Live TV'], 'assumed_state': True, 'device_class': 'tv', 'friendly_name': 'LG TV', 'supported_features': 24509}, 'last_changed': '2023-12-29T22:48:16.305770+00:00', 'last_updated': '2023-12-29T22:48:21.832809+00:00', 'context': {'id': 'KGHDSFKH755958', 'parent_id': None, 'user_id': None}}

This one doesn't have the source list:

{'entity_id': 'media_player.living_room_3', 'state': 'idle', 'attributes': {'volume_level': 0.0, 'is_volume_muted': True, 'media_content_id': 'aiosws://spotify/connect/track', 'media_content_type': 'music', 'media_position': 406682.0, 'media_position_updated_at': '2023-12-23T22:50:17.789598+00:00', 'media_title': 'uuid:7123ceda-9d21-1eb0-0080-0006788748973e', 'app_id': 'mass', 'source': 'uuid:7123ceda-9d21-1eb0-0080-0006788748973e', 'shuffle': False, 'repeat': 'off', 'entity_picture_local': None, 'mass_player_id': 'uuid:7123ceda-9d21-1eb0-0080-0006788748973e', 'mass_player_type': 'player', 'group_members': [], 'group_leader': None, 'active_queue': 'uuid:7123ceda-9d21-1eb0-0080-0006788748973e', 'items_in_queue': 2, 'queue_index': 2, 'device_class': 'speaker', 'friendly_name': 'Denon HEOS', 'supported_features': 3602367}, 'last_changed': '2023-12-29T22:48:16.869302+00:00', 'last_updated': '2023-12-29T22:48:16.869302+00:00', 'context': {'id': '01HJVW74Q5S786876DDNBN20BPM', 'parent_id': None, 'user_id': None}}

I use Hass Music Assistant, which created the media_player.living_room_3 entity automatically. To resolve the issue, I deleted that entity and disabled UPnP/DLNA to prevent it from being created again.

I Hope this helps @skiant.

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

3 participants