Hi I have an Alexa Echo Binding Rule which I can ask alexa if there are windows open - alexa check if open or not and say yes or no …it was running very good and i dont think i made a config change.
It could be that I upgraded the OH2 Docker container anytime but I dont changed anything in the config. It was running till yesterday - now I got NULL error.
I rebooted the system open and closed any window but still got the error.
rule:
rule "Alexa - Fenster offen"
when
Member of Amazon_Echos changed to "sind noch fenster offen"
then
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(Fenster.state == OPEN) {
currentEcho.sendCommand("Ja, folgende Fenster sind geöffnet. " + OffeneFenster)
}
else {
currentEcho.sendCommand("Nein alle Fenster sind zu")
}
end
It’s probably not going to help much more, but it would be good practice to show us the actual error. I guess you are finding this in your openhab.log?
Okay, some basics.
When openHAB starts up and creates Items, they all get a state of NULL.
That’s the way they stay until something changes them - a restore, or an update from a binding, etc.
So in the normal course of events, Items linked to battery window sensors may stay at NULL state for a long time after a reboot, until the window is opened and an update happens.
Obviously there are things you can’t do with NULL in rules, like simply adding up for example.
note that Item state NULL is not like null, the empty or void variable value in rules. Pay attention to error messages.
I can’t see an obvious problem in your rule. It filters group members by state==OPEN, so you might end up with an empty list, but that should be dealt with.
My next suspect would be that [lastUpdate]
Is there (yet) a last update to find? Is there a configured default persistence service - you’re relying on that.
If the mystery error message is not forthcoming about where in the rule the problem arises, you can diagnostically add logInfo() to follow rule progess step by step.
2020-10-14 11:52:40.479 [vent.ItemStateChangedEvent] - Echo_Kitchen_LastVoiceCommand changed from sind noch fenster offen to alexa
2020-10-14 11:52:45.798 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Alexa - Fenster offen': null
2020-10-14 11:52:45.780 [vent.ItemStateChangedEvent] - Echo_Kitchen_LastVoiceCommand changed from alexa to sind noch fenster offen
My presistance is a mariadb with jdbc.persist file
This info is spot on and my link was so you could find more information about doing this.
Change your rule to add a warning in the log if you get a null state like
rule "Alexa - Fenster offen"
when
Member of Amazon_Echos changed to "sind noch fenster offen"
then
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
Changed to your rule with additional log info - but get any additional log entry:
2020-10-15 10:25:35.639 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'echofenster.rules', using it anyway:
2020-10-15 10:25:35.670 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'echofenster.rules'
2020-10-15 10:26:01.253 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Alexa - Fenster offen': null
2020-10-15 10:26:01.140 [vent.ItemStateChangedEvent] - Echo_Kitchen_LastVoiceCommand changed from alexa to sind noch fenster offen
2020-10-15 10:26:54.874 [vent.ItemStateChangedEvent] - Echo_Kitchen_LastVoiceCommand changed from sind noch fenster offen to alexa
2020-10-15 10:27:05.417 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Alexa - Fenster offen': null
2020-10-15 10:27:05.400 [vent.ItemStateChangedEvent] - Echo_Kitchen_LastVoiceCommand changed from alexa to sind noch fenster offen
2020-10-15 10:27:29.797 [vent.ItemStateChangedEvent] - Echo_Kitchen_LastVoiceCommand changed from sind noch fenster offen to alexa
2020-10-15 10:27:40.584 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Alexa - Fenster offen': null
2020-10-15 10:27:40.576 [vent.ItemStateChangedEvent] - Echo_Kitchen_LastVoiceCommand changed from alexa to sind noch fenster offen
I have 3 different window switches the most are the contacts from xiaomi , than 1 from homematic and one from homematic ip
it has worked before it is not a problem that it never would have done in the configuration.
when i look into mysql for the presistence of the group windows - all members have OPEN or CLOSED in them
Your rules are executing before the items have been populated causing the error. Ignore it, delay the rule start or touch all of your rules files after openhab has fully started.
Use mapdb for restoreOnStartup and remove that from mariaDB persistence.
Trouble probably is the item isn’t restored when the rule executes.
You should also check for the item to be NULL in your “filter” line to be more failsafe.
ok - sorry for my noobish but could you be more detail what i should change ? i never worked with mapdb oder somethin like that - also im new to persistences as well
copy mariadb.persist into mapdb.persist and remove all strategies but restoreOnStartup. Remove restoreOnStartup from mariadb.persist.
And read up in the docs how to enable mapdb persistence in the first place.
And as @rossko57 said check and make mariadb your default persistence.
can you show the item definition please
And Alexa takes any literal input even if she doesn’t understand it semantically ?