Template sensor not working as expected

Have a look at this:

Basically it comes down to this: