Hi all,
Thanks to latest input_text component now I was able to store scores and announce them to Google Home when ever ESPN sends updates via IFTTT. Also used a script component to announce these updates on demand.
Final score text from ESPN
Final: Cardinals 7 Pirates 0. WP: STL M Wacha (12-7) LP: PIT I Nova (11-13) (ESPN)
Here I used only strings before WP.
In progress update from ESPN
Cardinals lead the Reds 6-1 at the end of the 3rd. Pitching: CIN R Stephenson, STL L Lynn (ESPN)
Here I used only strings before . (period). In this instance ‘3rd.’
Here are few snippets of the logic.
input_text:
espn_score:
name: ESPN Cardinals Score
initial: SomeText
espn_baseball_in_game_update:
name: ESPN Cardinals ingame update score
initial: SomeTextInGame
sensor:
# store baseball score to announce that later on that day
- platform: mqtt
state_topic: "/home/sports/cardsfinalscore"
name: "Cardinals Final Score"
value_template: "{{ value }}"
- platform: mqtt
state_topic: "/home/sports/cardsingameupdatescore"
name: "Cardinals In Game Update"
value_template: "{{ value }}"
Script component:
script:
cardinals_final_score:
alias: Cardinals score
sequence:
- service: media_player.turn_on
entity_id: media_player.living_room_home
- service: media_player.volume_set
entity_id:
- media_player.living_room_home
data:
volume_level: 0.6
- service: tts.google_say
data_template:
entity_id: media_player.living_room_home
message: >
{% if now().strftime("%H")|int < 12 %}
Good morning Cardinals Fans
{% elif now().strftime("%H")|int < 18 %}
Good afternoon Cardinals Fans
{% else %}
Good evening Cardinals Fans
{% endif %}
{% if states.sensor.cardinals_final_score.state != 'unknown' %}
final score update {{ states.sensor.cardinals_final_score.state.split('WP')[0] }}
{% else %}
at this moment there is no final score information
{% endif %}
cardinals_ingame_update_score:
alias: Cardinals Game Inprogress update
sequence:
- service: media_player.turn_on
entity_id: media_player.living_room_home
- service: media_player.volume_set
entity_id:
- media_player.living_room_home
data:
volume_level: 0.6
- service: tts.google_say
data_template:
entity_id: media_player.living_room_home
message: >
{% if now().strftime("%H")|int < 12 %}
Good morning Cardinals Fans
{% elif now().strftime("%H")|int < 18 %}
Good afternoon Cardinals Fans
{% else %}
Good evening Cardinals Fans
{% endif %}
{% if states.sensor.cardinals_in_game_update.state != 'unknown' %}
{{ states.sensor.cardinals_in_game_update.state }}
{% else %}
at this moment there is no game update
{% endif %}
# add - <break time='0.5s'/>
Automation components:
- alias: Cardinals baseball final game update
initial_state: true
hide_entity: true
trigger:
platform: state
entity_id: input_text.espn_score
action:
- service: script.voice_notify
data_template:
value1: "Hello Cardinals Fans - score update - {{ states.input_text.espn_score.state.split('WP')[0] }}"
- service: mqtt.publish
data_template:
topic: "/home/sports/cardsfinalscore"
retain: true
qos: 1
payload: '{{ trigger.to_state.state }}'
- alias: Cardinals baseball in progress game update
initial_state: true
hide_entity: true
trigger:
platform: state
entity_id: input_text.espn_baseball_in_game_update
action:
- service: script.voice_notify
data_template:
value1: "Hello Cardinals Fans - Cardinals Game update - {{states.input_text.espn_baseball_in_game_update.state.split('.')[0]}}"
- service: mqtt.publish
data_template:
topic: "/home/sports/cardsinprogressscore"
retain: true
qos: 1
payload: '{{ trigger.to_state.state }}'
Group component:
group:
score_card:
name: Scores
entities:
- script.cardinals_final_score
- script.cardinals_ingame_update_score
Thank you