setLocationMode in Device Type possible?

I am trying to set the location mode in my device type.


gives me a groovy runtime error saying string cannot be used as parameter.

	def awayMode = null
	location.modes.each {
		log.debug "location modes: ${it}, id ${}"
    	if ( == "Away")
    		awayMode = it
	if (awayMode)

Trying to pass an argument of type Mode, gives me also a runtime error saying I cannot pass an argument of type ModeWrapper.

Any suggestions on what code to use?

@urman @Duncan can you give me hint? I tried this code too (should be similar to code above) and it gives me the same error. I am stuck.

def awayMode = location.modes.find {"Away")}

@psfunatyo Did you get this resolved? I am attempting to do something similar from a Device Type without luck.

Unfortunately not. The only way I can think of is to have a helper app which sets the mode on behalf of device type helper.

Interestingly, a device can send a mode event and all apps that subscribe to location event will get it, but it does not change the actual location mode. Try this:

sendEvent(name:"mode", value:"Away", description:"The mode is now 'Away'")

Just shows how inconsistent SmartThings API is.

1 Like

My guess is that this is a nasty bug feature that is technically allowing us to create “imposter” Events.

i.e., If a real mode change had occurred, then an Event with name:"mode" is valid. Otherwise, the platform should NOT permit this via any other method. That’s bad containerization.

IMHO: The sendEvent() method (and any other method that allows us to construct and send ad-hoc Events, such as the parse() method…), needs to have scope and security restrictions. Event names should be limited to the Attributes of a Capability – and, until no longer permitted, the ad-hoc additional Attributes declared in “SmartDevice Type.metadata{ attribute ... }” (and probably a limited set of globals, though I’d have to understand them in context and use cases).

…CP / Terry.

Very new to SmartThings, but I would like to be able to set the mode in a device type. Doesn’t seem to be possible, but I found this thread. Hoping someone can help me directly do this or suggest a workaround.

Why in a “Device Type” (Device Handler)… Example?

(Regardless, any Device Handler can issue an arbitrary Event, which, in turn, a SmartApp can be written to subscribe to and issue the Mode change command.)

I am using a SimpliSafe device type that someone in the community wrote. That device type allows you to set the alarm to “home” mode. I would like that to translate to a mode, such as going to bed, and have that mode trigger other actions (like turning out the lights).

1 Like

Paste a link to the code, please?

It may have an Attribute Event already, else it’s likely very easy to add one. Then a tiny SmartApp takes the next step of setting Location.mode and that can trigger lots…

Even at that, I am so new that I don’t even know how to get the SmartApp to react to the event. I’ve looked at the Input statement in Preferences to set that to the SimpliSafe device. Then I put a Subscribe in the install function (according to docs). I used the sendevent from this chain, but it doesn’t activat the SmartApp. I’m very new.

Here is the device type.

I understand the concept, just not clear how to subscribe to the event from the device type.

We’re off to a very good start. I’ll look at this within the next couple of days and suggest the next step to try or chat with you private message. Don’t worry… It will work without much more work!

Awesome. I look forward to learning more.

Seems that I made a simple mistake when I setup the sendevent command. I failed to provide the isStateChange: true value and the events were not being recognized outside of the Device Handler. Once I did this, I was able to get the events out to a small, companion SmartApp that took care of setting the Location mode.

This allows the SimpliSafe app to drive the location mode to do some fairly simple “lights on”, “lights off” type of activities to accompany the security system being turned on & off.

Reading the documentation paid off.


@Schreinco would you mind posting the code for the helper? Thank you!!!