Skip to content

Instantly share code, notes, and snippets.

@RustyDust
Created January 7, 2023 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RustyDust/714e316d94293c42f7daf2752d6834f6 to your computer and use it in GitHub Desktop.
Save RustyDust/714e316d94293c42f7daf2752d6834f6 to your computer and use it in GitHub Desktop.
Send message on Sonos speakers when washing machine is done
alias: Washing machine done
description: ''
trigger:
# power consuption below 3W for 5 minutes
- platform: numeric_state
entity_id: sensor.washing_machine_power
below: '3'
for: '00:05:00'
condition: []
action:
# save state of all involved Sonos players
- service: sonos.snapshot
data:
entity_id: media_player.buro
- service: sonos.snapshot
data:
entity_id: media_player.kuche
- service: sonos.snapshot
data:
entity_id: media_player.wohnzimmer_tv
# stop whatever is currently playing
- service: media_player.media_stop
data:
entity_id: media_player.buro
- service: media_player.media_stop
data:
entity_id: media_player.kuche
- service: media_player.media_stop
data:
entity_id: media_player.wohnzimmer_tv
# group Sonos players
- service: media_player.join
data:
group_members:
- media_player.buro
- media_player.kuche
- media_player.wohnzimmer_tv
target:
entity_id: media_player.buro
# adjust volume for each speaker to our taste
- service: media_player.volume_set
data:
volume_level: 0.3
target:
entity_id: media_player.buro
- service: media_player.volume_set
data:
volume_level: 0.4
target:
entity_id: media_player.kuche
- service: media_player.volume_set
data:
volume_level: 0.25
target:
entity_id: media_player.wohnzimmer_tv
# play message on Sonos group (file is in www/mp3/...)
- service: media_player.play_media
target:
entity_id: media_player.buro
data:
media_content_type: music
# generate media at https://ttsmp3.com/
media_content_id: http://homeassistant.local.ip/local/mp3/washing_machine_done.mp3
announce: true
# wait until message has finished playing
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
# dissolve Sonos group
- service: media_player.unjoin
data: {}
target:
entity_id:
- media_player.buro
- media_player.kuche
- media_player.wohnzimmer_tv
# restore old player states
- service: sonos.restore
data:
entity_id: media_player.buro
- service: sonos.restore
data:
entity_id: media_player.kuche
- service: sonos.restore
data:
entity_id: media_player.wohnzimmer_tv
# turn of outlet to minimize standby consumption
- service: switch.turn_off
data: {}
target:
entity_id: switch.washing_machine
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment