Bonjour @Coben,
j’ai trouvé la solution du problème de String. Pour compiler avec arduino ca fonctionne String, par contre pour esp-idf ca ne fonctionne pas.
Pour esp-idf faut utiliser to_string a la place de String.
exemple:
sensor:
- platform: uptime
id: uptime_sec
update_interval: 60s
internal: true
text_sensor:
- platform: template
id: format_uptime
name: "M5Stack Atom Echo Uptime"
lambda: |-
int seconds = (id(uptime_sec).state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days ) {
return { (to_string(days) +"d " + to_string(hours) +"h " + to_string(minutes) +"m "+ to_string(seconds) +"s ").c_str() };
} else if ( hours ) {
return { (to_string(hours) +"h " + to_string(minutes) +"m "+ to_string(seconds) +"s ").c_str() };
} else if ( minutes ) {
return { (to_string(minutes) +"m "+ to_string(seconds) +"s ").c_str() };
} else {
return { (to_string(seconds) +"s ").c_str() };
}
icon: mdi:clock-start
update_interval: 60s
entity_category: "diagnostic"