Why is it not working I going bald, I have tried also
//convert hex_code to Number type
var MyNumber = Integer.parseInt(hex_code, 16) as Number
//use the following for large_hex_code
var MyNumber1 = Long.parseLong(hex_code, 16) as Number
// coverting hex_code into DecimalType
var DecimalType parsedResult = DecimalType.valueOf(Long.parseLong(hex_code, 16).toString);
val itemvalue = new java.math.BigDecimal(Integer::parseInt(hex_code, 16))
I guess I don’t know or its not working or is broken.
Oh well try another approach
Install JS Transformation Pattern
Create File in transformation folder
HEXtoDEC.JS
(function(i) {
if (i == 'NULL') { return i; }
if ((i == '-') || (i == 'UNDEF')) { return 'Undefined'; }
return (parseInt(i,16));
})(input)
Then use a transform in your rule
rule "Battery Level"
when Time cron "0/15 * * * * ?" //run every 15 seconds
then
var hex_code = executeCommandLine("i2cget -y 1 0x62 0x4 b",10000)
var value = transform("JS", "HEXtoDEC.js", hex_code)
logInfo("Hex",hex_code)
logInfo("Test",value)
end