Rule not working anymore

Hi, following rules are not working anymore. I think it is not working since update to 2.0 or 2.1 snapshot.

rule "Xiaomi Temp-Sensoren State Changed"
when
		Item gXiaomiTemp received update // NOTE: the rule will trigger multiple times per event
then
		Thread::sleep(500) // give persistence time to catch up
		val haveHistory = gXiaomiTemp.members.filter[c|c.lastUpdate("mapdb") != null]
		val mostRecent = haveHistory.sortBy[lastUpdate("mapdb")].last
		if(mostRecent == null) logError("XiaomiTemp", "Failed to find most recent")
		else if(mostRecent.state != null) {
				logInfo("RULES", "Xiaomi Temp Group - most recent state: " + mostRecent.state)
				val dt = gXiaomiZeit.members.filter[dt|dt.name == mostRecent.name+"_last_connection"].head
				logInfo("RULES", "Xiaomi Temp Group - most recent name: " + mostRecent.name + " dt " + dt)
				if(dt == null) logError("XiaomiTemp", "null Failed to find " + mostRecent.name+"_last_connection")
				else if(dt == NULL) logError("XiaomiTemp", "NULL Failed to find " + mostRecent.name+"_last_connection")
				else dt.postUpdate(new DateTimeType)
		}
//		else {
//				logInfo("XiaomiTemp", mostRecent.name + " Xiaomi Temp")
//		}
// 
end

rule "Xiaomi Temp 1 time since"
when
		Time cron "0 * * * * ?"
then
		// logInfo("RULES", "Xiaomi Temp 1 - new minute - state: " + Xiaomi_Temp_1_last_connection.state as DateTimeType)
		var Number lastthingy1 = (Xiaomi_Temp_1_last_connection.state as DateTimeType).calendar.timeInMillis
		// logInfo("RULES", "Xiaomi Temp 1 - new minute - state: " + lastthingy1)
		var Number myminutes1 = ((now.millis - lastthingy1) / 60000)
		// logInfo("RULES", "Xiaomi Temp 1 - new minute - state: " + now.millis)
		// logInfo("RULES", "Xiaomi Temp 1 - new minute - state: " + myminutes1)
		Xiaomi_Temp_1_time_since.postUpdate(myminutes1)
end

I don´t get new values since may, where i made the OH update. Values is still filled with old date.

Can someone help me? What do i have to change to get it working again?

Whitch messages does the SmartHome-Designer show?
How do you define this items?

I don´t have installed the smarthome-designer. Can i do this with Paper UI or can i do this only manually by copying the unpacked directory over my OH2 installation?

Here are my Items:

Number  	Xiaomi_Temp_1     		"Temp 1 [%.1f °C]"     			<temperature>	(gXiaomiTemp, gXiaomi_Temp_Sensors, gXiaomi_Temperatur)		{ channel="mihome:sensor_ht:158d00114c2b3a:temperature" }

DateTime Xiaomi_Temp_1_last_connection				"Temp 1 [%1$td.%1$tm., %1$tH:%1$tM]"						(gXiaomiZeit)
DateTime Xiaomi_Temp_2_last_connection				"Temp 2 [%1$td.%1$tm., %1$tH:%1$tM]"						(gXiaomiZeit)


Number		Xiaomi_Temp_1_time_since		"Xiaomi Temp 1 letztes Update vor [%.0f Minuten]"		<clock>
Number		Xiaomi_Temp_2_time_since		"Xiaomi Temp 2 letztes Update vor [%.0f Minuten]"		<clock>

I installed it on my Win-PC, but there are also versions for OS X and Linux.

I downloaded the smarthome-designer snapshot 0.9.0 and expanded it to my drive - but then i get many java errors. I can´t start ist. So i thought, i have to copy it diretcly into my OH2 directory?

Will test on another computer.



I don´t understand the error messages…

mapdb is spelled correct.

gXiaomiTemp is the name of a group and it is persisted inside rrd4j and inside mapdb
gXiaomiZeit is the same.

Fair enough. Like most other parts of OpenHAB you have to get used to what it tells you.

First up, most will advise to use Designer 0.8 for now, 0.9 has flaky bits apparently

Yes, but you won’t find it in an English dictionary. This really is just a string spell-checker, so if you are happy it can be safely ignored.

Yes, but it probably is not a valid Item on “hr”'s sytem.


Are your rules firing at all? There have been large changes about how group updates work (and so about triggering from group updates)

I uncommented the log-commands in the rules and it shows all the timestamps from the second rule - but allways with the old date.

Will have a look into it, if i get the logs from the first rule as well.

That seems consistent with group update not triggering. Next you need to look at group Item definition.

Yes, you are right. The group gXiaomiTemp will not work in the first rule anymore. I doesn´t get triggered if an item inside this groups changes.

I changed it to Group:switch gXiaomiTemp.

But i don´t get new values for the timestamp shown in the logs from the second rule.

I did some further tests…

It is working again. Xiaomi Sensors only send new values every 50 minutes, so i had to wait some time.

Thanks for your help!

One more question: Can i make the second rule usable for all items?

Now i have 6 rules for 6 items. How can i change the rule to only have 1 rule for all 6 temp-sensors? Like the first rule.

Use 0.8. There are massive issues with 0.9 which makes it almost unusable.

It is a separate program. Unzip it to its own folder. See:

http://docs.openhab.org/installation/designer.html

See:

and

At a high level, put your Items in Groups, use similarly named Item names, and then loop through the Group of Temp sensor Items, pull out its associated time_since Item from the time_since Group and postUpdate the minutes.

1 Like