Category Archives: General

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.

https://www.home-assistant.io/docs/configuration/templating/

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.

100d/100h update

I have been pressing on with this.  But got very tired by the third Friday and “counted” my full day at work, which is a bit of a cheat.  Discretion is the better part of valour I guess.  I made up for it with a long bike ride on the Saturday.

I think yesterday was day 21?

100d/100h d15

Well, I have managed a 15th straight day of doing an hour of exercise, but today was a bit of a bomb. I cycled for 30 minutes on my turbo but my heart was not in it and I will have to go for a short walk later if I am really going to complete the full hour.

I think I should probably have a break from it all, but an hour a day seems so little, especially if I walk, that I want to keep it up.

Bleah.