Besoin d'aide sur ESPHOME code esp8266

Bonjour tous, après avoir vu plein de tutos j’ai réussi à apprivoiser esphome, mais là je bloque sur un code que j’ai tourné dans tout les sens et rien y fait, je m’explique, j’essai de récupérer les données de mon onduleur via un esp8266 D1 mini pro, j’ai récupéré et modifié 2 fichiers pour l’adapter à mon esp don voici le premier code

esphome:
  name: raw_serial_voltronic
  platform: ESP8266
  board: d1_mini_pro
  includes:
    - raw_serial_voltronic_custom_sensor.h
    
# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "ebW0GfR+CLF0dEfvwg="

ota:
  password: "86af116c248"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Essspot"
    password: "x1kt"

captive_portal:

sensor:
  - platform: custom
    id: VOLTRONIC_id
    lambda: |-
     auto VOLTRONIC = new VOLTRONICCustomSensor();
     App.register_component(VOLTRONIC);
     return {VOLTRONIC->VOLTRONIC_raw_string};
     
    sensors:  
    - name: "VOLTRONIC_raw_string"

quand je le valide c’est ok puis j’ai un deuxième code qui va avec celui du dessus dont voici:

#include "esphome.h"


#define RXD0 3
#define TXD0 1


class VOLTRONICCustomSensor : public PollingComponent, public Sensor 
{
 public:
	Sensor *VOLTRONIC_raw_string = new Sensor();
	
	
	unsigned long lastMillis=0;
    long previousMillis = 0;
    long interval = 5000;
    double temp;
	
	VOLTRONICCustomSensor() : PollingComponent(3000) {}
	
	void setup() override 
    {
     //Serial2.begin(2400, SERIAL_8N1, RXD2, TXD2);
	 Serial1.begin(2400, SERIAL_8N1, RXD0 03, TXD0 01);
    }


 void removeNonAscii(char line[],char modifiedline[])
 {
     int i=-1;
     int j=-1;
     while(line[++i]!='\0'){
        if(!(line[i]>=0&&line[i]<=127))continue;
        else modifiedline[++j]=line[i];
     }
     modifiedline[++j]='\0';
 }

	
	void update() override 
    {
		String CMD = "\x51\x50\x49\x47\x53\xB7\xA9\x0D"; // QPIGS + CRC + CR  (EVO1, EVO2)
		//String CMD = "\x51\x50\x49\x47\x53\x0D"; // QPIGS + CR (MPPSOLAR)
        //String CMD = "\x51\x50\x49\x47\x53\x0D\x0A";
        unsigned long currentMillis = millis();
		int n;
		if (currentMillis - previousMillis > interval) 
	    {  	
		   previousMillis = currentMillis;    
		   String raw_string;
		   Serial1.print(CMD); 
		   raw_string = Serial1.readStringUntil('\r');
		   n = raw_string.length();
		   
		   char raw_array[n + 1];
		   char modifiedline[n + 1];
		   strcpy(raw_array, raw_string.c_str());
		   strcpy(modifiedline, raw_string.c_str());
		   removeNonAscii(raw_array,modifiedline);
		   ESP_LOGD("customTest", "%s" , modifiedline);
	    }		
  }	
};

et lorsque je veux l’installer il me donne cette erreur :

Compiling .pioenvs/raw_serial_voltronic/src/main.cpp.o
In file included from src/main.cpp:26:
src/raw_serial_voltronic_custom_sensor.h: In member function 'virtual void VOLTRONICCustomSensor::setup()':
src/raw_serial_voltronic_custom_sensor.h:24:40: error: expected ')' before numeric constant
   24 |   Serial1.begin(2400, SERIAL_8N1, RXD0 03, TXD0 01);
      |                ~                       ^~
src/raw_serial_voltronic_custom_sensor.h:24:49: error: expected ')' before numeric constant
   24 |   Serial1.begin(2400, SERIAL_8N1, RXD0 03, TXD0 01);
      |                ~                                ^~
src/raw_serial_voltronic_custom_sensor.h:4:14: error: invalid conversion from 'int' to 'SerialMode' [-fpermissive]
    4 | #define RXD0 3
      |              ^
      |              |
      |              int
src/raw_serial_voltronic_custom_sensor.h:24:35: note: in expansion of macro 'RXD0'
   24 |   Serial1.begin(2400, SERIAL_8N1, RXD0 03, TXD0 01);
      |                                   ^~~~
In file included from /data/cache/platformio/packages/framework-arduinoespressif8266/cores/esp8266/Arduino.h:288,
                 from .piolibdeps/raw_serial_voltronic/ESPAsyncWebServer-esphome/src/ESPAsyncWebServer.h:24,
                 from src/esphome/components/web_server_base/web_server_base.h:10,
                 from src/esphome/components/captive_portal/captive_portal.h:10,
                 from src/esphome.h:16,
                 from src/main.cpp:3:
/data/cache/platformio/packages/framework-arduinoespressif8266/cores/esp8266/HardwareSerial.h:87:68: note:   initializing argument 3 of 'void HardwareSerial::begin(long unsigned int, SerialConfig, SerialMode, uint8_t)'
   87 |     void begin(unsigned long baud, SerialConfig config, SerialMode mode, uint8_t tx_pin)
      |                                                         ~~~~~~~~~~~^~~~
*** [.pioenvs/raw_serial_voltronic/src/main.cpp.o] Error 1
========================= [FAILED] Took 15.39 seconds =========================

apparemment cela vient du rx et tx j’ai beau enlever dans le serial le 03 et le 01 toujours le même problème si je masque la ligne serial1.begin il arrive à l’installer mais bon je pense que si cette ligne existe il va en avoir besoin.
Merci d’avance pour votre aide

Bonjour @Pipiche_p
J’imagine que si tu fais tout ça c’est que ton onduleur n’est pas capable de remonter via USB & Network UPS Tools les données directement dans HA ?

Bob

oui tout à fait un onduleur qui cout un bras et il ne remonte rien sauf sur une appli mais bof et il n’y a pas tout d’ailleurs beaucoup d’onduleur son comme ça il utilise un pc connecté en permanence en usb et utilise un logiciel comme watchpower et c’est en voyant cette vidéo que j’ai voulu faire pareil