Hello
here is my sketch is clean and functional.
the values sent with the bodyboard work well.
one step finished
now i tried with the examples of the schedules you gave me, and well i'm lost
I recapitulate the need.
MyC sends at a certain time or day, the value of on and off
for the time slots of the relay on the clock.
integer values without comma,
example : 1630 for 16hours 30minutes.
the sketch of MyS manages with
Thanks for your help.
many stars in the sky for you
the recopies and other info
the parts of the sketch
...
// ------ objet - MyS numero du Node ------
#define CHILD_ID_2 2 //On time
#define CHILD_ID_4 4 //Off time
...
//----------- test commande Relay ----------------
int ledPin = 7; // test Assigned Pin for Relay Module
int requestOn;
int requestOff;
//----- MyS ------
MyMessage dimmerMsg(CHILD_ID_2, V_PERCENTAGE); //hour walk
MyMessage dimmerMsg4(CHILD_ID_4, V_PERCENTAGE); //stop time
bool info; // for your information GW sur MyC
//---------------- SETUP ----------------------------
void setup() {
...
//---- test set point -----
send(dimmerMsg.set(info));
send(dimmerMsg4.set(info));
}
//--------------MySensors-------------
void presentation() {
sendSketchInfo("Clock", "2.0");
present( CHILD_ID_2, S_DIMMER, "Debut" ); // Register the LED Dimmable Light with the gateway
present( CHILD_ID_4, S_DIMMER, "Fin" );
}
//------------------ LOOP -----------------------
void loop() {
....
//----- commande Relay dans une plage horaire -----
timecurrent = hour()*100 + minute(); // Conversion des heure en minutes
//----- reception set time On Off ------------
int requestedLevel = atoi( message.data ); //RΓ©cupΓ©rer la valeur Γ partir du message
//----- limite valeur entrant dans la plage valide 0 to 2400 ------
requestedLevel = requestedLevel > 2400 ? 2400 : requestedLevel;
requestedLevel = requestedLevel < 0 ? 0 : requestedLevel;
if((requestedLevel % 100) > 59) { requestedLevel = 00; }
//----- trie des messages -------
switch (message.sensor) {
case 2: // message 1
requestOn = requestedLevel;
break;
case 4: // message 2
requestOff = requestedLevel;
break;
}
//----- commande Relay dans une plage horaire -----
if (timecurrent >= requestOn && timecurrent <= requestOff) {
digitalWrite(ledPin, HIGH); }
else {
digitalWrite(ledPin, LOW); }
//----- return value for MyC -------
send( dimmerMsg.set(requestOn) );
send( dimmerMsg4.set(requestOff) );
}
}