Hello all,
I’m writing this here as I think it is the right sub forum. And might be interesting for others as well - as soon as the problems are solved.
My goal is to monitor two APC UPS devices. I took some information, configuration and scripts from here.
Looks pretty decent but I am stuck with one error message:
2016-06-21 13:24:06.804 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'USV Handling': The name 'compile(<XFeatureCallImplCustom>)' cannot be resolved to an item or type.
Here’s the content of my configuration files:
Items file:
String USV_Log "kompletter Inhalt des Logs [%s]" { exec="<[/home/pi/USV_dump_log 3551:60000:REGEX((.*))]" }
String USV_Status "USV Status [%s]" <apc> (USV)
Number USV_LineV "USV Input Volts [%.1f V]" <apc> (USV)
Number USV_OutputV "USV Output Volts [%.1f V]" <apc> (USV)
Number USV_Load "USV Load [%.1f %%]" <apc> (USV)
Number USV_BattCharge "USV Battery Charge [%.1f %%]" <apc> (USV)
Number USV_MBattChg "USV Battery Change [%.1f %%]" <apc> (USV)
Number USV_TimeLeft "USV Time Left [%.1f min]" <apc> (USV)
Number USV_ITemp "USV Temperatur [%.1f °C]" <selfTemperature> (USV)
Number USV_BattVoltage "USV Battery Volts [%.1f V]" <apc> (USV)
String USV_BattDate "USV Battery Date [%s]" <apc> (USV)
usv.rules:
val org.eclipse.xtext.xbase.lib.Functions$Function4 UPS_GetNumValue = [
org.openhab.core.library.items.StringItem logITem,
org.openhab.core.library.items.NumberItem upsITem,
String sExpr,
String logline |
var String ups_log
ups_log = logITem.state.toString
var Pattern ups_pattern
ups_pattern = Pattern::compile(sExpr)
var Matcher ups_matcher
ups_matcher = ups_pattern.matcher(ups_log)
ups_matcher.find()
var String ups_result
ups_result = ups_matcher.group(1)
upsITem.postUpdate(ups_result)
]
val org.eclipse.xtext.xbase.lib.Functions$Function4 UPS_GetStrValue = [
org.openhab.core.library.items.StringItem logITem,
org.openhab.core.library.items.StringItem upsITem,
String sExpr,
String logline |
var String ups_log
ups_log = logITem.state.toString
var Pattern ups_pattern
ups_pattern = Pattern::compile(sExpr)
var Matcher ups_matcher
ups_matcher = ups_pattern.matcher(ups_log)
ups_matcher.find()
var String ups_result
ups_result = ups_matcher.group(1)
upsITem.postUpdate(ups_result)
]
rule "USV Handling"
when
Item USV_Log received update
then
UPS_GetStrValue.apply(USV_Log,USV_Status,"(?<=STATUS : )(.*?)(?= )","LogLine")
logInfo("USV.Handler","USV Status: "+USV_Status.state.toString+"")
UPS_GetNumValue.apply(USV_Log,USV_LineV,"LINEV \\: ([-+]?[0-9]*\\.?[0-9]) Volts","LogLine")
logInfo("USV.Handler","USV Input Volts: "+USV_LineV.state.toString+" Volt")
UPS_GetNumValue.apply(USV_Log,USV_OutputV,"OUTPUTV \\: ([-+]?[0-9]*\\.?[0-9]) Volts","LogLine")
logInfo("USV.Handler","USV Output Volts: "+USV_OutputV.state.toString+" Volt")
UPS_GetNumValue.apply(USV_Log,USV_Load,"LOADPCT \\: ([-+]?[0-9]*\\.?[0-9]) Percent","LogLine")
logInfo("USV.Handler","USV Load: "+USV_Load.state.toString+" %")
UPS_GetNumValue.apply(USV_Log,USV_BattCharge,"BCHARGE \\: ([-+]?[0-9]*\\.?[0-9]) Percent","LogLine")
logInfo("USV.Handler","USV Battery Charge: "+USV_BattCharge.state.toString+" %")
UPS_GetNumValue.apply(USV_Log,USV_MBattChg,"MBATTCHG \\: ([-+]?[0-9]*\\.?[0-9]) Percent","LogLine")
logInfo("USV.Handler","USV Battery Change: "+USV_MBattChg.state.toString+" %")
UPS_GetNumValue.apply(USV_Log,USV_TimeLeft,"TIMELEFT \\: ([-+]?[0-9]*\\.?[0-9]) Minutes","LogLine")
logInfo("USV.Handler","USV Time Left: "+USV_TimeLeft.state.toString+" %")
UPS_GetNumValue.apply(USV_Log,USV_ITemp,"ITEMP \\: ([-+]?[0-9]*\\.?[0-9]) C","LogLine")
logInfo("USV.Handler","USV Temperatur: "+USV_ITemp.state.toString+" C")
UPS_GetNumValue.apply(USV_Log,USV_BattVoltage," BATTV \\: ([-+]?[0-9]*\\.?[0-9]) Volts","LogLine")
logInfo("USV.Handler","USV Battery Volts: "+USV_BattVoltage.state.toString+" Volt")
UPS_GetStrValue.apply(USV_Log,USV_BattDate,"(?<=BATTDATE : )(.*?)(?= )","LogLine")
logInfo("USV.Handler","USV Battery Date: "+USV_BattDate.state.toString+"")
end
Script output and content of USV_Log looks like this:
APC : 001,045,1049 DATE : 2016-06-21 13:31:06 +0200 HOSTNAME : lemy VERSION : 3.14.12 (29 March 2014) debian UPSNAME : Aquarium CABLE : USB Cable DRIVER : USB UPS Driver UPSMODE : Stand Alone STARTTIME: 2016-06-20 21:29:20 +0200 MODEL : Back-UPS CS 650 STATUS : ONLINE LINEV : 234.0 Volts LOADPCT : 30.0 Percent BCHARGE : 100.0 Percent TIMELEFT : 19.2 Minutes MBATTCHG : 20 Percent MINTIMEL : 3 Minutes MAXTIME : 0 Seconds OUTPUTV : 230.0 Volts SENSE : Medium DWAKE : 0 Seconds DSHUTD : 0 Seconds LOTRANS : 180.0 Volts HITRANS : 266.0 Volts RETPCT : 0.0 Percent ITEMP : 29.2 C ALARMDEL : 30 Seconds BATTV : 13.6 Volts LINEFREQ : 50.0 Hz LASTXFER : No transfers since turnon NUMXFERS : 0 TONBATT : 0 Seconds CUMONBATT: 0 Seconds XOFFBATT : N/A SELFTEST : NO STESTI : None STATFLAG : 0x05000008 MANDATE : 2004-10-29 SERIALNO : QB0444135240 BATTDATE : 2015-03-18 NOMOUTV : 230 Volts NOMINV : 230 Volts NOMBATTV : 12.0 Volts NOMPOWER : 400 Watts FIRMWARE : 817.v2.I USB FW:v2 END APC : 2016-06-21 13:31:07 +0200
(All in one line.)
I have no idea what I am missing. Maybe someone can help me out…
Thanks a lot and cheers
Roi