Home Assistant Templates

I have been getting to grips with Home Assistant (hassio). (This was after attempting, late at night and tired, to update OpenHab… It didn’t go well and though I had solid backups I knew I would need to do a full restore and have kept hearing about Home Assistant. I wanted to give it a try, and found it is so much better than OpenHab. I had everything OpenHab had and more in one morning of play. Everythign is so much easier).

So the more I got in to hassio the more I kept hearing about Templates. Hassio is well documented but there are no examples at all. I can read them but miss the point because, typiccally, I read too fast.

So when the Templating documentation said:

Templating in Home Assistant is powered by the Jinja2 templating engine. This means that we are using their syntax and make some custom Home Assistant variables available to templates during rendering.


I didn’t realise this meant “custom code”. That would have helped. Template = Custom Code in Jinja2!

I went in to the Developer Tools > Template and had a play (with the help of avideo by “Smart Home Junkie”) I found that I could easily get the value of things using {{ states(‘the_thing’) }} (I also found that the Dutch word for curly bracket is “accolade” which is way better to my ear).

With my new knowledge I made my first Template to show the current rate as a read only thing so I can display is safely.

  1. A name – this is what you look up later and is turned in to a spaceless name, this one would become current_rate
  2. The Jinja2 code
  3. Preview

I made a sensor called “Current electricity period” and magic happened when creating a dashboard.

I know it is basic knowledge, but I needed to make this first step. I think I am away now.