Does anyone have a guide of when to use different syntax in scripts or animations. Lately, using examples here in the community. I have an extreme variety of methods to extract a variable and use it (Most of them, most-likely the inefficient method). For example, sometime my equation is embedded between {{ }} and other times in order to extract the value, the entire equation must be enclosed with in ’ like ‘{{ }}’ I suspect that one is a string and the other is numeric? How does one determine which is valid formatting?
Then there is she confusing syntax…
They both seem to work in the Developer Tools Template Editor, but they don’t always work the same when doing math. Is there a better way of learning the syntax other than moving things around in the Developer Tools Template Editor in hopes of recognizing what initially caused the templateSyntaxError
You don’t understand the difference between yaml and jinja here. See this link
One is the states method which just extracts the state.
{{ states('sensor.xyz') }} → Will just return the state.
The other is states objects
{{ states.sensor.xyz }} → will return the state object, which you can access all sorts of information about the entity. See link below for the information that’s inside a states object.
@petro,
Thank you for the clarification of yaml vs jinga. I was mislead earlier to believe all was yaml and anything beginning with { was part of a template and ( was a variable/state. Do I have it correctly to say that when writing my yaml chunks that contain jinga, the combined chunk is considered a template? I will agree that I am confused with all of this. Much of what I have is compiled using the process: Flow Cart Desired Event; Search for like examples, utilize UI and Developer Tools when possible, write yaml chunks (Scripts, Automation’s, etc.) Modify chunks based on log entries and results from trace and debug automation tools. Can you give any advice on when to use the term template, data_template or value_template? Honestly, I have seen examples of every variety possible, without knowing for sure, I toggle them about and chance ’ for " etc. here is an example of an automation still in the finalization phases… Basically Alexa has 5 possible responses returning to HA. the two expected are ResponseNumeric or ResponseDuration. The parts that confuse me are Conditions callout a template one way and the sequence calls it out differently. How would I determine the correct way?