Controlling air con power To use solar energy only

I have created a new input number
Auto AC Master Trim

which is updated every minute in the "Auto AC Control" automation

alias: Update cumulative trim
action: input_number.set_value
metadata: {}
target:
  entity_id: input_number.auto_ac_master_trim
data:
  value: >-
    {% set current_trim = states('input_number.auto_ac_master_trim') | float(0)
    %}

    {% set surplus = states('sensor.surplus_solar') | float(0) %}


    {% set step = 0.5 if surplus > 1200 else
                  0.1 if surplus > 500 else
                  0.0 if surplus > 100 else
                  -0.1 if surplus > -200 else
                  -0.3 if surplus > -600 else
                  -1.0 %}

    {# Clamping output #}

    {% set target_trim = current_trim + step %}

    {{ [[target_trim, -2] | max, 3] | min | round(2) }}
continue_on_error: true


this will replace the crude helper Auto AC Consumption Offset

now there are two bits of code changing temperature adjustment I will have to test a bit to see how it works