How to override Common methods

I would like to override some of the driver and app "common" methods. Well, overriding them is easy enough, but from the overridden method, is there a way to call the original method?

Overriding the driver methods is easy, as I can prefix the call with "driver." to get to the internal method. For common methods, is there an reference to the common method, like there is for driver?


// overridden method
void unschedule(handlerMethod) {
    // do something special, then

I already realize I can just create a method of a different name, but I want to override it, so that the new logic is inherited by all the calls to this original method that are made against my code.

Here is my actual code:

// override the unschedule method
void unscheduleQuery(handlerMethod) {
    volatileAtomicState[handlerMethod] = false

// override the runIn scheduler method
void runQueryIn(Long delayInSeconds, String handlerMethod, Map options = null) {
    volatileAtomicState[handlerMethod] = true
    runIn(delayInSeconds, handlerMethod, options)

If I rename unscheduleQuery to unschedule, how do I still call the common unschedule method?

Haven’t tried it with the built-in methods, but within some of my code I’ve provided overrides by simply naming the methods the same and using a different set of parameters or parameter types when making the call, and let the compiler direct the call appropriately.

You can’t do that because schedule et al aren’t part of your class so there’s no inheritance going on here so there is no super or anything like that. Those methods are basically in the global namespace essentially, not part of your object.


Try this:


@armand I'm curious whether that worked for you. In case you tried, can you let us know?

Download the Hubitat app