How to recharge an Electric Vehicle for X hours (X perhaps input_number)?

Hi,

Can you help me please with doing this automation (or script?).

Dpending on the need I wish to input an amount in hours, and then start the recharge clicking a button, of course the recharge has to stop after the amount of hours that I input

would be this ok?

the script.turn_off is triggered after duration?


  carica_oraria_nuvola:
    sequence:
      - service: script.turn_on
        target:
          entity_id: script.prism_normal_charge
        data:
          duration: '{{ states("input_number.prism_nuvola_ore_di_carica") }}'
      - service: script.turn_off
        target:
          entity_id: script.prism_normal_charge
    mode: single
    icon: hass:water