Stopping / Delaying a timer

Take a look at the new Ephemeris capability. It’s not well documented yet and support for JSR223 Rules isn’t implemented yet, but it’s purpose is to mark the day type. See Ephemeris binding? for details. You can mark weekend days in PaperUI (under Configuration -> System) and other types of days in an ephemeris.cfg file under $OH_CONF/services.

I’m building a reusable Python version of Time of Day and plan on incorporating this to have different times for different types of days.

Ok, granted there are people with a strict routine and there might be more to accept a suboptimum solution.
Maybe that was a bit too subjective of an answer, but I HATE being told or guessed by machines what is my current intention. Quite a number of those keep trying (such as those annoying online advertizers), and they all fail regularly.

Point is, the simple manual solution turned out to by far be the best (at least for me who doesn’t want to be patronized (infantilized?) by some computer even if it was me to knowingly write that code).
And pretty effortless.

Wow, you have been busy…just seen the 9 parter for python. I’ll take a leisurely read through it all and see if it gets the creative mind flowing.

Love the concept of converting, just need to find some time.

Hi all,

Just to add an update to this for posterity:

I had a little play with the rule after experiencing the routine a few times in real life and realised that if we are up after midnight when the rule is called we are watching the end of a film / TV program so I could use the fact that we simply turned the TV back on to cancel the rule…

So, I incorporated that back in, it’s a simple loop;

  • Routine runs at midnight, sends a message to the TV to inform us it’s about to run the routine
  • After 5 seconds of the message it turns the TV off.
  • It then sets a timer for 10 seconds
  • If the TV is still OFF, it continues with the routine, turning on the camera and turning down the thermostat
  • If the TV is back ON it sends a message to the TV confirming the routine has been delayed
  • It then resets the aEndofDay item switch back to OFF
  • Sets a timer for 30 minutes and then turns the aEndofDay item to ON
  • The whole process starts again
rule "End of Day routine (Alexa / vTimeOfDay / Switch - Should Only run if vPresent = ON)"
when
	Item aEndofDay changed 
then
    if(aEndofDay.state == ON)
        {
        logInfo(logName, "End of Day routine - started")
        TV_LG_Toast.sendCommand("End of Day routine started - turn TV back on to delay routine")
        createTimer(now.plusSeconds(5),
            [
            TV_LG_Power.sendCommand(OFF)
                createTimer(now.plusSeconds(10),
                [
                    if(TV_LG_Power.state == OFF)
                    {
                        ThermostatSetPoint.sendCommand(16.5)
                        createTimer(now.plusMinutes(5),
                        [
		                    CameraOn.sendCommand(ON)
		                    logInfo(logName, "End of Day Routine ON - Cameras ON")
                        ])
                    }
                    else
                    {
                        TV_LG_Toast.sendCommand("End of Day routine delayed for 30 minutes")
                        aEndofDay.sendCommand(OFF)
                        createTimer(now.plusMinutes(30),
                        [
		                    aEndofDay.sendCommand(ON)
                        ])
                    }
                ])
            ])
        }
	else
        {
        logInfo(logName, "End of Day routine - ended")
        CameraOn.sendCommand(OFF)
		logInfo(logName, "End of Day Routine OFF - Cameras OFF")
        }
end