Help with Virtual Device Code (AKA help with errors!)

So I created a simple virtual outlet by just using the relevant bits of the publicly released virtual omni sensor code for the power monitoring. The data is sent from node-red/zigbee2mqtt from an actual ST outlet which is not part of the HE mesh for compatibility reasons.

Anyhow this is the code:

metadata {
definition (name: "Draft Virtual Outlet", namespace: "Hubitat", author: "none") {
capability "Outlet"
capability "Switch"
capability "PowerMeter"
capability "Refresh"

command "setPower", ["Number"]
}
}

// handle commands
def on() {
sendEvent(name: "switch", value: "on")
}

def off() {
sendEvent(name: "switch", value: "off")
}

def parse(String description) {
}

def setPower(power) {
def descriptionText = "${device.displayName} is ${power} power"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: "power", value: power, descriptionText: descriptionText)
}

However in the logs I'm getting these errors:

The driver works fine otherwise. Any help would be appreciated. It's probably something fairly straightforward that I'm missing!

If that's the entirety of your driver, I see nothing there that should be causing this. Thus, what must have happened is that this device previously used a different driver, scheduled periodic jobs with those names (ping and checkEventInterval, for methods that existed in the previous driver matching those names), and were never erased.

An easy way to erase them would be to switch temporarily to Hubitat's "Device" driver, run the "Delete All Scheduled Job" command (and "Delete All States" wouldn't hurt either, assuming your driver does not use state and the previous one may have, though won't fix this particular problem). If this is the problem, this should fix it, and you can immediately switch back to your driver and verify that the problem no longer occurs.

3 Likes

Thanks - will try that! It was previously paired to HE with the ST outlet driver and then re-paired to my CC2531 stick. So the actual physical device is no longer on HE.

EDIT: that did the trick. That's my new lesson for the day learned! :+1:

Hi Robert,

I am having a similar issue with a Sonoff Button that I was using a community driver for until I switched it to the "Sonoff Zigbee Button Controller" driver provided with a recent Hubitat platform update.
I'm am looking for a way to run the "Delete All Scheduled Job" command but don't see how to accomplish that. When you suggested using Hubitat's "Device" driver are you referring to a generic driver that offers that command?

Yes. In the “type” drop down for your device, you will find one named: “device”.

1 Like

Thanks for the assist Sebastien, when Robert said Hubitat's "Device" driver, I failed to see that he meant that literally. :grin:

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.