apsupsd have a web interface, maybe is possible to get ups status data using http binding
Will be good if you share some information about apcupsd web interface and http binding... possible ot not possible
--
You received this message because you are subscribed to a topic in the Google Groups "openhab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openhab/W4xj_JAlWtA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
To view this discussion on the web visit https://groups.google.com/d/msgid/openhab/438773fc-251b-4fd1-9c71-3f8d7a5c6ca8%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
To view this discussion on the web visit https://groups.google.com/d/msgid/openhab/CAHuJBZGDr7FZjqYe_Cq1TA5nXWeWU4OhdtiUkhjP_ENm3gTBYw%40mail.gmail.com.
#!/bin/bashexport UPS_LOG="$(/sbin/apcaccess status localhost:$1)"
echo $UPS_LOG
String UPS_1_LOG "Stringa di Log Completa [%s]" { exec="<[/opt/openhab/configurations/myscript/ups_dump_log 3551:60000:REGEX((.*))]"}
String UPS_1_NAME "Nome UPS [%s]" String UPS_1_LASTUPDATE "Ultimo Aggiornamento [%s]" <calendar>String UPS_1_STATUS "Stato UPS [%s]" <power_light>Number UPS_1_RUNTIME "Runtime [%.1f Minuti]" <stopwatch>Number UPS_1_LINEVOLTAGE "Tensione di Linea [%.1f Volt]" <voltmeter>Number UPS_1_OUTVOLTAGE "Tensione Output [%.1f Volt]" <voltmeter>Number UPS_1_LOAD "Carico [%.1f %%]" <power_load>Number UPS_1_BATTVOLTAGE "Tensione Batteria [%.1f Volt]" <voltmeter>Number UPS_1_BATTCHARGE "Percentuale Carica Batteria [%.1f %%]" <battery_100>Number UPS_1_ITEMP "Temperatura Interna [%.1f °C]" <temperature>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 "UPS 1500 Handling"when Item UPS_1_LOG received updatethen //Nome UPS UPS_GetStrValue.apply(UPS_1_LOG,UPS_1_NAME,"(?<=UPSNAME : )(.*?)(?= )","LogLine") logInfo("UPS.1.Handler","Log "+UPS_1_NAME.state.toString+" recuperato") //Ultimo Aggiornamento UPS_GetStrValue.apply(UPS_1_LOG,UPS_1_LASTUPDATE,"(?<=DATE : )(.*?)(?= HOSTNAME)","LogLine") logInfo("UPS.1.Handler","Ultimo Aggiornamento: "+UPS_1_LASTUPDATE.state.toString+"") //Stato UPS UPS_GetStrValue.apply(UPS_1_LOG,UPS_1_STATUS,"(?<=STATUS : )(.*?)(?= )","LogLine") logInfo("UPS.1.Handler","Stato UPS: "+UPS_1_STATUS.state.toString+"") //Runtime UPS_GetNumValue.apply(UPS_1_LOG,UPS_1_RUNTIME,"TIMELEFT \\: ([-+]?[0-9]*\\.?[0-9]) Minutes","LogLine") logInfo("UPS.1.Handler","Runtime: "+UPS_1_RUNTIME.state.toString+" Minuti") //Tensione Di Linea UPS_GetNumValue.apply(UPS_1_LOG,UPS_1_LINEVOLTAGE,"LINEV \\: ([-+]?[0-9]*\\.?[0-9]) Volts","LogLine") logInfo("UPS.1.Handler","Tensione di Linea: "+UPS_1_LINEVOLTAGE.state.toString+" Volt") //Tensione di Uscita UPS_GetNumValue.apply(UPS_1_LOG,UPS_1_OUTVOLTAGE,"OUTPUTV \\: ([-+]?[0-9]*\\.?[0-9]) Volts","LogLine") logInfo("UPS.1.Handler","Tensione d'Uscita: "+UPS_1_OUTVOLTAGE.state.toString+" Volt") //Carico UPS_GetNumValue.apply(UPS_1_LOG,UPS_1_LOAD,"LOADPCT \\: ([-+]?[0-9]*\\.?[0-9]) Percent Load Capacity ","LogLine") logInfo("UPS.1.Handler","Carico: "+UPS_1_LOAD.state.toString+" %") //Tensione di Batteria UPS_GetNumValue.apply(UPS_1_LOG,UPS_1_BATTVOLTAGE," BATTV \\: ([-+]?[0-9]*\\.?[0-9]) Volts","LogLine") logInfo("UPS.1.Handler","Tensione di Batteria: "+UPS_1_BATTVOLTAGE.state.toString+" Volt") //Carica Batteria UPS_GetNumValue.apply(UPS_1_LOG,UPS_1_BATTCHARGE,"BCHARGE \\: ([-+]?[0-9]*\\.?[0-9]) Percent","LogLine") logInfo("UPS.1.Handler","Carica Batteria: "+UPS_1_BATTCHARGE.state.toString+" %") //Temperatura Interna UPS_GetNumValue.apply(UPS_1_LOG,UPS_1_ITEMP,"ITEMP \\: ([-+]?[0-9]*\\.?[0-9]) C","LogLine") logInfo("UPS.1.Handler","Temperatura Interna: "+UPS_1_ITEMP.state.toString+" C")
end
When i add the script to openhab 1.7.0
[ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'UPS 1500 Handling': The name 'compile(<XFeatureCallImplCustom>)' cannot be resolved to an item or type.
APC : 001,045,1084 DATE : 2015-07-26 20:02:11 +0200 HOSTNAME : nas VERSION : 3.14.10 (13 September 2011) debian UPSNAME : MINUPS CABLE : USB Cable DRIVER : USB UPS Driver UPSMODE : Stand Alone STARTTIME: 2015-07-26 19:00:04 +0200 MODEL : Back-UPS BF350 STATUS : ONLINE LINEV : 232.0 Volts LOADPCT : 22.0 Percent Load Capacity BCHARGE : 100.0 Percent TIMELEFT : 31.5 Minutes MBATTCHG : 15 Percent MINTIMEL : 10 Minutes MAXTIME : 0 Seconds OUTPUTV : 230.0 Volts SENSE : Medium DWAKE : 000 Seconds DSHUTD : 000 Seconds LOTRANS : 180.0 Volts HITRANS : 266.0 Volts RETPCT : 000.0 Percent ITEMP : 29.2 C Internal ALARMDEL : No alarm BATTV : 13.6 Volts LINEFREQ : 50.0 Hz LASTXFER : Low line voltage NUMXFERS : 0 TONBATT : 0 seconds CUMONBATT: 0 seconds XOFFBATT : N/A SELFTEST : NO STESTI : None STATFLAG : 0x07000008 Status Flag MANDATE : 2004-05-21 SERIALNO : AB0421122454 BATTDATE : 2004-05-21 NOMOUTV : 230 Volts NOMINV : 230 Volts NOMBATTV : 12.0 Volts NOMPOWER : 225 Watts FIRMWARE : 813.s3.I USB FW:s3 END APC : 2015-07-26 20:02:13 +0200