Trying to send an int to and from a script

I have made a test automation to try sending and receiving ints to and from a script. I use a helper to trigger an automation that call the script.

alias: Test
description: A test automation written in the horrible YAML
triggers:
  - trigger: numeric_state
    entity_id:
      - input_number.test
    above: 1
conditions: []
actions:
  - variables:
      test_send: "{{ states('input_number.test') | int }}"
  - action: script.value_plus_five
    metadata: {}
    data:
      value: test_send
    response_variable: result
  - variables:
      test_return: "{{ result.value }}"
  - if:
      - condition: template
        value_template: "{{ test_result > 3 }}"
    then:
      - action: fan.toggle
        metadata: {}
        target:
          entity_id: fan.office_fan
        data: {}
mode: single
alias: Value_plus_five
description: more horrible YAML
sequence:
  - variables:
      value_plus_five: "{{ input_int + 5 }}"
      return_dict: "{{ {'value': value_plus_five} }}"
  - stop: returning value + 5
    response_variable: return_dict
fields:
  input_int:
    selector:
      number:
        min: 1
        max: 100
    required: true

I work with C, C++, Object C, Java and even some Python, ... . I find markup languages like programing languages with all of the good stuff removed and replaced with bad syntax. I have tried IA but none of the returned examples work as you can see from above, meaning the web does not contain accurate information on YAML. The YouTube videos do not use ints, just strings and many of those examples do not work also. Is YAML syntax changing weekly? The hardest part is the "single quotes, double quotes, {, {{, (, : ...". It seems almost random to me. I would like to pass variables to and from scripts (I use as subroutines) with out making a helper (global), which is how I do it now. Wow would I like a terminal, a print statement and a syntax checker. The syntax checker is now: I save, exit, and open again, things just change with out warning (ex: [object:object]: null). Tried developer tool documentation but the made YAML documentation look good.

I like Home Assistant but wish there was a "C" or Unix like version. fi is looking better every day.

History of "C", it was the third try, "A" and "B" did not work. Seems YAML has an A in it. Can't wait for YCML.

Sorry about all of the complaining, but this is taking me longer than adding on the fly bit width changes to the jpeg-6b library (call jpeg-6c).

You are missing quotes and delimiters, and the variable isn't named correctly for what the script requires:

  - action: script.value_plus_five
    metadata: {}
    data:
      input_int: "{{test_send}}"

You also have mismatched variable names in your If's condition:

You saved the value to test_return, but retrieved the value of test_result... which is none.

  - variables:
      test_return: "{{ result.value }}"
  - if:
      - condition: template
        value_template: "{{ test_return > 3 }}"

In a way, it is random... All Jinja templates used in YAML need to be surrounded in quotes or preceded by a YAML mulit-line indicator. It doesn't matter if you use single or double quotes. Then... any strings inside the delimiters need to be in quotes. Those can also be either type of quote, but they need to either be the opposite type used around the delimiters or escaped with \. If you use a multi-line format you can use both single and double quotes inside the delimiters with near-wreckless abandon. :upside_down_face:

The [object:object]: null is the result of not properly surrounding templates with quotes in the UI editors. It is an artifact of the YAML being converted to json and back.

FWIW, you can avoid "things just changing" by creating automations directly in the YAML configuration rather than the "Edit in YAML" option of the UI Automation editor... but, you lose the option to edit those automation in the UI editor. There are a number of editor Apps available including File Editor, Blueprint Studio, and Studio Code Server.

The thing to understand is that the statistic work against AI... Home Assistant isn't the only thing using YAML or Jinja and most of the HA-specific examples available come from posts like yours that don't work. Every request for help poisons the data a little bit.

HA's configuration has changed over time, so some portion of the available corpus of data didn't work to begin with and the marked solutions do not work now. The devs have done a lot of work to keep old configs working, but sometimes it just isn't possible.

You can get accurate answers from AI with specific, well defined prompts.... eventually.

Thank you for your help. I have learned from what you showed me. Being a "C" guy I will be making tons of scripts (subroutines).