N0ciple / hass-kef-connector

A Home Assistant integration for KEF speakers
Apache License 2.0
9 stars 4 forks source link

Via an automation, LSX II cannot Stop or Play Media #5

Closed gurmukhp closed 9 months ago

gurmukhp commented 9 months ago

Hello

Thanks for making this plugin, I have managed to install it and create a dashboard card that can control the Kef Speaker (play / pause etc).

However when I try to do this via an automation, I get the following error:

Entity media_player.kef_speaker does not support this service.

This is a super simple YAML file I'm using:

alias: Stop Kef
description: ""
trigger: []
condition: []
action:
  - service: media_player.media_stop
    data: {}
    target:
      entity_id: media_player.kef_speaker
mode: single

I also am not able to play music via an automation.

If it helps, mute, unmute, volume up, volume down, volume set, pause, play all seem to work, it's just 'stop' and 'play media'. A workaround is to use 'Media Player: turn off' which works! ⭐️

I'm happy to beta test anything you might create.

Thanks!

N0ciple commented 9 months ago

Hello,

Unfortunately, the stop command is not (yet?) supported by hass-kef-connector. It is based on pykefcontrol that was created by reverse-engineering the Kef Connect app. To the best of my knowledge, the kef connect app has no "stop" button.

Maybe there is an undocumented stop command supported by the speakers. I am not a home right now so I cannot test this but if you can, please try the following :

  1. play a song on your speakers
  2. enter the following URL in a browser ;
    http://<your-speakers-ip>/api/setData?path=player:player/control&roles=activate&value={"control":"stop"}
  3. check if the playback has been effectively stopped

To double check, you could use this command :

http://<your-speakers-ip>/api/setData?path=player:player/control&roles=activate&value={"control":"pause"}

that should just toggle play/pause on the current track.

⚠️ do not forget to change <your-speakers-ip> to the correct value !

If this one is working but not the previous one, then the stop command does not work. If none are working then there is a problem on the communication with your speakers. If both are working then we are in luck ✨ and I'll implement the stop command and update hass-kef-connector to add this feature 😉

Let me know about your findings !

gurmukhp commented 9 months ago

Thanks for the indepth response!

The first URL didn't work so it looks like there is undocumented function called 'stop' :(

The second URL did work so at least we know the configuration of the speakers is good.

I did see that there was a function called close_session in pykefcontrol, could we use that?

In the KEF app, when you pause a radio station, the stream stops. Maybe it's the equivalent to close_session?

For the second URL, the audio pauses if a playlist on Spotify is playing, but if a radio station is playing, the play/pause toggle does nothing.

As for playing some music, I have realised that I could use the Google Cast speaker in Home Assistant instead of using the Kef Connector integration.

gurmukhp commented 9 months ago

I think we're all good!

shutdown works for turning the speaker off and play works for the chromecast target

this is awesome, thanks!

UNOE227 commented 9 months ago

So you think there could be a way to auto switch profiles when changing sources I requested that feature with KEF but they never implemented it.Could home assistant monitor your source and then request the change to profile?On Dec 24, 2023, at 4:42 AM, Gurmukh Panesar @.***> wrote: I think we're all good! shutdown works for turning the speaker off and play works for the chromecast target this is awesome, thanks!

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

gurmukhp commented 9 months ago

Sorry not sure I follow. I had problems with stopping playback and starting playback on the speaker via an automation.

I've now found that I can use the 'turn off' command via kef connector and 'play media' to the Chromecast target. In Home Assitant, the Kef Speaker has two devices, one is the Kef and one is the Chromecast speaker.