#Hi I ve tried several versions and
1 messages · Page 1 of 1 (latest)
#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
Well... there's something pretty obvious missing from that second automation
- service: media_player.media_stop
data: {}
``` what _doesn't_ that include?
Hi, Tinkerer: I've also tried this: ```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:
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
with no success.
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 
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
To test an automation there's three stages you can follow. Testing the action, the condition and action, and the whole automation:
- 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 - Use Developer tools -> Services and call
automation.triggeron the automation withskip_condition: false. If the first passes but this fails then the problem is in yourcondition:block - 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.
You can also just test the service calls in
Services
show your service developer tools
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.
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