Bang_bang climate dont work esphome

hello
I have a dallas sensor with a climate bang-band control.
It shows the temperature but does not deactivate the relay.
I don’t know if I have to put something else in the code
This is the code that I have
Thank you

climate:
  - platform: bang_bang
    sensor: $Id_Sensor_01
    id: $Id_Calefaccion_01
    name: $Nombre_Calefaccion_01
    visual:
      min_temperature: 12 °C
      max_temperature: 25 °C
      temperature_step: 0.1 °C
    default_target_temperature_low: 12 °C
    default_target_temperature_high: 22 °C
    heat_action:
      - switch.turn_on: $Id_Salida_Calefaccion_01
    idle_action:
      - switch.turn_off: $Id_Salida_Calefaccion_01

The switch id’s for the heat and idle actions should be your relay ID. You have not shown that part of the code so we can’t check it.

when turning off climate disconnects the relay.
But dont work un Mode heat

switch:
  - platform: gpio
    name: $Nombre_Salida_Calefaccion_01
    id: $Id_Salida_Calefaccion_01
    icon: $Icono_Id_Salida_Calefaccion_01
    restore_mode: ALWAYS_OFF    
    pin:
      mcp23008: mcp23008_hub_5
      number: 0
      mode: OUTPUT
sensor:
  - platform: dallas
    index: 0
    name: $Nombre_Sensor_01
    Id: $Id_Sensor_01
    dallas_id: $Id_Hub_Sensor_01
    unit_of_measurement: "°C"
    accuracy_decimals: 2
    resolution: 12

The Bang-Bang Climate control card in this instance only works in “auto”, “off” or “away” modes. Simply set your temp ranges while it’s on “auto”. The heat will turn on when the temp is too low, and A/C will turn on when the temp is too high.

I literally am doing the exact same thing as you right now.
Note: Make sure you employ “interlock” so during some malfunction, both the A/C and heat relays cannot activate at the same time" if you’re planning on including A/C anyways".

If you’re just using heat only. instead of using ESPHome’s Bang-Bang climate control. Configure the ESPhome as a switch and sensor. Then in HA, create a generic-thermostat, listing the switch, and sensor you created in ESPHome. This will likely give you what your looking for, as it will operate as a normal heating thermostat rather than requiring a " temp range".

It you select Heat or cool, dont test temperature, The problem is in file Bang_bang.cpp in esphome.
In the lines

 void BangBangClimate::compute_state_() {
// dont test temperature It mode different to AUTO
 // if (this->mode != climate::CLIMATE_MODE_AUTO) {
    // in non-auto mode, switch directly to appropriate action
    //  - HEAT mode -> HEATING action
    //  - COOL mode -> COOLING action
    //  - OFF mode -> OFF action (not IDLE!)
    //this->switch_to_action_(static_cast<climate::ClimateAction>(this->mode));
   // return;
  //}

In heat or heat mode, this piece of code did not check the temperature limits as it exited the function.

if these lines are commented it will check if it is below, above or in the range

there is another problem. when you have to turn on and cut. if not in automatic mode

if it is very hot it has to cool in auto or cold mode.
if it is very cold it has to heat in auto or heat mode.
the problem is solved a little further down by modifying these two lines of code

 if ((this->supports_heat_) && ((this->mode == climate::CLIMATE_MODE_AUTO) || (this->mode == climate::CLIMATE_MODE_HEAT)))

 if ((this->supports_cool_) && ((this->mode == climate::CLIMATE_MODE_AUTO) || (this->mode == climate::CLIMATE_MODE_HEAT)))`

With these modifications. It will stop you in auto, heat or cool mode or off.
You just have to select which mode you are going to work at every moment. And the same card is valid for everything.
The only thing that if it is in auto mode is going to be changing from cold to heat or vice versa. Right now according to this the code cuts in heat at the minimum temperature and in cold at the maximum

I am proposing that the code be modified with these variations on github