Is there some way to have a global function in HG?
What I'm trying to achieve is to get the correct light values depending on the time of day, currently I'm doing this as follows:
// standard theme is Relax
var command = ".1997,.8346,.8";
var solarAltitude = Modules.WithName("jkUtils - Solar Altitude").Get();
// Get Evening GoldenHour start
DateTime EveningGoldenHourStart = DateTime.Parse(solarAltitude.Parameter("jkUtils.SolarAltitude.Evening.GoldenHour.Start").Value);
DateTime EveningSunsetEnd = DateTime.Parse(solarAltitude.Parameter("jkUtils.SolarAltitude.Evening.Sunset.End").Value);
if (DateTime.Now.Hour == 6)
{
// Energize theme
command = "0.52635,.9133,.8";
}
else if (DateTime.Now.Hour >= 7 && DateTime.Now < EveningGoldenHourStart)
{
// Concentrate theme
command = "0.51649,.1732,.8";
}
else if (DateTime.Now >= EveningGoldenHourStart && DateTime.Now < EveningSunsetEnd)
{
// Reading theme
command = ".23393,.4763,.8";
}
Modules.WithName("Dining table light").Command("Control.ColorHsb").Set(command);
The problem is that I'm using this code for every single light (they're linked to seperate Z-Wave wall switches), what I'd prefer is to move the 'Get correct theme' code to a central location and just use something like this:
var command = HomeGenie.GetCurrentLightTheme();
Modules.WithName("Dining table light").Command("Control.ColorHsb").Set(command);