- Platform information:
- Hardware: Raspberry Pi 3 Model B Rev 1.2
- OS: Raspbian GNU/Linux 8 (jessie)
- Java Runtime Environment: don’t know
- openHAB version: openHAB 2.3.0-1 (Release Build)
- Issue of the topic: Lambda does not execute (see details below)
I am pulling my hair out (whatever is left…) to get this lambda code working. My problem is a thought understanding of the “types” that OpenHAB is using. I have tried to search for some detailed info, but so far have only found references that lead me into a wild goose chase .
Here is the simplified test rule and it’s corresponding error messages in the log:
rule (including the item definition as comment in the rule):
// ********************************************************
// Lambda Test
// ********************************************************
val Functions$Function2 <StringItem, StringItem, Boolean> LambdaTest = [ item1, item2 |
var int tNumber
logInfo(RFN, "#*#*#*#*#*#*#*#*#*#* Lambda: entered...")
if (item2.state == "Family")
{
tNumber = Integer::parseInt(item1.state.toString)
logInfo(RFN, "#*#*#*#*#*#*#*#*#*#* Lambda: tNumber = " + tNumber.toString)
}
logInfo(RFN, "#*#*#*#*#*#*#*#*#*#* Lambda: exited...")
true
]
//********************************************************
// Rule Lamba Testing
// Item definition in .items file:
// String Entered_Code "Entered Code"
// String TV_Room "Family,Office or Bed" (gCDcmd)
// ********************************************************
rule "Lamba Testing"
when
Item Entered_Code changed
then
logInfo(RFN, "#*#*#*#*#*#*#*#*#*#* Lamba Testing: Entered_Code entry...")
if(triggeringItem.state == NULL) return;
logInfo(RFN, "#*#*#*#*#*#*#*#*#*#* Lamba Testing: Trigger Item :" + triggeringItem)
logInfo(RFN, "#*#*#*#*#*#*#*#*#*#* Lamba Testing: TV_Room Item :" + TV_Room)
// prevent endless loop due to postupdate further down...
if (triggeringItem.state != "")
{
logInfo(RFN, "#*#*#*#*#*#*#*#*#*#* Lamba Testing: Lambda called...")
LambdaTest.apply(triggeringItem,TV_Room)
logInfo(RFN, "#*#*#*#*#*#*#*#*#*#* Lamba Testing: Lambda executed...")
// reset to empty string to allow new (or same) entry via HABpanel
Entered_Code.postUpdate("")
}
logInfo(RFN, "#*#*#*#*#*#*#*#*#*#* Lamba Testing: Entered_Code exit...")
end
The log output is here:
2018-09-29 10:33:48.717 [INFO ] [org.eclipse.smarthome.model.script.ZMOTE ] - #*#*#*#*#*#*#*#*#*#* Lamba Testing: Entered_Code entry...
2018-09-29 10:33:48.729 [INFO ] [org.eclipse.smarthome.model.script.ZMOTE ] - #*#*#*#*#*#*#*#*#*#* Lamba Testing: Trigger Item :Entered_Code (Type=StringItem, State=114, Label=Entered Code, Category=null)
2018-09-29 10:33:48.737 [INFO ] [org.eclipse.smarthome.model.script.ZMOTE ] - #*#*#*#*#*#*#*#*#*#* Lamba Testing: TV_Room Item :TV_Room (Type=StringItem, State=Family, Label=Family,Office or Bed, Category=null, Groups=[gCDcmd])
2018-09-29 10:33:48.742 [INFO ] [org.eclipse.smarthome.model.script.ZMOTE ] - #*#*#*#*#*#*#*#*#*#* Lamba Testing: Lambda called...
2018-09-29 10:33:48.753 [ERROR] [.model.rule.runtime.internal.engine.RuleEngineImpl] - Rule 'Lamba Testing': null
Maybe @rlkoshak can help? (from whom I learned a huge deal! I am ever amazed how much time you spend to teach the community, THANK YOU!)
Thanks in advance,
Al