How to save a value at the start of an automation and then print it later?

Hi everyone, i have an automation that stops HVAC when power consumption is too high and then sends me a notification.
I set the notification as the last thing to be done to be sure all the other were completed, but i get into the situation in which the power reading that is printed into the notification is “too late”, so i would need to read it, save it somewhere, turn HVAC off and then send the notification with the correct value… is it possible?

Post the automation.

The automation fires this script

accensione_pdc_soggiorno:
  sequence:
    # Accendo PDC
    - service: climate.turn_on
      entity_id: climate.daikin_soggiorno
    - delay: '00:00:05'
    # Imposto temperatura a 20°C
    - service: climate.set_temperature
      target:
        entity_id: climate.daikin_soggiorno
      data:
        temperature: '20'
        hvac_mode: 'heat'
    - delay: '00:00:15'
    # Imposto in modalità Eco
    - service: climate.set_preset_mode
      target:
        entity_id: climate.daikin_soggiorno
      data:
        preset_mode: "Eco"
    - delay: '00:00:05'
    # Ventola in modalità Auto
    - service: climate.set_fan_mode
      target:
        entity_id: climate.daikin_soggiorno
      data:
        fan_mode: "Auto"
    # Avvio timer
    - service: timer.start
      target:
        entity_id: timer.attesa_avvio_pdc
    - delay: '00:00:05'
    # Invio notifica
    - service: notify.christian
      data_template:
        title: '*PDC Soggiorno*'
        message: >
            Accesa in autoconsumo
            
            Lettura Contatore: {{states('sensor.lettura_contatore_filtrata')}} W,
            Temperatura Attuale: {{states('sensor.temperatura_pt')}}°C

As you can see the reading in W i get is affected by the HVAC already turned on

This script is called when “power consumption is too high”. That means the automation that calls this script is triggered when power exceeds a threshold value. Pass that power value as a variable to the script.

Reference: Passing variables to scripts