I want to have some way to get some news either displayed to me or read to me using TTS. I had problems with RSS feeds, but I found out I can use a Reddit sensor in HA. I got that to work, and basically would like to try having the TTS read out loud just the post titles to me. This information is found in the sensor attributes, but so far I’ve only been able to get the TTS to read the whole thing, including links, weird characters, all that jazz.
I tried to use this YAML but it isn’t working:
service: tts.cloud_say
data:
entity_id: media_player.nest_living_room
message: Here are some news. {{ state_attr('sensor.reddit_worldnews', 'title') }}
Appreciate any ideas. Basically even though this is incredibly rudimentary, I feel like I’m almost there. I just don’t know how to tell HA which bit of attributes I want it to pick and select instead of just grabbing all of them.
…but I’d like to be able to create a TTS that just reads out the first price value and the ‘trading-name’. I’m not sure how to access the next ‘level’ of data in the json output.
Sorry, those weren’t meant to be there actually - I accidentally left them in as I copied the attributes. This is the full list of attributes without the headers or anything extra:
- id: psx72n
url: >-
https://nypost.com/2021/09/21/brazils-unvaccinated-president-eats-pizza-on-nyc-sidewalk/
title: Brazil’s unvaccinated president had to eat pizza on NYC sidewalk
score: 2941
comms_num: 267
created: 1632274960
body: ''
- id: pswp4q
url: >-
https://edmonton.citynews.ca/2021/09/20/alberta-bar-threats-vaccine-passport/
title: >-
Alberta bar closes after 'overwhelming' number of threats after opting into
vax pass
score: 2604
comms_num: 427
created: 1632273187
body: ''
- id: psw70z
url: >-
https://www.npr.org/2021/09/21/1039380004/gilgamesh-dream-tablet-hobby-lobby-iraq-return
title: >-
An Ancient Tablet, Stolen Then Acquired By Hobby Lobby, Will Be Returned To
Iraq
score: 2047
comms_num: 152
created: 1632271444
body: ''
- id: psrgbm
url: >-
https://www.france24.com/en/live-news/20210921-xi-tells-un-china-will-stop-funding-coal-projects-overseas
title: Xi tells UN China will stop funding coal projects overseas
score: 3730
comms_num: 459
created: 1632256612
body: ''
- id: psy92w
url: >-
https://www.reuters.com/world/americas/brazils-health-minister-tests-positive-covid-19-nyc-2021-09-22/
title: Brazil's health minister tests positive for COVID-19 in NYC
score: 728
comms_num: 45
created: 1632278718
body: ''
- id: pshvi0
url: >-
https://www.reuters.com/world/europe/france-weighs-australia-options-urges-britain-restore-trust-2021-09-21/
title: Germany warns of lost U.S. trust as France wins EU support
score: 7540
comms_num: 2788
created: 1632227908
body: ''
- id: psfaii
url: >-
https://www.reuters.com/world/uk/prince-andrew-is-served-accusers-sexual-assault-lawsuit-united-states-lawyers-2021-09-21/
title: Prince Andrew is served sexual assault lawsuit in United States
score: 67983
comms_num: 2757
created: 1632216456
body: ''
- id: psytcu
url: https://gizmodo.com/amazon-is-lobbying-the-u-s-to-legalize-weed-1847719317
title: Amazon Is Lobbying the U.S. to Legalize Weed
score: 324
comms_num: 96
created: 1632280772
body: ''
- id: pst2xj
url: >-
https://theintercept.com/2021/09/21/afghanistan-taliban-ahmad-massoud-flee/?utm_campaign=theintercept&utm_source=twitter&utm_medium=social
title: With No U.S. Support, Leaders of Afghan Resistance Flee the Country
score: 843
comms_num: 151
created: 1632261143
body: ''
- id: pt1qhi
url: >-
https://www.news.com.au/world/europe/furious-dad-made-paedophile-friend-who-abused-his-daughter-dig-his-own-grave/news-story/8c6ddb194c0e7070f8cbb8d0c7d3350d
title: >-
Furious dad ‘made paedophile friend who abused his daughter dig his own
grave’
score: 163
comms_num: 71
created: 1632292776
body: '
This looks like it’s working! It’s putting all the titles into one big string of text though, I’d need to figure out how to separate them somehow in case I want the TTS to say something in between them… I wonder if there’s a way to say each title in a separate piece of code? For example, to define which number of title on the list of titles we want to be using, etc…
I will test this in the automation and will report back!
If Hellis81’s template works you did not list all the attributes. This makes it very difficult to help you without making assumptions. Fortunately for you Hellis81’s assumption was correct. In future when someone asks you to list all the attributes, actually list all the attributes.
And… I hate to say this… But sometimes a picture of the developer tools is better than copying the text.
If you look at how Dave posted he had a picture that showed the layout which means it’s easy to see what the JSON is but also the text in case we needed to test something.
Generally text is better than images, but in some cases an image can help convey what the text does not tell us.
Hmmm. I wasn’t actually looking at this through developer tools but the Overview tab, I think that might be the source of our confusion. I also left out the outlined part below because I assumed it irrelevant to the question, apologies. I’m still kinda new to some of the HA features, haven’t really been using developer tools up until now if I’m honest.