That's what I thought you meant. And yes, you certainly can do that. The basic form would be something like:
var time_sunrise = DateTime.Now;
var time_sunset = DateTime.Now;
bool Night = false;
// Process all module changes
When.ModuleParameterIsChanging((module, parameter) =>
{
// Set sunrise/sunset times
try
{
//jkUtils
time_sunrise = DateTime.ParseExact(Program.WithName("jkUtils - Solar Altitude").Parameter("jkUtils.SolarAltitude.Morning.Sunrise.Start").Value, "H:mm", System.Globalization.CultureInfo.InvariantCulture);
time_sunset = DateTime.ParseExact(Program.WithName("jkUtils - Solar Altitude").Parameter("jkUtils.SolarAltitude.Evening.Sunset.End").Value, "H:mm", System.Globalization.CultureInfo.InvariantCulture);
//Log("jkUtils evaluated:\ntime_sunrise = " + time_sunrise + "\ntime_sunset = " + time_sunset + "\n\n");
}
catch (Exception e)
{
Log("1-ERROR: could not generate sunrise/sunset times.\n" + e.Message + "\ntime_sunrise = " + time_sunrise + "\ntime_sunset = " + time_sunset + "\n\n");
time_sunrise = DateTime.Now;
time_sunset = DateTime.Now;
}
if (DateTime.Compare(DateTime.Now, time_sunrise)<0 || DateTime.Compare(DateTime.Now, time_sunset)>0)
{
Night = true;
//Log("Night");
}
else
{
Night = false;
//Log("Day");
}
if (module.Is("C1") && parameter.Is("C1") && parameter.Value>0 && Night)
{
Modules.WithAddress("A1,A2").On();
Pause(1);
Modules.WithAddress("A2").Off();
}
//break; don't check any more items
return true;
});
Program.GoBackground();
I didn't compile the code, so it could have a typo but this is the basic structure. I kept the night check for reference. If you want this to happen at all times of the day, simply delete everything related to determining day/night.