Invalid config for 'template' at templates.yaml, line 217: required key 'platform' not provided
(line 217 is the -trigger line)
I’ve tried other various formations (including starting with -trigger), but no joy. I’m not sure where to go from here - how can I add trigger based templates to an included templates.yaml file?
That doesn’t work, It seems like the documentation doesn’t translate for a separated templates file. I get the following:
2024-04-16 12:22:02.075 ERROR (MainThread) [homeassistant.config] Invalid config for 'template' at templates.yaml, line 216: 'trigger' is an invalid option for 'template', check: sensor->40->trigger
Invalid config for 'template' at templates.yaml, line 216: required key 'state' not provided
Invalid config for 'template' at templates.yaml, line 222: 'sensor' is an invalid option for 'template', check: sensor->40->sensor
if I adjust the indenting to the left, so that -trigger is “top level” in the file, I get:
2024-04-16 12:25:56.892 ERROR (MainThread) [homeassistant.components.template] while parsing a block mapping
in "templates.yaml", line 1, column 1
expected <block end>, but found '-'
in "templates.yaml", line 216, column 1
If someone has a working chunk of yaml for trigger based templates, in a separate file, I would love to see it. Thanks.
Yes, for some reason I had it in my mind, that once moving to a separate file, you dropped the array ‘-’ part - I struggled with that when splitting my configuration files. Anyway - I’ve learned something new, and it’s all for the better.
I’m trying to do similar. Although the code validates and saves OK, it doesn’t seem to work. The sensor section appears to work in Developer tools, it’s the trigger that doesn’t seem to evaluate the entity. Their states remain as ‘unknown’.
- trigger:
- platform: time
at: "23:59:50"
sensor:
- name: "Greenhouse Heater Energy"
unit_of_measurement: "kWh"
device_class: energy
state: >
{% set greenhouse_daily_energy = states('sensor.shellyheater_daily_energy') %}
- name: "Daily Gas Consumption"
unit_of_measurement: "m³"
device_class: gas
state: >
{% set gas_daily_consumption = states('sensor.current_accumulative_consumption_m3') %}
Thanks for replying. Sorry I can’t format the code correctly (Edited to correct).
I was expecting the end of day values of the two sensors to be saved as two entities. I can add the curly brakets to output their values in Developer tools OK.