How to save data in python_script

Hi!
I have a water heater that I can turn on and off using hass.services.call('homeassistant', 'turn_on', {'entity_id': water_heater_id} in the python_script, right now I’m turning if on when the electricity is cheap and off when it is expensive.

I want to save the time of when I turned on the water heater so after about 2-4 hours when I run the python script again it looks at the starting time and determines if the water heater has been on for enough time.

Since I can’t use any imports in python_script, I’m not really sure how to do it. Right now I’m using the hass.states.get(water_heater_id).last_changed to see when it changed the state last time but since I’m doing a lot more things in the python script I really want to be able to save data and have access to them in some way.

(Also using last_changed shows me a time that is 2 hours to early, but datetime.datetime.now() shows me a time that is correct, if anyone know how to fix this please give some tips!)

Any help would be appreciated!