Getting "Ambiguous method overloading for method java.lang.Integer#div"

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.


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_${}")  // 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. "onTIME=$onTIME, onPeriod=$onPeriod, percentON=$percentON, OutsideTemp=${state.Temperature},  MasterBRTemp= ${state.MasterBRTemp}"
    }  //if idle
}  // handlerAC

you have a null value in some variable on line 74

Thank you, I'll do some more troubleshooting, however am I wrong in thinking the operands are the same as:

where is onPeriod defined?, i see period, but not onPeriod

1 Like

Oops !

Sorry, you shouldn't have to edit my typos.

But thank you for you observation.