Hi all, I am hoping for some direction here… I am currently polling data from my solar controller and displaying them as floats, which is working ok but 2 of my status registers are actually mostly bit flags and 2 and 3 bit values… which would be much more useful to view as such… I have tried a few rules to try and pull some of the flags out, but am hoping there is a more elegant approach… can anyone point me to an example or suggest a direction?
Thanks for your response…
my efforts at this point seem to break down at my java understanding… my modbus polls are returning proper data ( 16bit road only registers ) and it my sitemap is displaying SolarTracerABattStatus and SolarTracerAChargeStatus as decimal numbers… I am attempting to use a logical AND to pull out the indidvual bits as separate status flags… but seem to be unable to use AND in my rules… I get a screen full of java error messages as soon as I introduce the AND operation… I am importing these libraries…
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import java.lang.Math
part of my solar.items
Number SolarTracerABattStatus “Tracer Battery Status [%d ]” (gTH_Solar_Status) {modbus=“slave2:0”}
Number SolarTracerABattVoltStatus “Status Batt Voltage [%d ]” (gTH_Solar_Status) {}
Number SolarTracerAChargeStatus “Tracer Charger Status [%d ]” (gTH_Solar_Status) {modbus=“slave2:1”}
Number SolarTracerAChargeRun “Status RUN [%d]” (gTH_Solar_Status) {}
Number SolarTracerAChargeNormal “Status NORMAL/Fault [%d]” (gTH_Solar_Status) {}
my rules attempt
rule "ChargStatus"
when
Item SolarTracerAChargeStatus received update or
Time cron "0 * * * * ?"
then
var Integer temp2=0
if(SolarTracerAChargeStatus.state instanceof DecimalType ) ChargeStatus= (SolarTracerAChargeStatus.state as DecimalType )
temp2 = ChargeStatus & 0x1
postUpdate(SolarTracerAChargeRun,temp2)
var Integer temp3=(SolarTracerAChargeStatus.state as DecimalType & 2)
postUpdate(SolarTracerAChargeNormal,temp3)
end
this rule fails with
Error during the execution of rule ChargStatus
java.lang.IllegalStateException: Ambiguous methods [protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAssignment(org.eclipse.xtext.xbase.XAssignment,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBlockExpression(org.eclipse.xtext.xbase.XBlockExpression,org.eclipse.xtext.xbase.interpreter.IEvaluationContext,org.eclipse.xtext.util.CancelIndicator), protected java.lang.Object org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBooleanLiteral(org… much more…