I'm receiving an error when trying to calculate a ratio on integers. I've tried several variations of variable types and have not found where I'm going wrong.
I think the operands are the result of subtracting two Epoch values. So I can't see where I'm going astray.
Any help would be appreciated.
John
def handlerAC(evt) {
if(evt.value == "cooling"){
state.coolStart = now()
}
else if(evt.value == "idle"){ // if idle we must be stopped.
state.prev_coolStop = state.coolStop // in ms
state.coolStop = now()
int onTIME = (state.coolStop - state.coolStart)
int period = (state.coolStop - state.prev_coolStop)
BigDecimal percentON = (onTIME/onPeriod) * 100 // line 74
def percentONDevice = getChildDevice("percentONdeviceHandle_${app.id}") // we need this becasue apps forget variables between runs.
percentONDevice.reportAC_ON(percentON.toInteger()) // <<---------- this sends percentON to the device driver to create an event.
percentONDevice.reportAC_Period(period.toInteger()) // <<---------- this sends period to the device driver to create an event.
log.info "onTIME=$onTIME, onPeriod=$onPeriod, percentON=$percentON, OutsideTemp=${state.Temperature}, MasterBRTemp= ${state.MasterBRTemp}"
} //if idle
} // handlerAC