Appending return; on a DSL rule line of action

Is it possible to append a return; at the end of a line vs. putting it on the next line? I have a bunch of IF statements on a member of rule that I want it to return after it finds it’s match.

Is this possible below?

            if (triggeringItem.name == 'LivingRoom_Motion_SensorBatteryLevel')			{ LivingRoom_Motion_SensorLastChange.postUpdate(new DateTimeType())  return; }

Lots of lines of code like this:

            if (triggeringItem.name == 'LivingRoom_Motion_SensorBatteryLevel')			{ LivingRoom_Motion_SensorLastChange.postUpdate(new DateTimeType()) }	
			if (triggeringItem.name == 'DiningRoom_Motion_SensorBatteryLevel')			{ DiningRoom_Motion_SensorLastChange.postUpdate(new DateTimeType()) }	
			if (triggeringItem.name == 'Foyer_Motion_SensorBatteryLevel')				{ Foyer_Motion_SensorLastChange.postUpdate(new DateTimeType()) }	
			if (triggeringItem.name == 'BasementHallway_Motion_SensorBatteryLevel')		{ BasementHallway_Motion_SensorLastChange.postUpdate(new DateTimeType()) }	
			if (triggeringItem.name == 'BasementHallway2_Motion_SensorBatteryLevel')	{ BasementHallway2_Motion_SensorLastChange.postUpdate(new DateTimeType()) }
			if (triggeringItem.name == 'PowderRoom_Motion_SensorBatteryLevel')			{ PowderRoom_Motion_SensorLastChange.postUpdate(new DateTimeType()) }		
			if (triggeringItem.name == 'Closet_Motion_SensorBatteryLevel')				{ Closet_Motion_SensorLastChange.postUpdate(new DateTimeType()) }
			if (triggeringItem.name == 'KidsBathroom_Motion_SensorBatteryLevel')		{ KidsBathroom_Motion_SensorLastChange.postUpdate(new DateTimeType()) }			

Best, Jay

I see you are using openHAB 3, if all you want is a timestamp, why not use a DateTime item with a timestamp on update profile? No rule needed or am I missing some use case?

Never heard of “update profile”. I don’t use the GUI for OH 3.x, I’m still using files for items, rules, etc.

Can you show me example code of what your referencing ?

Best, Jay

Very cool and simple! Anyway for me to manage this via an .item definition?

Is it this syntax at the item definition → [profile=“system:timestamp-update”]

Best, Jay

I don’t know sorry, I use the Main UI for everything since moving to v3
Maybe someone else can jump in
Got openHAB running with DSL rules (but in Main UI editor) but my DSL is really rusty, using jRuby now

Use

DateTime Gateway_Sensor_LastSeen "Last seen [%1$tF %1$tR]" { channel="mqtt:topic:pforte:gateway" [profile="timestamp-update"] }

Relevant part is at the end of the channel definition before closing brace.

1 Like

I did notice that I can’t use any other options on the channel as such below, no worries, just wanted to let other folks know this.

, expire="30m, [ignoreStateUpdates= “true”] ← had to remove these parameters

Best, Jay

The GUI isn’t representing the profile timestamp-update on OH 3.2. Am I missing something?

DateTime	DiningRoom_Motion_SensorLastChange   "Last Change [%1$tm.%1$td.%1$tY %1$tH:%1$tM]"		<time>			(gSensorUpdates, ResetExpire)							{ channel="hue:0107:2:64:last_updated" [profile="system:timestamp-update"] }

Best, Jay

The issue of it NOT working is around the format on the item, once I changed it from:

[%1$tm.%1$td.%1$tY %1$tH:%1$tM] → [%1$tF %1$tR]

Everything worked as designed.

Best, Jay

If that’s how you had it in the first place the syntax is wrong. You are missing the close quotes after the "30m.

That should have never worked as written. I’m surprised there were not syntax errors during parsing.

Wow! Great catch and yes it should of thrown an error when it was like that.

Best, Jay