Stories of openHAB conversion, co-existence & augmentation

[quote=“jdr0berts, post:20, topic:186434”]One further thing, I’ve ommitted this section from the example:

if (KitchenMotionZoneArmed.state != ON) {
        logInfo("house-kitchen", "Kitchen-Motion Not Armed, skipping")
        return void
}

As of yesterday, whenever I restart the rule, the motion sensor is set to not armed for some reason - I’ve never knowingly disarmed it.

Cheers
James[/quote]

For this, make sure you have Persistence on, and data being actively collected, for the Item being evaluated.

Without persistence, a “flush” of Item State (because of a Repository Rule/Item change, for example) can leave the value in “UnDef” state, which will cause it to skip.

[quote=“jdr0berts, post:19, topic:186434”]Here’s a simple one, I’ve got the following rule (log statement removed):

rule "Lounge Lights Off"
	when
		Time cron "0 50/1 21 ? * MON-THU,SUN" or
		Time cron "0 0/1 22-23,0-4 ? * MON-THU,SUN" or
		Time cron "0 45/1 22 ? * FRI-SAT" or
		Time cron "0 0/1 23,0-4 ? * FRI-SAT"
	then
	
	if (Network_TV.state == OFF && Network_Amp.state == OFF)
	{
		sendCommand(Light_GF_LoungeLamps, OFF)
	}
end

For some reason, it will run when I’ve saved the rule and it gets reloaded, but the following day, it never restarts and I’m at a loss as to why! (I’ll post to google groups too).[/quote]

Switch to DEBUG Mode logging and see if there are other clues. I ran each expression through a Cron/Quartz eval tool and they appear correct.

That said, since you know when the Amp and TV are off, it may be easier to write it as events against those changing state, and then perform DateTime calcs within the rule. It’ll definitely be less taxing on the system, since it’s only have to Eval each time the TV or Amp changes it’s power-state.

Thanks again - it seems to be working again now, though I can’t work out what changed.

Yes - I’d come to a similar conclusion about reducing the number of repeated cron calls, I’ll still need a timed action for when the TV or Amp aren’t turned off (they’re already off), but the bit I can’t work out is how to setup a fixed time, I assume the best way to do this would be a DateTime item?

DateTime ClockGoodnight  "Goodnight [%1$tH:%1$tM]" <calendar>	{"22:10:00"}

which would allow

if Goodnight.isafternow

Cheers
James

James,
See the code/Rule snippet I posted to your openHAB Group posting. It’s not 100% of what you’re asking for, but it should get you closer.