hchris1 / Eversolo

Eversolo Integration for Home Assistant
Apache License 2.0
19 stars 2 forks source link

Mediaplayer not working #5

Closed marcgarciamarti closed 1 year ago

marcgarciamarti commented 1 year ago

Describe the issue

Hello,

I installed this component through HACS. Thanks a million for putting this together.

All the entities but the mediaplayer seem to work just fine. The mediaplayer integration is not even provisioned when the integration is enabled but once you reload the integration, it shows up. It however does not seem to work for me.

Log details (ERROR)

Logger: homeassistant.components.media_player
Source: custom_components/eversolo/media_player.py:176 
Integration: Media player ([documentation](https://www.home-assistant.io/integrations/media_player), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+media_player%22)) 
First occurred: 5:57:08 PM (4 occurrences) 
Last logged: 5:58:26 PM

Error adding entities for domain media_player with platform eversolo
Error while setting up eversolo platform for media_player
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1002, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 730, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 830, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 773, in _async_generate_attributes
    attr.update(self.state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1029, in state_attributes
    if (value := getattr(self, attr)) is not None:
                 ^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/eversolo/media_player.py", line 176, in media_album_name
    return music_control_state['playingMusic']['album']
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'album'
Screenshot 2023-09-15 at 17 58 45

Reproduction steps

  1. Install integration
  2. reload
  3. media_player will show up
  4. media_player won't work ...
hchris1 commented 1 year ago

Hello @marcgarciamarti! Thank you for reporting this issue.

I will change the implementation to use default values when a certain value is not provided by the Eversolo API. You can expect an update on this in the coming days. I will do this as soon as I have time.

Are you using an Eversolo device other than the DMP-A6?

marcgarciamarti commented 1 year ago

Hi Christian,

thanks again for developing this module again. I was soooo much looking forward to this...

No, I only have the DMP-A6.

Thanks

On Sat, Sep 16, 2023 at 1:21 AM Christian Horn @.***> wrote:

Hello @marcgarciamarti https://github.com/marcgarciamarti! Thank you for reporting this issue.

I will change the implementation to use default values when a certain value is not provided by the Eversolo API. You can expect an update on this in the coming days. I will do this as soon as I have time.

Are you using an Eversolo device other than the DMP-A6?

— Reply to this email directly, view it on GitHub https://github.com/hchris1/Eversolo/issues/5#issuecomment-1722002664, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADA3QFEHGQRNVGHNTPVGCETX2TPHJANCNFSM6AAAAAA42AVAJE . You are receiving this because you were mentioned.Message ID: @.***>

hchris1 commented 1 year ago

@marcgarciamarti I just released v0.2.0. This version should be much more robust when values are missing in API responses.

I also added some debug logging. This way you can send me the log so I can understand where your API response differs from mine. To do that you can follow these steps. Your Eversolo should be turned on during that time so that new data can be fetched:

  1. Go to settings -> devices & integrations -> Eversolo
  2. Activate the debug protocol
  3. Wait for approximately 10 seconds
  4. Deactivate the debug protocol
  5. Attach the whole debug file or copy the lines that start with "Fetched data from API" in case you don't want to send the whole file

Looking forward to get feedback from you! Christian

marcgarciamarti commented 1 year ago

Wow, thanks a lot! v.0.2.0 is installed on my end and I finally can see the mediplayer displayed on my frontend! thanks!!

I tried it and it works well! I just used it briefly and nothing worked incorrectly. It is very very convenient! How would you like for me to share my feedback with you? do you want a github issue for everything that I come across, if at all?

I’m not sure this can be helpful for this project, but up until I purchased the Eversolo, I was using LMS and I remember the HA integration was very powerful. Maybe you can benefit from portions of that code?

In any case, your project is awesome and I’m so happy you put this together!! I still see that Eversolo won’t allow for their device to be turned on by invoking the API either… thank God I have this cool broadlink device sitting next to it, and I can beam an IR signale to compensate their decision!

Hats off Christian! can we buy you a coffee somehow?

On 16 Sep 2023, at 15:47, Christian Horn @.***> wrote:

@marcgarciamarti https://github.com/marcgarciamarti I just released v0.2.0. This version should be much more robust when values are missing in API responses.

I also added some debug logging. This way you can send me the log so I can understand where your API response differs from mine. To do that you can follow these steps. Your Eversolo should be turned on during that time so that new data can be fetched:

Go to settings -> devices & integrations -> Eversolo Activate the debug protocol Wait for approximately 10 seconds Deactivate the debug protocol Attach the whole debug file or copy the lines that start with "Fetched data from API" in case you don't want to send the whole file Looking forward to get feedback from you! Christian

— Reply to this email directly, view it on GitHub https://github.com/hchris1/Eversolo/issues/5#issuecomment-1722234208, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADA3QFFAMZVEP36QDZX4BZLX2WUWTANCNFSM6AAAAAA42AVAJE. You are receiving this because you were mentioned.

hchris1 commented 1 year ago

@marcgarciamarti Good to hear that v0.2.0 brought an improvement for you!

I would recommend to open a new issue per feature request/bug to keep it structured. If you are satisfied with the bug fix, you can close this issue :)

I set up "Buy Me a Coffee" in case you want to support me: https://www.buymeacoffee.com/hchris1 Don't feel obligated to donate, but if you do, thank you so much! Christian

marcgarciamarti commented 1 year ago

Done!!