You are mixing the configuration of the new template sensor integration with the legacy template sensor platform.
e.g. you are using the platform structure but integration state option.
Pick one (I would suggest the new integration as it supports new features) and stick with only those available options.
Also please format your pasted configuration as per point 11 here.