New problem with scheduling

in “edit event” in the scheduling, if the event is set to “turn on” and the load is already on, the load is turned off and on “turn off” if the load is already turned off. account of the state of the load that he also knows.
Here is the code:
CAYENNE_IN(1)
{
digitalWrite(INGRESSO1, HIGH);
}
CAYENNE_IN(2) //da Cayenne per comandare il pulsante su INGRESSO2
{
digitalWrite(INGRESSO2, HIGH);

CAYENNE_IN(3) //da Cayenne per comandare il pulsante su INGRESSO2
{
digitalWrite(INGRESSO3, HIGH);

}

CAYENNE_OUT(1) //virtuale per lo stato dei relè o lo stato della scheda
{
Cayenne.virtualWrite(1, Pulsante1);
}

CAYENNE_OUT(2) //usata quando l’ingresso è usato come pulsante in Tele2
{
Cayenne.virtualWrite(2, Pulsante2);
}

CAYENNE_OUT(3) //usata quando l’ingresso è usato come pulsante in Tele3
{
Cayenne.virtualWrite(3, Pulsante3);
}

i did not understand what you are saying.
Also post the entire code and not the a small part of it.