Building a SmartApp and need quick help on a zwave command

I was looking to quickly leverage some code from a device handler I found to effectively turn an AEON Smart Switch into nightmode:
0x51 1 0 mode 0 - energy, 1 - momentary indicator, 2 - night light

the command they used in the device handler is - where mode is the integer value:
zwave.configurationV1.configurationSet(parameterNumber: 0x51, size: 1, scaledConfigurationValue: mode).format()

Trying to write a SmartApp leveraging the Sunrise, Sunset template to turn the AEON device mode nightlight mode and sunset. The input is defined as (sunriseOn):
preferences {
section (“At sunrise…”) {
input “sunriseOn”, “capability.switch”, title: “Turn night light on?”, required: false, multiple: true
input “sunriseOff”, “capability.switch”, title: “Turn night light off?”, required: false, multiple: true

How do I explicitly invoke that zwave command from a seperate function on the objects/Things that will be selected in the preferences sunriseOn selections?

This is the function I put together but I don’t understand how the device is set in context to the zwave command:
def setDeviceMode(mode) {
log.debug “Set current device mode to ‘$mode’”

// __HERE__ __HELP__
// This zwave syntax was copied from sample device handler for Aeon Switch
// I have no idea how this zwave command is getting applied to a particular device, ie I have 2 Aeon switches 
// and several other 'Things', where is the reference to the device as an object?
// this notation looks to generic. Note that it is from a device handler so the context is probably set
// automatically because it was a device handler. how is the SmartApp applying this to a specific 'Thing'?
zwave.configurationV1.configurationSet(parameterNumber: 0x51, size: 1, scaledConfigurationValue: mode).format()


I’m pretty sure you can’t execute zwave commands from a SmartApp.

If you want the device to do something that the Device Handler doesn’t support, you need to modify the Device Handler instead of creating a SmartApp.

The SmartThings documentation does a great job of explaining what SmartApps and Device Handlers are and how they interact.

thx for the reply

a point of clarity, I’m not trying to do something that the Device Handler doesn’t support. The Device Handler that I have created from the shared code is working flawlessly. What I’m trying to do is build an automation based on a Sunrise/Sunset event and was trying to leverage the wave command from the source code in the Device Handler as an example only.

In other words, the Device Handler has a line of code that I know works to change the AEON device mode to nightlight; and now I’m looking to automate the switching of the device mode through a customized SmartApp.

Also note, I am not trying to change the Hub mode I’m am looking to change the device mode of the AEON Switch from say Energy to Nightlight.

I find it odd that we wouldn’t be able to issue the same zwave command from a SmartApp that the framework allows in a Device Handler. Is that a fact/confirmed?

SmartApps select devices based on a capability and that capability defines the attributes and commands that can be used with that device. That level of abstraction allows developers to write SmartApps without knowing anything about the device and improves security.

SmartApps can execute commands that are not part of a capability, but it can’t send commands directly to the device. This is a fact that’s explained in the “Overview” section of the Device Handler documentation.

If the device handler doesn’t already have a public command that allows you to “change the device mode of the AEON Switch from say Energy to Nightlight”, you’re going to have to modify the device handler.

*** a light bulb just went off ***

think you gave me the lead i needed; let me try something out and revert back

got it to work; thanks a ton

Being my first dive into the SmartApps, it didn’t occur to me what the context was between the Device Handler and the SmartApp. Your last statement set me in the right direction; I originally had been trying port logic over when I should have been simply trying to invoke the command already defined in the Device Handler.

I had the object handle already from the preferences section and simply needed to call the function that was defined in the handler which contained the ZWave command in question.

Thanks again for the insight and leads

1 Like