I am hoping someone can help me troubleshoot this as I have tried for days to no avail.
Goal: Scrape page to get most recent podcast URL and pass that to media_player.play_media
I have created a sensor that scrapes the podcast URL:
configuration.yaml
sensor:
- platform: scrape
resource: http://feeds.podtrac.com/zKq6WZZLTlbM
name: podcast_the_daily
select: 'enclosure:nth-of-type(1)'
attribute: url
scan_interval: 900
Adding
{{ states.sensor.podcast_the_daily.state }}
to template returns the correct URL
https://dts.podtrac.com/redirect.mp3/rss.art19.com/episodes/e163ee32-7ae9-453e-a81e-a8c4e60a4c96.mp3
But when I create a script to play the media, it won’t work:
morning_podcast:
alias: Morning Podcast
sequence:
- service: media_player.play_media
entity_id:
- media_player.livingroom
data_template:
media_content_id: >
{{ states.sensor.podcast_the_daily.state }}
media_content_type: audio/mp3
I have checked the logs and I am not getting any sort of error either. I have verified that pasting the URL directly into the script works, just not when I try and use the sensor.
Does anyone have any idea what I might be doing wrong here? Any help would be appreciated.