Hi guys. Been setting up Home Assistant and am starting to play with templates. As a test, I tried creating a sensor that outputs the current temp from my Nest thermostat. Before anyone says it, I know there is an existing sensor for this. This is more a way to learn the template ropes by essentially duplicating the existing thing, so I could validate it’s working correctly by comparing the output with the existing sensor. However, I can’t even get this working! I get an error below about dictionary value. My guess is something about formatting or quotation marks, but I’ve tried many iterations and done quite a bit of Google-fu and am at a dead end. I’m sure it’s simple, and I’d appreciate if any of you HA whizzes could point out where I’m going wrong!
I should add, I put the actual template function into the template testing box in Developer and it returned the right value, so I think that should be right.
Sensors.yaml file in packages:
template:
sensors:
thermostat_curr_temp:
- friendly name: "Thermostat Current Temperature"
Unit of measurement: "°F"
value_template: '{{state_attr("climate.thermostat","current_temperature")}}'
Error in logs:
Invalid config for [template]: expected dictionary for dictionary value @ data['sensors']['thermostat_curr_temp']. Got [OrderedDict([('friendly name', 'Thermostat Current Temperature'), ('Unit of measurement', '°F'), ('value_template', '{{state_attr("climate.thermostat","current_temperature")}}')])]. (See ?, line ?).