Hi Nick,
yes, the name of my entity is correct.
I used the dev tools (template) to test the template I got from some conversation and adopt it, but doesn’t work.
I see 5 day forecast in my UI, but can’t get this values out via template. The sample uses indices to extract the element 0 of an array, but there is no array, the dev tools told me …
With best regards
Gerhard
I have this element in my UI …
If there is extra work to do, please give my a pointer how and where (I am still a newbee).
Thanks a lot.
With best regards
Gerhard
It shows how to create a Trigger-based Template Sensor that reports today’s hourly temperature and automatically updates every hour.
I have modified the example to meet your requirements (get tomorrow’s daily temperature, updated every hour and whenever Template Entities are reloaded).
Is there a related error message in Settings → Logs?
You said you put it in the configuration.yaml file. Does that file already contain a template: key?
Because if you copy-pasted my example into the file, the first line of the example is a template: key so if there’s already a template: key in the file you will have duplicated it (it should never be duplicated).
NOTE
If your configuration.yaml file contains something that looks like this:
template: !include templates.yaml
It means the configuration for Template entities are located in a separate file named templates.yaml.
Examine your configuration.yaml file and let me know if it already contains a template: key and if it has an !include or not.
If it does contain a template: key (but no !include), paste my example directly under it and ensure there’s only one instance of the template: key.
If this is the very first Template entity you have ever created, restart Home Assistant in order to load it. If you already have other Template entities, you can simply use Developer Tools → YAML → Reload Template Entities.
Ok, not that easy. I have to learn lot about this ‘yaml’ …
Ok, to get things structured I created a templates.yaml file.
I included it.
And I learned, that the key ‘template:’ is in configuration.yaml and the content is in templates.yaml. Otherwise I get some message that the line ‘template:’ isn’t allowed.
Ok, now I have the same problem as I get when I copied the code directly into configuration.yaml before which does’n contain a ‘template’ key before:
It looks like, that something was changed in HA and this syntax isn’t valid any longer.
This error was maybe misinterpreted by me, I first thought, that this code is not for configuration.yaml.
With best regards
Gerhard
PS: By the way, is it usual that syntax is broken with updated very often? My working eMail notification service is also in error and the message is more or less the same.
Note that the syntax parsing/error codes in vscode is not maintained by the Home Assistant project, and is occasionally incorrect or out of date.
So when you see errors in vscode take it with a grain of salt. You can try ignoring it and check your configuration with the official config check tool in Developer Tools.
That’s entirely optional. As explained, it can be placed within configuration.yamlas long as it’s done correctly.
It’s different, not the same. As explained by karwosts, that message isn’t produced by Home Assistant. It’s produced by the VS Code editor, specifically by a plug-in used by VS Code called Home Assistant Config Helper.
It’s still valid.
Recently, Home Assistant renamed several keys used in automations (and Trigger-based Template entities) such as platform and service (to trigger and action, respectively). The old names still work but Config Helper identifies them anyways.
To make Config Helper’s message go away, replace the word platform with trigger. Refer to my original example posted above which I have already updated.
NOTE
If you wish, you can remove the second trigger. It’s there merely as a convenience for you.
It’s sole purpose is to ensure that the Trigger-based Template Sensor produces a value the moment you execute Reload Template Entities. You get an initial result immediately
Without that second trigger, the Sensor’s initial value will be unknown and will remain that way until the Time Pattern Trigger fires (on the hour, every hour). You have to wait for the initial result.