#Hi I ve tried several versions and

1 messages · Page 1 of 1 (latest)

minor cave
#

#the following automation works:

alias: Radio UK Play
description: ""
trigger:
  - platform: state
    entity_id: input_boolean.radio_uk
    to: "on"
condition: []
action:
  - service: media_player.play_media
    data:
      media_content_id: >-
        http://stream.live.vc.bbcmedia.co.uk/bbc_radio_wales_fm?s=1641199659&e=1641214059&h=c0da96092edbdc9142733a3e69aad041
      media_content_type: audio/mp4
    target:
      entity_id: media_player.vlc_telnet
mode: single

#but this (and several other versions) don’t do anything to stop the VLC media player:

alias: Radio UK Stop
description: ""
trigger:
  - platform: state
    entity_id: input_boolean.radio_uk
    to: "off"
condition:
  - condition: state
    entity_id: media_player.vlc_telnet
    state: playing
action:
  - service: media_player.media_stop
    data: {}
mode: single
atomic eagle
#

Well... there's something pretty obvious missing from that second automation

#
  - service: media_player.media_stop
    data: {}
``` what _doesn't_ that include?
minor cave
#

with no success.

atomic eagle
#
    target:
      entity_id: media_player.vlc_telnet
``` you need the target to tell it _what_ to stop
#

You don't stop something and include the media to play though, so you don't include

    data:
      media_content_id: >-
        http://stream.live.vc.bbcmedia.co.uk/bbc_radio_wales_fm?s=1641199659&e=1641214059&h=c0da96092edbdc9142733a3e69aad041
      media_content_type: audio/mp4
#
  - service: media_player.media_stop
    target:
      entity_id: media_player.vlc_telnet
``` will _probably_ do it, but the log should tell you if there's issues
#

I also know that some media players don't support stop, you need to pause shrug

minor cave
#

Aaah, I'll try pause since I've tried this it also doesn't work.```alias: Radio UK Stop
description: ""
trigger:

  • platform: state
    entity_id: input_boolean.radio_uk
    to: "off"
    condition:
  • condition: state
    entity_id: media_player.vlc_telnet
    state: playing
    action:
  • service: media_player.media_stop
    data: {}
    target:
    entity_id: media_player.vlc_telnet
    mode: single```
#

this also doesn't work (I am reloading automations -YAML configuration reloading- after each change)```action:

  • service: media_player.media_play_pause
wispy phoenixBOT
#

To test an automation there's three stages you can follow. Testing the action, the condition and action, and the whole automation:

  1. Use Configuration -> Automations to find the automation and then push Run Actions. If this fails your problem is in the action: section, and details should be found in your log file
  2. Use Developer tools -> Services and call automation.trigger on the automation with skip_condition: false. If the first passes but this fails then the problem is in your condition: block
  3. Use Developer tools -> States to find the trigger entity, click the name, then change the state (at the top) to something that'll trigger the automation before pushing Set State. If this fails then the problem is with your trigger: section, or the automation is turned off (you can check that in Developer tools -> States).

You can also see this section in the docs and with HA 2021.4 onwards debug automations.

atomic eagle
#

You can also just test the service calls in devtools Services

wispy phoenixBOT
minor cave
#

I'm on it. Thanks, and good chatting with you again. (I forgot to troubleshoot using the excellent tools in HA) I'll be more diligent in the future.

minor cave
#

Here is a working automation in case it is of use to anyone:

#
description: ""
trigger:
  - platform: state
    entity_id: input_boolean.radio_uk
    to: "off"
condition:
  - condition: state
    entity_id: media_player.vlc_telnet
    state: playing
action:
  - service: media_player.media_stop
    data: {}
    target:
      entity_id: media_player.vlc_telnet