halloween
(Hallo Ween)
July 6, 2017, 6:51am
1
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?
hr3
(Harry)
July 6, 2017, 7:50am
2
Whitch messages does the SmartHome-Designer show?
How do you define this items?
halloween
(Hallo Ween)
July 6, 2017, 8:09am
3
hr3:
SmartHome-Designer
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>
hr3
(Harry)
July 6, 2017, 8:21am
4
I installed it on my Win-PC, but there are also versions for OS X and Linux.
halloween
(Hallo Ween)
July 6, 2017, 8:30am
5
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.
halloween
(Hallo Ween)
July 6, 2017, 8:41am
7
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.
rossko57
(Rossko57)
July 6, 2017, 10:06am
8
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)
halloween
(Hallo Ween)
July 6, 2017, 10:15am
9
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.
rossko57
(Rossko57)
July 6, 2017, 10:21am
10
That seems consistent with group update not triggering. Next you need to look at group Item definition.
halloween
(Hallo Ween)
July 6, 2017, 10:22am
11
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.
halloween
(Hallo Ween)
July 6, 2017, 12:13pm
12
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!
halloween
(Hallo Ween)
July 6, 2017, 12:52pm
13
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.
rlkoshak
(Rich Koshak)
July 6, 2017, 4:21pm
14
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:
Problem Statement
Often one finds a number of rules that are very similar and that all work on similar Items. One way to solve this problem is through the use of lambdas but an even more flexible approach is to use Groups.
This Design Pattern presents a step-by-step tutorial for how to use Groups to consolidate and simplify the these several similar rules into one single rule.
The example used will be based on Contact Items that represent door and window sensors. Whenever any of these Contac…
and
Problem Statement
Often one will have a number of separate Items which are all related to each other in some way. For example, one might have a Contact on a door and a DateTime to represent when the last time the door was opened. This is easy enough to keep track of if there are only one or two such Items, but if one has a lot of similar Items or is using a lot of genetically coded rules where one cannot hard code the names of the associated Items inside the rule mapping between the Items become…
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