I have tinkered with this for quite a while, and never been able to get it to run. With ST either depreciating or outright breaking the modes that used to be associated with it, Ive lost a lot of processing based on what mode ST was in, i.e. Away, Home, Night etc.
Essentially I have modified my routines to be centered around the variable at the beginning and this routine to set the variables, however, it never runs, and I have tried multiple different iterations.
Not sure where to go with this one, but the logic is fairly simple.