I know this is old, and maybe solved by now, but I happened upon this subject while searching for examples of the value template. I solved it by not having a value template in this sensor and then making a template sensor with the stuff I want. But I think the problem is that you’re trying to get the value from the sensor in the regular template way, then it’s trying to evaluate it self while it’s getting the new value. That doesn’t work. I think you should’ve skipped “states.sensor.gmail_carnet.attributes” and go right to “subject”. Maybe someone else happens upon this and can be helped by this.