Reading data from the furnace control via UART and converting the data into different sensors

Hello.
I was looking for a solution, but I did not find it, and I’m not good at these blocks. - I don’t understand everything yet.
I am asking for help in converting the data I receive from the furnace controller via the UART bus
I found something in one of the posts, but it doesn’t fit.

I just want to read the data

I want to extract the data from the data:
Temperature:

  • Oven temperature
  • boiler temperature
  • return temperature, etc.
  • Oxygen sensor

Binary sensor:

  • lid open sensor
  • Carbon feeder sensor
  • Oven alarm

esp32 w jaml :

esphome:
  includes:
     - uart_read_text_sensor.h   

  name: kotownia-termometry
esp32:
  board: esp32dev
  framework:
    type: arduino

(.....)

uart:
  id: uart_bus
  tx_pin: 17
  rx_pin: 16
  baud_rate: 57600
  
  debug:
    direction: BOTH
    dummy_receiver: false
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_string(direction, bytes);
text_sensor:
- platform: custom
  lambda: |-
    auto my_custom_sensor = new UartReadLineSensor(id(uart_bus));
    App.register_component(my_custom_sensor);
    return {my_custom_sensor->playtime, my_custom_sensor->switchhits, my_custom_sensor->switchhits1, my_custom_sensor->switchhits2, my_custom_sensor->switchhits3, my_custom_sensor->score};
  text_sensors:
  - name: "playtime"
  - name: "switchhits"
  - name: "switchhits1"
  - name: "switchhits2"
  - name: "switchhits3"
  - name: "score" 
 

a w pliku uart_read_text_sensor.h :

#include "esphome.h"

class UartReadLineSensor : public Component, public UARTDevice, public TextSensor {
 public:
  TextSensor *playtime = new TextSensor();
  TextSensor *switchhits = new TextSensor();
  TextSensor *switchhits1 = new TextSensor();
  TextSensor *switchhits2 = new TextSensor();
  TextSensor *switchhits3 = new TextSensor();
  TextSensor *score = new TextSensor();
  UartReadLineSensor(UARTComponent *parent) : UARTDevice(parent) {}

  void setup() override {
    // nothing to do here
  }

  int readline(int readch, char *buffer, int len)
  {
    static int pos = 0;
    int rpos;

    if (readch > 0) {
      switch (readch) {
        case '\n': // Ignore new-lines
          break;
        case '\r': // Return on CR
          rpos = pos;
          pos = 0;  // Reset position index ready for next time
          return rpos;
        default:
          if (pos < len-1) {
            buffer[pos++] = readch;
            buffer[pos] = 0;
          }
      }
    }
    // No end of line has been found, so return -1.
    return -1;
  }

  void loop() override {
    const int max_line_length = 180;
    static char buffer[max_line_length];
    while (available()) {
      if(readline(read(), buffer, max_line_length) > 0) {
        playtime->publish_state(strtok(buffer, ":"));
        switchhits->publish_state(strtok(NULL, ":"));
        switchhits1->publish_state(strtok(NULL, ":"));
        switchhits2->publish_state(strtok(NULL, ":"));
        switchhits3->publish_state(strtok(NULL, ":"));
        score->publish_state(strtok(NULL, ":"));
      }
    }
  }
};

what esp now displays:

some data for example from uart:


{"DevId":"TASI7 S8","DevPin":"TASI7 OKN","Token":"GZVQDQ","FrameType":"SkzpData","TimeStamp":"20-42-31","BoilerTempAct":"5627","AN01":"1310","CH1ReturnTempAct":"3853","CH1ReturnTe

some data for example from uart: for example:
,“BoilerTempAct”:“5627”, → is the boiler temperature : 56,27 Celsius
,“ExhaustTempAct”:“16222”, → exhaust gas temperature 162,22 celsius

“CH1ReturnProtAct”:“On”, → sensor binary ON
“DHWPriority”:“Off”, → sensor binary Off

I haven’t recognized all the data yet, but if I have the above data, I think I will be able to extend it.

I am asking for help, I need a control to know if everything is working properly or if someone has turned off the stove or changed the settings.

The stove is in a different building.

I am still looking for a way to make it served nicer and to have temperature sensors, not just text ones.

maybe someone will help?

#include "esphome.h"

class UartReadLineSensor : public Component, public UARTDevice, public TextSensor {

   // class Piecyk : public PollingComponent, public UARTDevice {
 public:
  TextSensor *playtime = new TextSensor();
  TextSensor *temp_pieca = new TextSensor();
  TextSensor *do_pieca = new TextSensor();
  TextSensor *switchhits2 = new TextSensor();
  TextSensor *spaliny = new TextSensor();
  TextSensor *paliwomax = new TextSensor();
  TextSensor *paliwo = new TextSensor();
  TextSensor *switchhits3 = new TextSensor();
  TextSensor *score = new TextSensor();
  UartReadLineSensor(UARTComponent *parent) : UARTDevice(parent) {}

 //Piecyk(UARTComponent *parent) : PollingComponent(1000), UARTDevice(parent) {}

  void setup() override {
    // nothing to do here
  }
  int readline(int readch, char *buffer, int len)
  {
    static int pos = 0;
    int rpos;

    if (readch > 0) {
      switch (readch) {
        case '\n': // Ignore new-lines
          break;
        case '\r': // Return on CR
          rpos = pos;
          pos = 0;  // Reset position index ready for next time
          return rpos;
        default:
          if (pos < len-1) {
            buffer[pos++] = readch;
            buffer[pos] = 0;
          }
      }
    }
    // No end of line has been found, so return -1.
    return -1;
  }

  void loop() override {
  	
    const int max_line_length = 1680;
    static char buffer[max_line_length];
    while (available()) {
      if(readline(read(), buffer, max_line_length) > 0) {
 
         //11111111111111111111111111111111   
         playtime->publish_state(strtok(buffer, ":"));  
         char* word =(strtok(NULL, ":"));
          word =(strtok(NULL, ":"));  
          word =(strtok(NULL, ":"));  
          word =(strtok(NULL, ":")); 
		  word =(strtok(NULL, ":"));  
         
        temp_pieca->publish_state(strtok(NULL, ","));  // temperatura boiler
         word =(strtok(NULL, ":"));  
         word =(strtok(NULL, ":")); 
    //    switchhits2->publish_state(strtok(NULL, ","));    
    
        do_pieca->publish_state(strtok(NULL, ","));   // tempertura aktualna
         word =(strtok(NULL, ":")); 
         word =(strtok(NULL, ":"));  
         word =(strtok(NULL, ":"));  
         word =(strtok(NULL, ":")); 
         word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
	//	playtime->publish_state(strtok(NULL, ":")); 
	
        switchhits2->publish_state(strtok(NULL, ","));
         word =(strtok(NULL, ":"));
         word =(strtok(NULL, ":"));
         word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		 word =(strtok(NULL, ":"));
		  word =(strtok(NULL, ":"));
		  word =(strtok(NULL, ":"));
		  word =(strtok(NULL, ":"));
		  word =(strtok(NULL, ":"));
       	  word =(strtok(NULL, ":"));
        
        spaliny->publish_state(strtok(NULL, ","));  // spaliny
        
          word =(strtok(NULL, ":"));
          word =(strtok(NULL, ":"));
          word =(strtok(NULL, ":"));
          word =(strtok(NULL, ":"));
          word =(strtok(NULL, ":"));
          word =(strtok(NULL, ":"));
          word =(strtok(NULL, ":"));
          word = (strtok(NULL, ":"));
        paliwomax->publish_state(strtok(NULL, ","));  // poziom paliwa  max
        paliwo->publish_state(strtok(NULL, ","));  // poziom paliwa
           
        switchhits3->publish_state(strtok(NULL, ","));  // poziom paliwa?
        score->publish_state(strtok(NULL, ":"));
       
      }

    }
    
  }
};

Hi,

The record I just opened with reference to a different problem. Maybe my code will be useful as an example.

Disconnects WiFi Every 3 Hours or Less While Reading or Writing UART Data

And…

“ExhaustTempAct”:“16222” this data int value divide to 100.
Sample;
16222/100=162,22 or 5627/100=56,27

Read data parse or find title of data for;
https://github.com/clockbrain/xantrex
https://github.com/clockbrain/xantrex/blob/88621569f94ebce58764f2874951d4034b49e308/xantrex.h

https://github.com/buyukgaga/esphome-get-ups-rs232-data

Home Assistant Sensor types;
Binary Sensor
Sensor