Firepace control with ESP

Hi!

I have a fireplace and I installed a thermocouple max6675 (inside) with an ESP32.

This thermocouple gives me the fireplace internal temperature and I would like to create a template that shows me this in a entity card:

Temp between 0° to 50° --> Fireplace OFF
Temp between 50° to 150° --> LOW TEMP, CECK THE FLAME
Temp between 150° to 300° --> Fireplace is OK

How can i get this?
Many thanks in advance

Do you want to template this in esphome, or home assistant?

If home assistant, what is the entity id of the temperature sensor?

If esphome, show your config.

I prefer in ESPHome…this is my config:

esphome:
  name: esp32_01
  platform: ESP32
  board: esp-wrover-kit
  on_loop:
    then:
      - lambda: delay(5);

wifi:
  ssid: "name"
  password: "pass"
  power_save_mode: none
  fast_connect: true
  manual_ip:
    static_ip: 192.168.1.30
    gateway: 192.168.1.1
    subnet: 255.255.255.0

logger:

api:

ota:

spi:
  miso_pin: GPIO12
  clk_pin: GPIO14

sensor:
  - platform: max6675
    name: "Temperatura Stufa"
    cs_pin: GPIO15
    update_interval: 10s
    
  - platform: wifi_signal
    name: "ESP32_01_WiFi"
    update_interval: 60s
    
  - platform: uptime
    name: "Uptime"
    id: uptime_s
    update_interval: 60s
    internal: true

Probably some template sensor in esphome. I’m not up on lambda notation so I’m at a loss on the code.

text_sensor:
  - platform: template
    name: "Fire State"
    lambda: |-
#some if/then code
      return {"Off"};
# else if temp is over 50
      return {"Unknown - Check the flame"}
# else
      return {"OK"}
    update_interval: 15s

I don’t think I understand how to do it :sweat_smile:

sensor:
  - platform: max6675
    name: "Temperatura Stufa"
    cs_pin: GPIO15
    update_interval: 10s
    id: fire_temp

text_sensor:

  - platform: template
    name: "Stato Fuoco"
    lambda: |-
if (id(fire_temp).state == under 50)
      return {"Off"};
# else if temp is over 50
      return {"Unknown - Check the flame"}
# else
      return {"OK"}
    update_interval: 

< 50

not under 50

Many thanks!
This is the final configuration (tonight I’ll try if it works well)

text_sensor:
#STATO FUOCO STUFA
  - platform: template
    name: "Stato Fuoco"
    lambda: |-
     if (id(fire_temp).state  < 50)
      return {"SPENTO"}
     ;else if (id(fire_temp).state  > 50)
      return {"BASSO - controllare!"}
     ;else (id(fire_temp).state  > 140)
      ;return {"NORMALE"};
    update_interval: 15s

That’s never going to have the state " Normal". As the > 50 test will always be true before it gets to > 140. Try this

    lambda: |-
      if (id(fire_temp).state  > 140);
        return {"NORMALE"};
      else if (id(fire_temp).state > 50);
        return {"BASSO - controllare!"};
      else;
        return {"SPENTO"};
    id: fire_state

Also rather than polling the sensor every 15 seconds, update it when the temperature changes:

sensor:
  - platform: max6675
    name: "Temperatura Stufa"
    cs_pin: GPIO15
    update_interval: 10s
    id: fire_temp
    on_value:
      then:
        - component.update: fire_state

Ok thanks tom, I will try this.

Can I set the different icon color for the 3 states?
For eample: red icon for state NORMALE, black icon for state SPENTO

Immagine11

No, I don’t think you can do that. You’d have to use card mod in home assistant.

Ok!

Last question, with this sensor, can I display degrees without decimals?
I would like to see 1 degree steps without decimals (now is 29.5 etc)


sensor:
  - platform: max6675
    name: "Temperatura Stufa"
    cs_pin: GPIO15
    update_interval: 10s

accuracy_decimals

Hi!
In ESPHome I created this template, which it tells me if the fire is ON (“ACCESA”) or OFF (“SPENTA”).

  - platform: template
    name: "Stato Stufa"
    icon: "mdi:fire"
    lambda: |-
     if (id(fire_temp).state  > 50)
      return {"ACCESA"}
     ;else
      return {"SPENTA"};
    update_interval: 15s

Is it possible to display a time as an output value?
For example:

....
return {"ACCESA alle 18:00"}
....
return {"SPENTA alle 23:00"}

Thanks