Is there a way to tell when you can use a data template? Like for lights, I’m pretty sure that brightness can accept a template, but not rgb_color. Today I tried to build a scene to load a random playlist into Sqeezeplay. I tried to use a template for media_content_id and it didn’t work. Is trial and error the best way to determine this?
Turns out I had an error in my code. I was able to use a template for media_content_id!
But the original question still stands…
This works (I initially had forgotten to quote strings inside the list that the random item was picked from)
randomonsqueeze:
alias: Play random playlist on Squeeze
sequence:
- service: media_player.play_media
data:
entity_id: media_player.squeezeplay
media_content_type: PLAYLIST
data_template:
media_content_id: >
{{ ["http://192.168.1.110:9000/plugins/spotifylogi/index.html?action=playall&index=7f8a835b.7.6&player=bc%3A5f%3Af4%3Ae9%3A44%3A4a&sess=&start=&_dc=1475422566117", "http://192.168.1.110:9000/plugins/spotifylogi/index.html?action=playall&index=7f8a835b.7.0&player=bc%3A5f%3Af4%3Ae9%3A44%3A4a&sess=&start=&_dc=1475422463674"] | random }}
Variations on this have failed:
weatherlighttest:
alias: Weather Light Test
sequence:
- service: light.turn_on
entity_id: light.office_rgbw
data:
brightness: 255
data_template:
rgb_color: >
{% if states.sensor.forecastio_daily_high_temperature.state | float < 32 %}[168,108,255]{% elif states.sensor.forecastio_daily_high_temperature.state | float < 55 %}[192,255,239]{% elif states.sensor.forecastio_daily_high_temperature.state | float < 80 %}[229,255,193]{% elif states.sensor.forecastio_daily_high_temperature.state | float < 95 %}[255,231,205]{% elif states.sensor.forecastio_daily_high_temperature.state | float < 105 %}[185,13,0]{% else %}[255,255,255]{% endif %}