Calling a script from a script

I have the following scripts.yaml:

up_two_degrees:
  alias: Up two degrees
  variables:
    front_setpoint: '{{ state_attr(''climate.touchscreen_comfort_control_thermostat'',''temperature'')
      }}'
  sequence:
    if:
    - alias: If mode is heating
      condition: state
      entity_id: climate.touchscreen_comfort_control_thermostat
      state: heat
    then:
    - alias: increase set point
      action: climate.set_temperature
      target:
        entity_id: climate.touchscreen_comfort_control_thermostat
      data:
        temperature: '{{ front_setpoint + {{ incr_amt }} | float }}'
    else:
      action: climate.set_temperature
      target:
        entity_id: climate.touchscreen_comfort_control_thermostat
      data:
        temperature: '{{ front_setpoint - {{ incr_amt }} | float }}'
  description: up 2 degrees
  icon: mdi:air-conditioner
test_calling_script:
  alias: test calling script
  sequence:
  - action: script.up_two_degrees
    data: 
      incr_amt: 3
  description: 'Parameterized up temp'

But when I run test_calling_script I get:

Executed: November 16, 2024 at 2:15:42 PM
Error: Action script.up_two_degrees not found
Result:
params:
  domain: script
  service: up_two_degrees
  service_data:
    incr_amt: 3
  target: {}
running_script: true

Do I need to do something different to get the script recognized?

Hello Dan Hinsley,

It can’t call itself I don’t think. Honestly never tried it but this says that’s what’s happening.
It could create a feedback loop that could literally crash the world if you think about it…
Oops…

It’s not. The test script is calling the up 2 degrees script.

@danhi did you reload or restart after creating the script?

Are there other errors in your log indicating why the script was not loaded?

2 Likes

I reloaded the yaml, and there aren’t any other errors inthe log.

On a separate note, is there any way to log things to the log from inside a script?

Why did you start a new thread for what is essentially a continuation of yesterday’s thread?

There are multiple nested templates in the post above… this is not valid syntax. Just use the variables directly.

Also, it is best to always include a default value for filters like float or int.

"{{ front_setpoint + incr_amt | float(0) }}"

1 Like

And that would definitely have produced an error in the log. I know because I did it by accident myself this morning.

Not sure you really read the first post. my problem is trying to call a script from within a script, and it saying the script wasn’t found. Did you see that?

Yes. The script wasn’t loaded because of the invalid syntax.

2 Likes

Sorry, still working my way through jinja2 syntax. That worked like a champ. Thanks for the help.