Skip to content

Instantly share code, notes, and snippets.

@grischard
Last active December 5, 2021 01:07
Show Gist options
  • Save grischard/1542d998acccb2b11593cac31d109bbf to your computer and use it in GitHub Desktop.
Save grischard/1542d998acccb2b11593cac31d109bbf to your computer and use it in GitHub Desktop.
Announce dishwasher
alias: Announce dishwasher
description: ''
trigger:
- type: turned_on
platform: device
device_id: dca4ab3e65a13fd87ad164f5237d7a87
entity_id: binary_sensor.dishwasher_done
domain: binary_sensor
condition:
- after: '07:00:00'
before: '23:00:00'
condition: time
action:
- data:
message: Dishwasher is done!
service: script.autoplay
mode: single
alias: AutoPlay
fields:
message:
description: The text to be read
example: Hello
mp3:
description: URL of an mp3 to be played. m4a might work?
example: http://192.168.1.2:8123/local/ciao.mp3
variables:
inoneear_playing: >-
{{ true if is_state("media_player.spotify_grischard", "playing") and
is_state_attr("media_player.spotify_grischard", "source", "In-One-Ear") }}
sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ true if message }}'
sequence:
- service: tts.google_cloud_say
data:
entity_id: media_player.hifiberry
message: |
<s><emphasis level="strong"> {{ message }}</emphasis></s>
- conditions:
- condition: template
value_template: '{% if mp3 %}true{% endif %}'
sequence:
- service: media_player.play_media
data:
media_content_type: audio/mpeg
media_content_id: |
{{ mp3 }}
entity_id: media_player.hifiberry
default:
- service: notify.mobile_app_guillaume_lost_stereo_lu
data:
message: |
You done goofed up! Message was {{ message }} and mp3 was {{ mp3 }}
- choose:
- conditions:
- condition: template
value_template: '{{ true if inoneear_playing }}'
sequence:
- service: media_player.media_play
target:
entity_id: media_player.spotify_grischard
default: []
mode: queued
icon: mdi:text-to-speech
max: 10
description: >-
Plays the passed message as tts, or mp3 as audio, on In-one-ear. Automatically
deals with returning to previous state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment