Confusion of syntax in variables and templates

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…

{{ states('input_number.rgb_r') }}
{{ states.input_number.rgb_r.state }}

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.

And you should use the method whenever possible.

https://www.home-assistant.io/docs/configuration/templating/#states

@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?

alias: basement_lights_alexa_response
id: basement_lights_alexa_response
trigger:
  - platform: event
    event_type: alexa_actionable_notification
    event_data:
      event_id: basement_lights
      event_response_type: ResponseYes
    id: basement_lights_response_yes
  - platform: event
    event_type: alexa_actionable_notification
    event_data:
      event_id: basement_lights
      event_response_type: ResponseNo
    id: basement_lights_response_no
  - platform: event
    event_type: alexa_actionable_notification
    event_data:
      event_id: basement_lights
      event_response_type: ResponseNone
    id: basement_lights_response_none
  - platform: event
    event_type: alexa_actionable_notification
    event_data:
      event_id: basement_lights
      event_response_type: ResponseSelect
    id: basement_lights_response_select
  - platform: event
    event_type: alexa_actionable_notification
    event_data:
      event_id: basement_lights
      event_response_type: ResponseNumeric
    id: basement_lights_response_numeric
  - platform: event
    event_type: alexa_actionable_notification
    event_data:
      event_id: basement_lights
      event_response_type: ResponseDuration
    id: basement_lights_response_duration
condition: []
action:
  - choose:
    - conditions:
      - condition: trigger
        id: basement_lights_response_yes
      sequence:
      - service: input_number.set_value
        data:
          value: 5
        target:
          entity_id: input_number.timer_basement
    - conditions:
      - condition: trigger
        id: basement_lights_response_no
      sequence:
      - service: input_number.set_value
        data:
          value: 0
        target:
          entity_id: input_number.timer_basement
    - conditions:
      - condition: trigger
        id: basement_lights_response_none
      sequence:
      - service: input_number.set_value
        data:
          value: 0
        target:
          entity_id: input_number.timer_basement
    - conditions:
      - condition: trigger
        id: basement_lights_response_select
      sequence:
      - service: input_number.set_value
        data:
          value: 0
        target:
          entity_id: input_number.timer_basement
    - conditions:
      - condition: trigger
        id: basement_lights_response_numeric
      - condition: template
        value_template: "{{ '0' <= trigger.event.data.event_response<= '60' }}"
      sequence:
      - service: input_number.set_value
        data_template:
          value: >-
            {{ trigger.event.data.event_response | int(default=0) }}
        target:
          entity_id: input_number.timer_basement
    - conditions:
      - condition: trigger
        id: basement_lights_response_numeric
      sequence:
      - service: script.activate_alexa_actionable_notification
        data:
          text: Sorry, the maxium is sixty minutes at a time. How many minutes longer?
          event_id: basement_lights
          alexa_device: media_player.basement
    - conditions:
      - condition: trigger
        id: basement_lights_response_duration
      sequence:
      - service: input_number.set_value
        data_template:
          value: >-
            {{ trigger.event.data.event_response | int(default=0)/60 }}
        target:
          entity_id: input_number.timer_basement
mode: single