Hola a todos,
Comparto mi configuración para obtener el color TEMPO (opción EDF) en Node Red.
![]()
- El nodo « Timestamp » inicia un flujo a las 00:10
- El nodo function « generateDate » genera la fecha del día en el formato correcto (será el parámetro de la solicitud http:
const date = new Date();
let day = date.getDate();
let month = date.getMonth() + 1;
let year = date.getFullYear();
let currentDate = `${year}-${month}-${day}`;
msg.query = currentDate;
return msg;
- el nodo htt request « Couleur_TEMPO » realiza la solicitud con la API REST de EDF:
https://particulier.edf.fr/services/rest/referentiel/searchTempoStore?dateRelevant={{{query}}}
- el nodo function « convert2msg » extrae la información útil
var tempo=msg.payload.couleurJourJ;
msg.payload=tempo;
msg.topic="couleur_tempo";
if(tempo==="TEMPO_BLEU")
{
node.status({ fill: "blue", shape: "ring", text: tempo });
}
if (tempo === "TEMPO_BLANC") {
node.status({ fill: "white", shape: "ring", text: tempo });
}
if (tempo === "TEMPO_ROUGE") {
node.status({ fill: "red", shape: "ring", text: tempo });
}
return msg;
Al final del flujo, obtenemos un resultado TEMPO_BLEU, TEMPO_BLANC o TEMPO_ROUGE para usarlo como desees.
