I can call the service from Developer tools/Services and it works 100% of the time:
Service: media_player.play_media
Entity: media_player.living_room_speaker
Service Data:
{
"entity_id": "media_player.living_room_speaker",
"media_content_id": "https://myurl.com:8123/local/doorbell.mp3",
"media_content_type": "audio/mp3"
}
However it does nothing in my automation:
- id: '1536205374176'
alias: Detect door button push and ring chime
trigger:
- entity_id: binary_sensor.doorbell
from: 'off'
platform: state
to: 'on'
action:
- service: media_player.media_play
data:
entity_id: media_player.living_room_speaker
media_content_id: https://myurl.com:8123/local/doorbell.mp3
media_content_type: audio/mp3
- service: notify.pushover
data:
message: Doorbell Pressed
title: Doorbell Pressed
I know the automation is firing because I get the “Doorbell Pressed” notification via Pushover. The configuration looks right from https://www.reddit.com/r/homeassistant/comments/6m8tuh/play_audio_through_google_home/
In the log I get:
Oct 18 11:48:00 16elford hass[2589]: 2018-10-18 11:48:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.doorbell, old_state=<state binary_sensor.doorbell=off; friendly_name=Doorbell @ 2018-10-18T11:45:06.007790-04:00>, new_state=<state binary_sensor.doorbell=on; friendly_name=Doorbell @ 2018-10-18T11:48:00.543039-04:00>>
Oct 18 11:48:00 16elford hass[2589]: 2018-10-18 11:48:00 INFO (MainThread) [homeassistant.components.automation] Executing Detect door button push and ring chime
Oct 18 11:48:00 16elford hass[2589]: 2018-10-18 11:48:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event logbook_entry[L]: name=Detect door button push and ring chime, message=has been triggered, domain=automation, entity_id=automation.detect_door_button_push_and_ring_chime>
Oct 18 11:48:00 16elford hass[2589]: 2018-10-18 11:48:00 INFO (MainThread) [homeassistant.helpers.script] Script Detect door button push and ring chime: Running script
Oct 18 11:48:00 16elford hass[2589]: 2018-10-18 11:48:00 INFO (MainThread) [homeassistant.helpers.script] Script Detect door button push and ring chime: Executing step call service
Oct 18 11:48:00 16elford hass[2589]: 2018-10-18 11:48:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=media_player, service=media_play, service_data=entity_id=media_player.living_room_speaker, media_content_id=https://myurl.com:8123/local/doorbell.mp3, media_content_type=audio/mp3, service_call_id=140375639587416-26>
Oct 18 11:48:00 16elford hass[2589]: 2018-10-18 11:48:00 ERROR (MainThread) [homeassistant.core] Invalid service data for media_player.media_play: extra keys not allowed @ data[‘media_content_id’]. Got ‘https://myurl.com:8123/local/doorbell.mp3’
Oct 18 11:48:00 16elford hass[2589]: extra keys not allowed @ data[‘media_content_type’]. Got ‘audio/mp3’
Oct 18 11:48:00 16elford hass[2589]: 2018-10-18 11:48:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=140375639587416-26>
Oct 18 11:48:00 16elford hass[2589]: 2018-10-18 11:48:00 INFO (MainThread) [homeassistant.helpers.script] Script Detect door button push and ring chime: Executing step call service
Oct 18 11:48:00 16elford hass[2589]: 2018-10-18 11:48:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=notify, service=pushover, service_data=message=Doorbell Pressed, title=Doorbell Pressed, service_call_id=140375639587416-27>
Oct 18 11:48:00 16elford hass[2589]: 2018-10-18 11:48:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=140375639587416-27>
Oct 18 11:48:00 16elford hass[2589]: 2018-10-18 11:48:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.detect_door_button_push_and_ring_chime, old_state=<state automation.detect_door_button_push_and_ring_chime=on; last_triggered=2018-10-18T11:45:05.074770-04:00, id=aa, friendly_name=Detect door button push and ring chime @ 2018-10-18T11:43:59.776020-04:00>, new_state=<state automation.detect_door_button_push_and_ring_chime=on; last_triggered=2018-10-18T11:48:00.995961-04:00, id=aa, friendly_name=Detect door button push and ring chime @ 2018-10-18T11:43:59.776020-04:00>>
Oct 18 11:48:01 16elford hass[2589]: 2018-10-18 11:48:01 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.doorbell, old_state=<state binary_sensor.doorbell=on; friendly_name=Doorbell @ 2018-10-18T11:48:00.543039-04:00>, new_state=<state binary_sensor.doorbell=off; friendly_name=Doorbell @ 2018-10-18T11:48:01.900336-04:00>>
What’s wrong with my automation? I’ve tried adding quotes around ‘https://myurl.com:8123/local/doorbell.mp3’ and ‘audio/mp3’ in the config to no avail.