Hi
Is there any way to read text from url.
I want my Google Home to read article about “random subject” when my kids using bathroom in the morning.
I am thinking about some predefinied topics like science etc but want to start with this https://en.m.wikipedia.org/wiki/Wikipedia:Random
I have working Google cloud integration but how to pass article to tts
You will have to store the text you want in an attribute of the sensor as the state is limited to 255 characters. Attributes do not have this limit.
Once you have that done it’s trivial to send the attribute value to tts using a template, assuming the attribute is called “body_text”:
service: tts.google_translate_say
entity_id: media_player.whatever
data:
message: "{{state_attr('sensor.your_scrape_sensor', 'body_text') }}"
The non-trivial part is getting the scrape sensor to grab the text you want. Good luck.
Hi Tom. Thanks for your reply. Still don’t get it what is “attribute” of sensor. Cant find anything here https://www.home-assistant.io/integrations/sensor/. There is attribute in scrape manual but it reffers to attribute of html tag as I understand it correctly.
This what I have now
sensor.yaml
- platform: scrape
resource: https://pl.wikipedia.org/wiki/Specjalna:Losowa_w_kategorii/Fizyka_j%C4%85drowa
name: Nauka
select: ".mw-parser-output p"
value_template: '{{ value | truncate(255) }}'
and automation
alias: Ciekawostki naukowe
description: ''
trigger:
- platform: state
entity_id: binary_sensor.garaz_motion
condition: []
action:
- service: tts.google_say
data_template:
entity_id: media_player.roza_speaker
message: >-
Umilę Ci czas ciekawostkami z wikipedia. Kategoria nauka. {{
states('sensor.nauka') }}
mode: single
and this is limmited to 255 characters as you said.