Request: Edge Drivers for Aeotec Smart Switch 6 and and Multisensor 6

/**

  • on - Turns on the switch
  • Required for the “Switch” capability
    */
    def on() {
    if (switchDisabled) {
    logDebug “switch disabled, doing nothing”
    delayBetween([
    formatCommand(zwave.switchBinaryV1.switchBinaryGet())
    ], 200)
    } else {
    logDebug “switching it on”
    delayBetween([
    formatCommand(zwave.switchBinaryV1.switchBinarySet(switchValue: 0xFF)),
    formatCommand(zwave.switchBinaryV1.switchBinaryGet())
    ], 200)
    }
    }

/**

  • off - Turns off the switch
  • Required for the “Switch” capability
    */
    def off() {
    if (switchDisabled) {
    logDebug “switch disabled, doing nothing”
    delayBetween([
    formatCommand(zwave.switchBinaryV1.switchBinaryGet())
    ], 200)
    } else {
    logDebug “switching it off”
    delayBetween([
    formatCommand(zwave.switchBinaryV1.switchBinarySet(switchValue: 0x00)),
    formatCommand(zwave.switchBinaryV1.switchBinaryGet())
    ], 200)
    }
    }

/**

  • poll - Polls the device

  • Required for the “Polling” capability
    */
    def poll() {
    logTrace “poll()”

    delayBetween([
    formatCommand(zwave.switchBinaryV1.switchBinaryGet()),
    formatCommand(zwave.meterV3.meterGet(scale: 0)), // energy kWh
    formatCommand(zwave.meterV3.meterGet(scale: 1)), // energy kVAh
    formatCommand(zwave.meterV3.meterGet(scale: 2)), // watts
    formatCommand(zwave.meterV3.meterGet(scale: 4)), // volts
    formatCommand(zwave.meterV3.meterGet(scale: 5)), // amps
    ], 200)
    }

/**

  • refresh - Refreshed values from the device

  • Required for the “Refresh” capability
    */
    def refresh() {
    logInfo “refresh()”
    updateDeviceInfo()

    sendEvent(name: “power”, value: “0”, displayed: true, unit: “W”)
    sendEvent(name: “energy”, value: “0”, displayed: true, unit: “kWh”)
    sendEvent(name: “amperage”, value: “0”, displayed: true, unit: “A”)
    sendEvent(name: “voltage”, value: “0”, displayed: true, unit: “V”)

    sendEvent(name: “currentEnergyCostDay”, value: “0”, displayed: true)
    sendEvent(name: “currentEnergyCostWeek”, value: “0”, displayed: true)
    sendEvent(name: “currentEnergyCostMonth”, value: “0”, displayed: true)
    sendEvent(name: “currentEnergyCostYear”, value: “0”, displayed: true)

    sendEvent(name: “cumulativeEnergyCostDay”, value: “0”, displayed: true)
    sendEvent(name: “cumulativeEnergyCostWeek”, value: “0”, displayed: true)
    sendEvent(name: “cumulativeEnergyCostMonth”, value: “0”, displayed: true)
    sendEvent(name: “cumulativeEnergyCostYear”, value: “0”, displayed: true)

    delayBetween([
    formatCommand(zwave.switchMultilevelV1.switchMultilevelGet()),
    formatCommand(zwave.meterV3.meterGet(scale: 0)), // energy kWh
    formatCommand(zwave.meterV3.meterGet(scale: 1)), // energy kVAh
    formatCommand(zwave.meterV3.meterGet(scale: 2)), // watts
    formatCommand(zwave.meterV3.meterGet(scale: 4)), // volts
    formatCommand(zwave.meterV3.meterGet(scale: 5)), // amps
    formatCommand(zwave.configurationV1.configurationGet(parameterNumber: 0x51)), // device state
    formatCommand(zwave.configurationV1.configurationGet(parameterNumber: 0x53)), // night light RGB value
    formatCommand(zwave.configurationV1.configurationGet(parameterNumber: 0x54)), // led brightness
    ], 200)
    }

/**

  • reset - Resets the devices energy usage meter and attempt to reset device
  • Required for the “Switch Level” capability
    */
    def setLevel(level) {
    setBrightnessLevel(level)
    }

/**

  • Sets the color to the passed in maps values

  • Required for the “Color Control” capability
    */
    def setColor(colormap) {
    logDebug " in setColor"

    if (colormap.hex == null && colormap.hue) {
    def hexColor = colorUtil.hslToHex(colormap.hue, colormap.saturation)
    logDebug " in setColor colormap = $hexColor"

    sendEvent(name: "color", value: hexColor)
    formatCommand(zwave.configurationV1.configurationSet(parameterNumber: 0x53, size: 3, configurationValue: colorUtil.hexToRgb(hexColor)))
    

    } else {
    logDebug " in setColor: hex = ${colormap.hex}"
    sendEvent(name: “color”, value: colormap.hex)
    def hexColorList = colorUtil.hexToRgb(colormap.hex)
    formatCommand(zwave.configurationV1.configurationSet(parameterNumber: 0x53, size: 3, configurationValue: [hexColorList[0], hexColorList[1], hexColorList[2]]))
    }
    }

/*******************************************************************************

  • Methods *
    ******************************************************************************/

/**

  • installed - Called when the device handling is being installed
    */
    def installed() {
    logInfo “installed() called”

    if (state.deviceInfo == null) {
    state.deviceInfo = [:]
    state.deviceInfo[‘secureInclusion’] = false
    }

    // Call a reset upon install to clear all values.
    reset();

    updateDeviceInfo();
    }

/**

  • updated - Called when the preferences of the device type are changed
    */
    def updated() {
    logInfo “updated()”

    updateStatus()
    //updatePowerStatus(0)
    response(configure())
    }

/**

  • reset - Resets the devices energy usage meter and attempt to reset device

  • Defined by the custom command “reset”
    */
    def reset() {
    logInfo “reset()”
    state.energyMeterRuntimeStart = now()

    def timeString = new Date().format(“MM-dd-yy h:mm a”, location.timeZone)
    sendEvent(name: “resetDate”, value: "Since: "+timeString, unit: “”)

    delayBetween([
    formatCommand(zwave.meterV3.meterReset()),
    formatCommand(zwave.meterV3.meterGet(scale: 0)), // energy kWh
    formatCommand(zwave.meterV3.meterGet(scale: 1)), // energy kVAh
    formatCommand(zwave.meterV3.meterGet(scale: 2)), // watts
    formatCommand(zwave.meterV3.meterGet(scale: 4)), // volts
    formatCommand(zwave.meterV3.meterGet(scale: 5)), // amps
    ], 200)
    }

def factoryReset() {
logDebug “factoryReset()”

formatCommand(zwave.configurationV1.configurationSet(parameterNumber: 0xFF, size: 4, scaledConfigurationValue: 1))
//factory reset
configure()

}

def getDeviceInfo() {
logDebug “getDeviceInfo()”

delayBetween([
        formatCommand(zwave.versionV1.versionGet()),
        formatCommand(zwave.firmwareUpdateMdV2.firmwareMdGet()),
        //zwave.manufacturerSpecificV2.deviceSpecificGet().format(),
        formatCommand(zwave.manufacturerSpecificV2.manufacturerSpecificGet())
], 200)

}

private updateStatus() {
def sinceTime = ‘’
if (state.energyMeterRuntimeStart != null) {
sinceTime = “${getBatteryRuntime()}”
} else {
sinceTime = now()
}

sendEvent(name: "statusText3", value: "Elasped Time since Reset: $sinceTime", displayed: false)

}

private updateDeviceInfo() {
logInfo “updateDeviceInfo()”

if (state.deviceInfo == null) {
    state.deviceInfo = [:]
}

def buffer = "Get Device Info";
def newBuffer = null;

def switchStatus = "SWITCH ENABLED\n"
if (switchDisabled) {
    switchStatus = "SWITCH DISABLED\n"
}

if (state.deviceInfo['applicationVersion'] == null ||
    state.deviceInfo['manufacturerName'] == null) {
    getDeviceInfo()
} else {
    newBuffer = "${switchStatus}"
}

if (state.deviceInfo['applicationVersion'] != null) {
    if (newBuffer == null) {
        newBuffer = "${switchStatus}"
    }

    newBuffer += "app Version: ${state.deviceInfo['applicationVersion']} Sub Version: ${state.deviceInfo['applicationSubVersion']}\n";
    newBuffer += "zWaveLibrary Type: ${state.deviceInfo['zWaveLibraryType']}\n";
    newBuffer += "zWaveProtocol Version: ${state.deviceInfo['zWaveProtocolVersion']} Sub Version: ${state.deviceInfo['zWaveProtocolSubVersion']}\n";
    newBuffer += "secure inclusion: ${state.deviceInfo['secureInclusion'] || secureInclusionOverride}\n";
}

if (state.deviceInfo['manufacturerName'] != null) {
    if (newBuffer == null) {
        newBuffer = "${switchStatus}"
    }

    newBuffer += "manufacturer Name: ${state.deviceInfo['manufacturerName']}\n";
    newBuffer += "manufacturer Id: ${state.deviceInfo['manufacturerId']}\n";
    newBuffer += "product Id: ${state.deviceInfo['productId']} Type Id: ${state.deviceInfo['productTypeId']}\n";
    newBuffer += "firmwareId: ${state.deviceInfo['firmwareId']} checksum: ${state.deviceInfo['checksum']}\n";
}

if (newBuffer == null) {
    newBuffer = buffer
}

return sendEvent(name: "deviceInfo", value: "$newBuffer", displayed: false)

}

private getBatteryRuntime() {
def currentmillis = now() - state.energyMeterRuntimeStart
def days = 0
def hours = 0
def mins = 0
def secs = 0
secs = (currentmillis / 1000).toInteger()
mins = (secs / 60).toInteger()
hours = (mins / 60).toInteger()
days = (hours / 24).toInteger()
secs = (secs - (mins * 60)).toString().padLeft(2, ‘0’)
mins = (mins - (hours * 60)).toString().padLeft(2, ‘0’)
hours = (hours - (days * 24)).toString().padLeft(2, ‘0’)

if (days > 0) {
    return "$days days and $hours:$mins:$secs"
} else {
    return "$hours:$mins:$secs"
}

}

private getBatteryRuntimeInHours() {
def currentmillis = now() - state.energyMeterRuntimeStart
def days = 0
def hours = 0
def mins = 0
def secs = 0
secs = (currentmillis / 1000)
mins = (secs / 60)
hours = (mins / 60)
return hours
}

void logInfo(str) {
log.info str
}

void logWarn(str) {
log.warn str
}

void logError(str) {
log.error str
}

void logDebug(str) {
if (isLogLevelDebug) {
log.debug str
}
}

void logTrace(str) {
if (isLogLevelTrace) {
log.trace str
}
}

def nightLight() {
logDebug “in set nightlight mode”
sendEvent(name: “deviceMode”, value: “nightLight”, displayed: true)
setDeviceMode(2)
}

def energy() {
logDebug “in set energy mode”
sendEvent(name: “deviceMode”, value: “energy”, displayed: true)
setDeviceMode(0)
}

def momentary() {
logDebug “in momentary mode”
sendEvent(name: “deviceMode”, value: “momentary”, displayed: true)
setDeviceMode(1)
}

def setDeviceMode(mode) {
logTrace “set current mode to ‘$mode’”
formatCommand(zwave.configurationV1.configurationSet(parameterNumber: 0x51, size: 1, scaledConfigurationValue: mode))
}

def setBrightnessLevel(newLevel) {
logDebug “in set setlevel newlevel = ‘$newLevel’”
sendEvent(name: “brightnessLevel”, value: newLevel.toInteger(), displayed: true)

// There seems to have an error in the documentation where this config should be a size = 1
formatCommand(zwave.configurationV1.configurationSet(parameterNumber: 0x54, size: 3, configurationValue: [newLevel, newLevel, newLevel]))

}

def formatCommand(physicalgraph.zwave.Command cmd) {
if (isSecured()) {
logTrace “Formatting secured command: ${cmd}”
zwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()
} else {
logTrace “Formatting unsecured command: ${cmd}”
cmd.format()
}
}

def isSecured() {
(state.deviceInfo && state.deviceInfo[‘secureInclusion’]) || secureInclusionOverride
}

def internalCreateEvent(event) {
if (forceStateChangeOnReport) {
event.isStateChange = true
}

return createEvent(event)

}

Here is the Settings Page:

@CommanderQ , any possibility this change could be added?

Thank you for the code and the screenshot @damohabir - those are super helpful. So in the existing driver, the “Disable switch on / off” doesn’t affect the actual physical button behavior, but it does affect whether SmartThings attempts to turn the switch on or off, right? I want to make sure I’m reading the code correctly and that this reflects the desired behavior. :slight_smile: I also want to double check my understanding since the Smart Switch 7 supports this with a hardware flag and the Smart Switch 6 really doesn’t have a flag for this (which your code was super helpful in verifying).

As a thought, if I provided a driver that simply didn’t expose the switch capability at all for the Smart Switch 6 (but had all the other settings), would that be functionally equivalent? Since the Edge drivers are really easy to switch between, my thought is that a separate “energy monitor” driver for the switch could achieve the same result… :thinking: The caveat is that it wouldn’t report the switch status at all, but perhaps that’s acceptable and how the existing DTH works?

I’m very curious about your thoughts and ideas. :smile: It should be easy either way, though the separate driver without the switch capability would be super simple (if it’s something that seems viable).

@CommanderQ , that is interesting. You are correct, “Disable switch on/off” does NOT affect the physical button. That button can still turn the switch On or OFF. It just prevents the app from turning it on and off. It did work well with the DTH.

I probably would not use a driver that did not expose the switch capability. The reason is if someone does turn the switch on or off, I would want the app to reflect that. I use these switches on several devices (TV, refrigerators, etc), where I monitor the power and use the power for some automation, but I definitely don’t want them to be turned off accidentally. The existing DTH does reflect the state of the switch, in addition to preventing the app from controlling it.

Cool! Working on this now @damohabir . :smile: I have some code ready to test and - once I get it published - might I ask you to take it for a spin? I’m away from my own Smart Switch 6 at the moment, otherwise I’d test it myself…

1 Like

@damohabir I just pushed an updated driver to the channel for the Smart Switch 6 that has an “Always on Mode” for you to try out, if you would be so kind. :smile: Let me know if that works or needs adjustment and I can get that taken care of (much more quickly now).

I don’t see the new driver as yet. I will test as soon as i see it.

@CommanderQ , I am still not able to see an updated driver.

Hmmm… It should be there - I see version “2022-11-19T07:40:14.115392365” listed. I did change the profile, though, and I’ve had to uninstall and re-install drivers on my hub to pick up some changes when they involved the profile. Can you give that a shot and see if it picks up?

I unpaired the device, and removed the driver from the hub. When I added the driver back, it is still Version 2208-08-03T07:18:14

I even unenrolled, and re-enrolled to the channel, but it is still picking up the older version.

Sorry for the delay - it took me a bit to step through the driver publishing steps again. You should see the updated driver now (I neglected to assign the updated driver to the channel); I’m eager to know how it works out. :smile:

I have 2 Aeotec Smart Switch 6s (AU version) connected with this driver, and neither shows power consumption in anywhere near real time. It only updates when I turn the device on or off, and even then seems to show the previous power consumption state.

E.g, I have a lamp connected to the plug, and when the switch is on it more often than not shows 0W. If I turn the smart switch off, the power consumption will show 30W, and stay that way despite being off. Both plugs operate in the same manner.

Hi @CommanderQ , the new driver was pushed to my hub, so thank you.
Unfortunately I am no longer able to control On/OFF independent of which state I select in “Always On Mode”. In addition, if I manually turn the device ON or OFF from the switch, the status is not updated in the driver. It is always shown as ON.

Hi @RebelMagpie and @damohabir ,

Looks like I need to snag my Smart Switch 6 to experiment with the “Always On Mode” setting a bit more - I’ll have that available in about a week. In the interim, I updated the driver to remove the new “Always On Mode” which should mean the switch driver goes back to normal operation. I’ll take a fresh look at this shortly and figure out what subtlety is at play. :smile:

1 Like

Hi @CommanderQ

Thanks to create edge drivers for Aeotec devices! :blush:

I have the same problem as @RebelMagpie. I have 3 Aeotec Smart Switch Gen 6 (US Version), it does not show power consumption in anywhere near real time. It only updates when I turn the device on, off or refresh the main page, and even then seems to show the previous power consumption state.

Do you have any news about it?

Thanks!

1 Like

Are you still having issues using your smart switch 6 using the Aeotec Smart Switch 6 edge drivers? I also have the AU version of the Smart Switch 6. I haven’t switched to the aeotec smart switch 6 edge drivers yet but when my smart switch 6 migrated over to edge drivers it chose the SmartTthings Z-Wave Switch edge drivers. I mainly use the power meter and occasionally the energy consumption and havent had any issues. Just wondering if there is any added functionality other than energy consumption and power meter using the Aoetec Smart Switch 6 edge drivers?

Nothing has changed for new. They work fine as switches, but the power consumption readings are problematic.

oh ok. i’ll probably hold off in updating mine then. i primarily use the smart switch 6 with my washing machine to alert me once its finished by using the power consumption.

1 Like

Ha. That was exactly the reason I bought them, but unfortunately have proven completely useless for that purpose

You could try using the Z-Wave Switch edge drivers. Its been working ok so far for me on the Smart Switch 6.

Is there other functionality/features when using the Aeotec Smart Switch 6 edge drivers? The Z-Wave Switch edge drivers does what i need currently which is monitoring power meter and energy consumption. Just curious what added features I’ll get with using the Aeotec Smart Switch 6 edge drivers.