Thanks for the replies.
The code I posted is a copy and paste, I don’t know the code and I’m going to experiment.
My idea was to give a “time” value to orario_accensione_irrigazione, based on 3 options in the interface.
1 - if avvio_irrigazione_alba is selected then the orario_accensione_irrigazione value must be the dawn time + delta_minuti_irrigazione;
2 - if avvio_irrigazione_tramonto is selected then the value of orario_accensione_irrigazione must be the sunset time + delta_minuti_irrigazione;
3 - if avvio_irrigazione_orario_fisso is selected then the value of orario_accensione_irrigazione must be equal to orario_avvio_irrigazione (datetime entity)
In the first post I made a mistake in the third option.