Hello All,
I have been having a hard time getting a particular automation working.
Specifically I cannot get the template below to respond as I expect it too.
I am using a Sonos to play wave files local on the HA server.
The automation fairly simple and tested to work fine without the template.
This leads me to believe I am missing something simple in the template.
If I manually set the media_player.play_media Media_content the automation works:
media_content_id: "http://192.168.#.123:8123/local/W01.wav"
Replacing the above URL with the below template throws errors.
Template:
{%- set responses = [
"http://192.168.#.123:8123/local/W01.wav",
"http://192.168.#.123:8123/local/W02.wav",
"http://192.168.#.123:8123/local/W03.wav",
"http://192.168.#.123:8123/local/W04.wav",
"http://192.168.#.123:8123/local/W05.wav",
"http://192.168.#.123:8123/local/W06.wav"
] -%}
{% set rindex = (range(0, (responses | length - 1) )|random) -%}
{{responses[rindex]}}
As soon as I add the template I begin receiving errors.
The template itself respond as expected in the template tester in Home Assistant.
Oct 06 23:15:12 PiMenu hass[31417]: 2017-10-06 23:15:12 ERROR (Thread-7) [soco.services] UPnP Error 714 received: Illegal MIME-Type from 192.168.##
Oct 06 23:15:12 PiMenu hass[31417]: self.handle_upnp_error(response.text)
Oct 06 23:15:12 PiMenu hass[31417]: File "/srv/homeassistant/lib/python3.4/site-packages/soco/services.py", line 469, in handle_upnp_error
Oct 06 23:15:12 PiMenu hass[31417]: error_xml=xml_error
Oct 06 23:15:12 PiMenu hass[31417]: soco.exceptions.SoCoUPnPException: UPnP Error 714 received: Illegal MIME-Type from 192.168.26.114
Oct 06 23:15:12 PiMenu hass[31417]: 2017-10-06 23:15:12 ERROR (Thread-7) [homeassistant.components.media_player.sonos] Error on play_media with UPnP Error 714 received: Illegal MIME-Type from ###
Full Automation
#############################################
## Sonos Door Chime
#############################################
- alias: 'Door Enter Chime'
id: doorenterchime
trigger:
- platform: state
entity_id: sensor.frontdoor_contact2_access_control
from: '23'
to: '22'
condition:
- condition: state
entity_id: input_boolean.laser_trip
state: 'off'
action:
- delay: '00:00:01'
- service: media_player.play_media
data:
entity_id: media_player.office
media_content_id: >-
{%- set responses = [
"http://192.168.#.123:8123/local/W01.wav",
"http://192.168.#.123:8123/local/W02.wav",
"http://192.168.#.123:8123/local/W03.wav",
"http://192.168.#.123:8123/local/W04.wav",
"http://192.168.#.123:8123/local/W05.wav",
"http://192.168.#.123:8123/local/W06.wav"
] -%}
{% set rindex = (range(0, (responses | length - 1) )|random) -%}
{{responses[rindex]}}
media_content_type: "music"
Am I missing something on the template? Any help would be greatly appreciated.
Thanks!
Dustin H