How to integrate calculations in scripts

Hello,

I want to use the following calculation in one of my scripts, but I have no clue, how to integrate this into the script:

input_number.Waterdepot = min(input_number.Waterdepot + 20, 20)

How can I accomplish that. My question is also targeted towards the general question on how to do calculations in scripts.

Thank you in advance

Amin

The general answer is that it is done through Templating.

So like this:

sequence: # or "action:" if an automation instead of a script
  - service: input_number.set_value
    target: 
      entity_id: input_number.Waterdepot
    data:
      value: "{{ min( states('input_number.Waterdepot')|float(0) + 20, 20 ) }}"