pymusiccast icon indicating copy to clipboard operation
pymusiccast copied to clipboard

Unlink service does not work for me

Open 1v0dev opened this issue 3 years ago • 6 comments

I got the following config:

  - platform: musiccast_yamaha
    host: 192.168.0.52
    port: 5004
  - platform: musiccast_yamaha
    host: 192.168.0.53
    port: 5005

and in lovelace:

          - type: button
            name: Join Office
            show_state: false
            tap_action:
              action: call-service
              service: musiccast_yamaha.join
              service_data:
                entity_id: media_player.speaker_main
                master: media_player.receiver_main
          - type: button
            name: Only Receiver
            show_state: false
            tap_action:
              action: call-service
              service: musiccast_yamaha.unjoin
              service_data:
                entity_id: media_player.speaker_main

The Join Office button works fine and groups the speakers but the Only Receiver one with the unjoin service does nothing. I tried calling the service from the dev screen in HASS but nothing happens there as well. Any thoughts?

1v0dev avatar Dec 28 '20 09:12 1v0dev

Hello. Can you please try with:

service: musiccast_yamaha.unjoin
entity_id: media_player.speaker_main

Try removing service_data

ppanagiotis avatar Dec 28 '20 10:12 ppanagiotis

Hi, thanks for the support. Unfortunately, it does not work that way too. I tried with dev tools as well, calling the service does nothing. No errors in the HASS log too. image

1v0dev avatar Dec 28 '20 11:12 1v0dev

I will try creating an automation and calling that instead, to test if it works that way

1v0dev avatar Dec 28 '20 11:12 1v0dev

I tried running this automation, but again no result:

alias: unlink test
description: ''
trigger: []
condition: []
action:
  - service: musiccast_yamaha.unjoin
    entity_id: media_player.speaker_main
mode: single

1v0dev avatar Dec 28 '20 11:12 1v0dev

I did some debugging and found the issue. Looks like something is messing up in Python due to the parameter names in one line of your code - file "init.py" line 51:

masters = [entities for entities in entities
                       if entities.is_master]

Since entities is already used maybe it overrides something (I am no expert in Python though, so I may be wrong) I changed it to this which fixed the issue for me: masters = [e for e in entities if e.is_master]

You can close this issue.

1v0dev avatar Jan 04 '21 11:01 1v0dev

I will try it too. And if it works as expected I will update the component. Thank you!

ppanagiotis avatar Jan 07 '21 15:01 ppanagiotis