Help with using split on return_variable for helper input

Hello, I need some help in using split on a return_variable so that I can use it to provide input for a helper. This is part of a process to force charge my battery to 30% before the higher rate tariff kicks in. In other words it gets me over the high rate tariff hump.
I have a HA script that runs a python script, whose output is the value of the option (in minutes) to force charge the battery. I want to use that output to input to a helper so that I can use that later.

This is my current code in the HA script:

 alias: force_test
sequence:
  - action: pyscript.force_charge
    metadata: {}
    data:
      soc: "{{states('sensor.givtcp_ce2249g687_soc' )}}"
    response_variable: ftime
  - action: input_number.set_value
    data:
      value: "{{ ftime.split('option:')[1] | int }} "
    target:
      entity_id: input_number.force_option
    enabled: true

When I run the script I get an error from the second action:

Error: Error rendering data template: UndefinedError: 'dict object' has no attribute 'split'

The python script has to return a dictionary(value). In my case that is “option: n”, where “n” is an integer. So, for example “option: 15”. It is the “15” part that I want to use as input to the helper, so hence using split.
My understanding is that split only works on strings, so I’m assuming I need to convert the contents of ftime into a string as it is a dictionary item?
Most of the examples that I have looked at already are using states(‘sensor’), which is a string output.
Other examples use the response_variable directly as input to a helper or entity. I can use the contents of ftime ({{ ftime }}) as direct input to the battery to force charge it, but I want to use the helper method for use later.
I know that the split will give me the desired result because I ran it in the Developer-Templates tab.

{% set ftime = "option: 15" %}
{% set option = ftime.split('option:')[1] | int %}
{{option}}

Result: 15 (number)

Obviously ftime is a string here.

So I’m struggling to get the syntax correct for the split function, assuming that it can be done.

The reason why I’m using a python script to calculate the force time and not jinja2 is because I want to get some experience in running python scripts in HA (scripts).

Thanks in advance for any help.

A response_variable is AFAIK always a mapping/dict. It does not have a split() method, only strings do. If you are returning a dict with your value stored under the key “option” simply access the value outright with ftime.option or ftime['option']

If ftime contains a dictionary, simply reference the desired dictionary key (i.e. option) directly.

Example

Define a variable containing a dictionary with three key-value pairs and then report the value of each key.

{% set ftime = 
  { "date": "2025-01-13T08:30:00+00:00",
    "option": 15,
    "rate": 0.08 } %}
{{ ftime.date }}
{{ ftime.option}}
{{ ftime.rate }}

Hi guys, many thanks for your help. It is the simple solutions that are the best and this was one that worked! You can probably guess that I spent a day trying to get this to work and then community member help solved it in a matter of minutes. I how to contribute myself one day, but at the moment I’m still learning. I’m very much old school when it comes to programming (i.e. procedural rather than object oriented).

My input for the helper is now

action: input_number.set_value
data:
  value: "{{ ftime.option | int }} "
target:
  entity_id: input_number.force_option

This has improved my understading of response variables that are dictionary items.
I’m still learning about all this having been using HA for a year or so.