sendEvent from SmartApp not working

I want to fire the event from the SmartApp with custom data to keep track of the action / workflow that caused this event. I tried using sendEvent after reading the docs:

http://docs.smartthings.com/en/latest/ref-docs/smartapp-ref.html#sendevent

Signature:

void sendEvent(Map properties)

void sendEvent(Device device, Map properties)

but its not working for me.

Here’s what I am doing: (I have two Cree bulbs)

def evtProp = [name: “switch”, value: “on”, data:[“CustomEventId”: “12345”], descriptionText: “turned on!”]

switches.each {
sendEvent(it, evtProp)
}

the following error occurs:

[error]: groovy.lang.MissingMethodException: No signature of method: script14636722357482134563699.isChildMessage() is applicable for argument types: (java.util.LinkedHashMap) values: [[name:switch, value:on, data:[CustomEventId:12345], …]]
Possible solutions: isChildMessage(java.lang.String)

if I try,

switches.each {
it.sendEvent(evtProp)
}

it gives the error

[error] java.lang.IllegalArgumentException: Command ‘sendEvent’ is not supported by device of type ‘Cree Bulb’. Supported commands: [on, off, poll, configure, setLevel, refresh]

and when I try:

switches.each {
evtProp[“Device”] = it
sendEvent(evtProp)
}

the code executes without giving any error but nothing happens.

So what am I missing here ?

1 Like

Same issue here, I’m interested in a solution to that problem

For those who would be interested in a workaround I’ve found :
You can use the method “sendLocationEvent” which is supposed to trigger location events, but in fact can raise any event type you would need.
To raise device related events, you will need the deviceId of the device itself, which is not supposed to be a problem if you can access to the deviceWrapper object that your “input” statement give.
You can use sendLocationEvent like this :
> sendLocationEvent(name:"switch", value:"on", data:[ . . .], descriptionText: "description you want", deviceId: :"the-128bit-device-identifier-here", source: "DEVICE", isStateChange:true)
The parameters “source” and “isStageChange” are necessary to trigger the event. The system is made not to propagate raised events if there is no state change
You have to understand that it will not make your device to switch on, but, it will propagate the event through your ZigBee network and trigger any smartapp that rely on this kind of event (through “subscribe” statements)

3 Likes

Wow… Love this, but… it really seems like a platform design violation and possible security vulnerability.
It is undocumented, right?

Comments @jody.albritton, @slagle, @dlieberman ?

Wow… Love this, but… it really seems like a platform design violation and possible security vulnerability.

It is, with this kind of method you can send spoofed events that look coming from devices but are not. These events are then catched by smart apps and can trigger undesired actions.

The documentation do not give access to this information (the use we can do of the source, hubId,locationId and deviceId attributes).

Smartthings team is aware of this issue

###This is really, really, really not good.

:scream: