Number item (read/update)

This worked:

import java.net.URLEncoder

var ZonedDateTime LIVACCOM_EtaStart = null

rule "Detect LIV AC Compressor on"
when 
    Item velbusGU44RYLDACAddress04_LIVACCOMP changed from OFF to ON
then
    logInfo("AC","LIVING ROOM COMPRESSOR ON")  
    // this is to calculate the minutes per day for the AC compressor to be on
    LIVACCOM_EtaStart = now
end

rule "Detect LIV AC Compressor OFF"
when 
    Item velbusGU44RYLDACAddress04_LIVACCOMP changed from ON to OFF
then
    var LIVACCOM_EtaDelta = Duration.between(LIVACCOM_EtaStart, now)
    var Number LIVACCOM_EtaRunTime = LIVACCOM_EtaDelta.toSeconds
    logInfo("AC","Running for -  " + LIVACCOM_EtaRunTime)

    var Number LIVoldValueRunTime = (LIVACCOM_SecondsPerDay.state as Number)
    logInfo("AC","old value -  " + LIVoldValueRunTime)
    if (LIVoldValueRunTime == NULL) {
        logInfo("AC","old value was NULL -  " + LIVoldValueRunTime)
        LIVoldValueRunTime = 0
    }
    var LIVACCOM_TotalRunTime = (LIVoldValueRunTime + LIVACCOM_EtaRunTime)
    logInfo("AC","Total seconds today -  " + LIVACCOM_TotalRunTime)
    LIVACCOM_SecondsPerDay.postUpdate(LIVACCOM_TotalRunTime)
end

You can only postUpdate to Items.
I don’t know if you have an Item named testHowLongSwitchRunTime, but if you did …

declaring a variable of the same name will mean the rule will use the new variable (which is an integer number, value 0) and not any Item.

Local variables and OH Items are not interchangeable.

In most cases, if you wanted to know the “value” of an Item within a rule, you would be interested in its .state property.

var temporary = myItem.state as Number

The end-result for whomever may want to use the same…

import java.net.URLEncoder
var ZonedDateTime LIVACCOM_EtaStart = null

rule "Detect LIV AC Compressor on"
when
    Item velbusGU44RYLDACAddress04_LIVACCOMP changed from OFF to ON
then
    logInfo("AC","LIVING ROOM COMPRESSOR ON")  
    // this is to calculate the minutes per day for the AC compressor to be on
    LIVACCOM_EtaStart = now
end

rule "Detect LIV AC Compressor OFF"
when
    Item velbusGU44RYLDACAddress04_LIVACCOMP changed from ON to OFF
then
    var LIVACCOM_EtaDelta = Duration.between(LIVACCOM_EtaStart, now)
    var Number LIVACCOM_EtaRunTime = LIVACCOM_EtaDelta.toSeconds
    
    // we get the original value so we can increment in a temporary variable
    var LIVoldValueRunTimetemp = LIVACCOM_SecondsPerDay.state
    var Number LIVoldValueRunTime

   // given the variable retrieved might be NULL (it cannot be a number by default then) we need to check on this.. if it is NULL we are going to set the used Number value to 0, else we convert the temporary value from the variable retrieved to a "Number" to be used in the SUM calculation below

    if (LIVoldValueRunTimetemp == NULL) {
        //logInfo("AC","old value was NULL -  " + LIVoldValueRunTimetemp)
        LIVoldValueRunTime = 0
    }else{
        LIVoldValueRunTime = (LIVoldValueRunTimetemp as Number)
    }
    var LIVACCOM_TotalRunTime = (LIVoldValueRunTime + LIVACCOM_EtaRunTime)
    logInfo("AC","Living Room AC Total seconds today -  " + LIVACCOM_TotalRunTime)
    LIVACCOM_SecondsPerDay.postUpdate(LIVACCOM_TotalRunTime)
end