You may have several (or none) persistence services.
You may designate one (or none) as the default service in openHAB settings.
This interacts with the default persistence service, because you have not specified a particular service to use here.
If you have not made a default, or the given default does not support lastUpdate, it will fail.
If there’s just no data for a particular Item, I’m not sure what happens with the sortBy.
Why not make some diagnostic moves, understand the problem better? Maybe your error is later in the rule?
rule "Alexa - Fenster offen"
when
Member of Amazon_Echos changed to "sind noch fenster offen"
then
logInfo("test", "preview lastupdates")
// wait for persist to catch that last change
Thread::sleep(100)
Amazon_Echos.members.forEach[ stamp |
logInfo("test", "fetching stamp " + stamp.name)
if (stamp.lastUpdate === null) {
logInfo("test", "No stamp")
} else {
logInfo("test", "stamp " + stamp.lastUpdate.toString)
}
]
val currentEcho = Amazon_Echos.members.sortBy[lastUpdate].last
logInfo("test", "selected " + currentEcho.name)
etc.
Can I ask what this lastupdate is for? Are you just trying to find out the source of the rule trigger? You know about implicit variable triggeringItem?
val currentEcho = Amazon_Echos.members.sortBy[lastUpdate].last <— Amazon_Echo Group are my echos - and lastupdate check only the one i spoke with - cause if you have more than one echo it could be you speak to it in the kitchen but the echo in living room would be answer.
no its equal cause i can say the magic phrase to one of the echo member in the group and that one is also answereing me than - thats the key of the lastupdate for the Amazon_Echos
so checked the default persistance settings and my only one is JDBC and this is default in paper ui
to your trigger item thing i change to this in the rule correct:
rule "Alexa - Fenster offen"
when
Member of Amazon_Echos changed to "sind noch fenster offen"
then
val currentEcho = Amazon_Echos.members.sortBy[lastUpdate].last
to
rule "Alexa - Fenster offen"
when
Member of Amazon_Echos changed to "sind noch fenster offen"
then
val currentEcho = Amazon_Echos.members.sortBy[triggeringItem].last
Just for information ! the rule is made cause of i want to ask alexa if any windows are open or not - she check the window contact if open or not and say if open which is open… just for clearification
You can of course just use triggeringItem where you used currentEcho before. It’s a magic variable pointing directly at the Item that triggered your rule…
rule "Alexa - Fenster offen"
when
Member of Amazon_Echos changed to "sind noch fenster offen"
then
val currentEcho = triggeringItem
val OffeneFenster = Fenster.members.filter[ i | i.state == OPEN ].map[ label ].reduce[ s, label | s + ", " + label ]
if(OffeneFenster == null) logWarn("FILE", "Something is amiss, no Item has a valid lastUpdate!")
if(Fenster.state == OPEN) {
currentEcho.sendCommand("Ja, folgende Fenster sind geöffnet. " + OffeneFenster)
}
else {
currentEcho.sendCommand("Nein alle Fenster sind zu")
}
end
So what i have done - i have done the refresh rule with the script from above and my actually rule looks like that:
rule "Alexa - Fenster offen"
when
Member of Amazon_Echos changed to "sind noch fenster offen"
then
val currentEcho = triggeringItem
// val currentEcho = Amazon_Echos.members.sortBy[lastUpdate].last
val OffeneFenster = Fenster.members.filter[ i | i.state == OPEN ].map[ label ].reduce[ s, label | s + ", " + label ]
if(OffeneFenster === null) logWarn("FILE", "Something is amiss, no Item has a valid lastUpdate!")
if(Fenster.state == OPEN) {
currentEcho.sendCommand("Ja, folgende Fenster sind geöffnet. " + OffeneFenster)
}
else {
currentEcho.sendCommand("Nein alle Fenster sind zu")
}
end
So what should i say !? It work why ? cause of the refresh rule maybe ?
Log looks like this:
2020-10-16 09:27:56.000 [WARN ] [.eclipse.smarthome.model.script.FILE] - Something is amiss, no Item has a valid lastUpdate!
2020-10-16 09:27:55.712 [vent.ItemStateChangedEvent] - Echo_Kitchen_LastVoiceCommand changed from alexa to sind noch fenster offen
2020-10-16 09:27:56.011 [ome.event.ItemCommandEvent] - Item 'Echo_Kitchen_LastVoiceCommand' received command Nein alle Fenster sind zu
2020-10-16 09:27:56.011 [nt.ItemStatePredictedEvent] - Echo_Kitchen_LastVoiceCommand predicted to become Nein alle Fenster sind zu
2020-10-16 09:27:56.019 [vent.ItemStateChangedEvent] - Echo_Kitchen_LastVoiceCommand changed from sind noch fenster offen to Nein alle Fenster sind zu
what does this mean ?
2020-10-16 09:27:56.000 [WARN ] [.eclipse.smarthome.model.script.FILE] - Something is amiss, no Item has a valid lastUpdate!
Well, it’s come from your rule. I don’t know why you used that text, it doesn’t mean what it says. The message means that this if(OffeneFenster === null)
was true.
That in turn means that your search of the group Fenster found no members OPEN
ok it was an suggestion here in the topic thought it has something to do with debugging - than i can comment it out or i edit the text - than i think all ist ok and working or ?
can anyone say me why i have such strong delay ? it was before the changes much faster
I think you need to examine that part of the rule and restructure it.
Your group search is for members OPEN … so why would you test later for OPEN.
What happens if none are OPEN (hint, you just found that out)
What delay? Maybe you can show us in your events.log
The first time a rule is run after editing always take a few seconds, there is compiling to do somewhere.