Documentation examples could be more useful to show example outputs

As I’m new to all this and trying to wrap my head around things. I’m making my way through the documentation. ‘templating’ features plenty of code examples, which is great but it would be very useful if those examples displayed examples of the outputs.

{{ expand(['device_tracker.paulus', 'group.child_trackers'])
  | selectattr("attributes.battery", 'defined')
  | join(', ', attribute="attributes.battery") }}

This would greatly help to understand exactly what is happening in the code.

For a lot functions, like expand(), it would just be a block of text that wouldn’t be all that helpful. It’s better to try the different functions out for yourself in the Template editor tool so you can relate the results to entities you actually have access to.

Jinja Cheatsheet
Jinja for Ninjas

2 Likes