Hi,
Awesome component, works great when I try the service by itself on the Developer tools, however it does throw a fit when I try to script with it.
My script is as follows:
spotify_test2:
alias: "Spotify test2"
sequence:
- service: spotcast.start
data_template:
device_name: >
{% if is_state("input_select.spotify_source","Grupo del Hogar (synced)") %} Grupo del Hogar
{% elif is_state("input_select.spotify_source","Comedor") %} Comedor
{% elif is_state("input_select.spotify_source","Pasillo Principal") %} Pasillo Principal
{% elif is_state("input_select.spotify_source","Recamara Principal Ducha") %} Recamara Principal Ducha
{% elif is_state("input_select.spotify_source","Recamara Principal") %} Recamara Principal
{% elif is_state("input_select.spotify_source","Recamara Principal Buro") %} Recamara Principal Buro
{% elif is_state("input_select.spotify_source","Grupo de Recamara Principal") %} Grupo de Recamara Principal
{% elif is_state("input_select.spotify_source","Recamara de Visitas") %} Recamara de Visitas
{% elif is_state("input_select.spotify_source","Oficina") %} Oficina
{% elif is_state("input_select.spotify_source","Grupo de Limpieza") %} Grupo de Limpieza
{% elif is_state("input_select.spotify_source","Solo Bocinas") %} Solo Bocinas
{% elif is_state("input_select.spotify_source","Solo Bocinas Inteligentes") %} Solo Bocinas Inteligentes
{% endif %}
uri: >
{% if is_state("input_select.spotify_playlist","Sueño Profundo") %}spotify:playlist:37i9dQZF1DX7aAuYd7Jogj
{% elif is_state("input_select.spotify_playlist","Solo Bocinas Inteligentes") %}
{% endif %}
random_song: true
I tested the if statements on the developer tools template section and they respond with the correct data.
If Statement 1 returns: Oficina
If Statement 1 returns: spotify:playlist:37i9dQZF1DX7aAuYd7Jogj
However the component complains that the ‘Spotify’ object has no attribute 'playlist_tracks’
2020-07-07 18:14:47 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall script.spotify_test2 (c:cb11f265f11640dd9676a86393c40dc5)>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1276, in catch_exceptions
await coro_or_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1295, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 204, in service_handler
await script.async_turn_on(variables=service.data, context=service.context)
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 280, in async_turn_on
await self.script.async_run(kwargs.get(ATTR_VARIABLES), context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 831, in async_run
await run.async_run()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 555, in async_run
await self._async_run()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 572, in _async_run
await self._async_step(log_exceptions=not propagate_exceptions)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 153, in _async_step
self, f"_async_{cv.determine_script_action(self._action)}_step"
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 656, in _async_call_service_step
*self._prep_call_service_step(), blocking=True, context=self._context
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1299, in _execute_service
await self._hass.async_add_executor_job(handler.func, service_call)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/spotcast/__init__.py", line 242, in start_casting
play(client, spotify_device_id, uri, random_song, repeat, shuffle, position)
File "/config/custom_components/spotcast/__init__.py", line 172, in play
results = client.playlist_tracks(uri)
AttributeError: 'Spotify' object has no attribute 'playlist_tracks'
Not sure if I missed something, or I’m doing something wrong. It might be all the identation spaces that are introduced in the mix when using the data_template.
Any and all help would be greatly appreciated.