How to programmatically set PID to OFF/ON?

Hello I have the following pid regulator:

climate:
  - platform: pid
    name: "Termostat Sypialnia PID"
    id: termostat_pid
    sensor: syp_temp
    default_target_temperature: 23.0
    heat_output: pid_output
    control_parameters:
      # Testy:
      # 1. Oscylacje (częste wł/wył kotła, skoki temp) -> zmniejsz KP
      # 2. Niedogrzanie (cel nieosiągnięty o >0.5C) -> zwiększ KI (np. o 0.001)
      # 3. Histereza (40/42C + 2min) stabilizuje układ, PID może być nieco agresywniejszy
      kp: 0.3
      ki: 0.001
      kd: 0.0
    deadband_parameters:
      threshold_high: 0.1
      threshold_low: 0.1
      kp_multiplier: 0.0
      ki_multiplier: 0.0
      deadband_output_averaging_samples: 15
    on_control:
      then:
        - lambda: kc::piec::process_pid_logic(id(termostat_pid).get_output_value());

I want programmatically set it to off on, like in homeassistant I click. However, I am not able to set it. I am trying with the following code,and same with climate::CLIMATE_MODE_OFF:

if (id(termostat_pid).mode != climate::CLIMATE_MODE_HEAT) { 
   id(termostat_pid).make_call().set_mode(climate::CLIMATE_MODE_HEAT).perform();
}

Is this the correct method and syntax to turn such PID on/off? ESP seems to reset after performing this, so I am not sure. Thank you.

Yes it is. There was an issue with other parts of my code. Sorry for the noise and thanks.