hchris1 / Eversolo

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

possible bug when selecting source #27

Closed therobster121 closed 9 months ago

therobster121 commented 9 months ago

Describe the issue

Since last update when I attempt to change source to a specific source via a template I get the following error. "Failed to call service media_player/select_source. coroutine raised StopIteration"

when changing source via the eversolo media player control it works fine.

Reproduction steps

  1. Create a template card similar to below:

content: Mediaplayer music entity: media_player.eversolo icon: mdi:music icon_color: tap_action: action: call-service data: source: Internal Player service: media_player.select_source target: entity_id: media_player.eversolo type: template

  1. click button
  2. error is observerd "Failed to call service media_player/select_source. coroutine raised StopIteration"
hchris1 commented 9 months ago

That's interesting! The last update changed the select source a bit because it now loads the source options from the device instead of hardcoding them.

I'll try recreate the issue and investigate.

hchris1 commented 9 months ago

First an explanation why the error was thrown: In the select_source method, it looks for the given source in the source dictionary. In version 0.3, I changed this so it's created from the Eversolo response. This means that it's now language specific. It looks like this:

{
    "XMOS": "Interner Player", 
    "BT": "Bluetooth-Eingang", 
    "USB": "USB-C-Eingang", 
    "SPDIF": "Optischer Eingang", 
    "RCA": "Koaxialer Eingang"
}

The select_source method used the next method to look for the given source value, e.g., 'Interner Player' in german, in the dictionary. If it doesn't find it, it will throw a StopIteration exception. For some reason it can't find the source that you have given. However, I didn't find any bug in the implementation.

I don't like that a service called from a template stops working with a hardcoded source if you change the language of the Eversolo device. Because of this, I introduced the following changes in Version 0.3.2:

Looking forward to your feedback! Chris

therobster121 commented 9 months ago

Thanks Chris

It works now I also realise that I was using “Internal Player” which was working before but it should now be “Internal player” for the EN version so therefore was case sensitive.

I think Eversolo are actually inconsistent in the naming but we can’t do anything about that.

I think you can close the issue.

On Sun, 17 Dec 2023 at 8:11 pm, Christian Horn @.***> wrote:

First an explanation why the error was thrown: In the select_source method, it looks for the given source in the source dictionary. In version 0.3, I changed this so it's created from the Eversolo response. This means that it's now language specific. It looks like this:

{ "XMOS": "Interner Player", "BT": "Bluetooth-Eingang", "USB": "USB-C-Eingang", "SPDIF": "Optischer Eingang", "RCA": "Koaxialer Eingang" }

The select_source method used the next method to look for the given source value in the dictionary. If it doesn't find it, it will throw a StopIteration exception. For some reason it can't find the source that you have given. However, I didn't find any bug in the implementation.

I don't like that a service called from a template stops working with a hardcoded source if you change the language of the Eversolo device. Because of this, I introduced the following changes in Version 0.3.2:

Looking forward to your feedback! Chris

— Reply to this email directly, view it on GitHub https://github.com/hchris1/Eversolo/issues/27#issuecomment-1859081258, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMB3GFK4PUXTNCGZ53OECLDYJ2ZMBAVCNFSM6AAAAABAX4KOJGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJZGA4DCMRVHA . You are receiving this because you authored the thread.Message ID: @.***>