I’m trying to convert the hex number output of a battery pack to a number item using parseInt inside a rule. So far my attempts have been giving me persistent errors.
Heres the rule:
rule "Battery Level" when Time cron "0/15 * * * * ?" //run every 15 seconds then var string = executeCommandLine("i2cget -y 1 0x62 0x4 b",10000) logInfo("Hex",string) var int value = Integer::parseInt(string) logInfo("Test",value) end
2020-10-17 19:22:15.067 [INFO ] [g.eclipse.smarthome.model.script.Hex] - 0x61
2020-10-17 19:22:15.072 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘Battery Level’: For input string: “0x61”
I’ve also tried giving parseInt a string directly parseInt(‘0x61’) however it still results in the above error, same with parseInt(‘0x61’, 16)
Any help would be appreciated I’ve been stuck on this for hours now