Passing a string from a device to a smartapp along with the event itself - how?

(j w) #1

Quick question: I want to pass a string from my device to a smartapp when the device throws an event. How?

Long story; I’m so close to having my x10 integration working. However, one thing I need to do is pass the x10 module (such as A15) and command for the device (such as ON) to a smartapp I’m writing. I need something like the following event:

sendEvent(name: ‘x10commandExecuted’, value: ‘A15-On’)

I think I’m limited to the built-in events, because when I try to throw a custom event, it just gets ignored in the smartapp, even though i’m subsubscribing to the matching event name. So, if I have to use built-in events, then something like the following could work:

sendEvent(name: ‘switch’, value: ‘on’, attr: ‘A15-On’)

I’m pseudo-coding here because I’ve been trying every seemingly possible way to get it to work for the past 4 or 5 hours and can’t. I know there’s got to be some magic to making this happen (custom events that I don’t understand, attributes I can read from the device, SOMETHING)…

Can anyone help?

(Dan) #2

@johnwest80 I am not 100% sure that I can help, but I have been trying to deal with a similar problem using an Arduino Thing Shield, multiple custom Device Types, and a SmartApp to tie everything together. Feel free to look at my code at It may give you some tips for the one-to-many, many-to-one mappings…

I have numerous X10 modules still and would love to hear more about your approach to integrating X10 with SmartThings.

(j w) #3

For those wondering, you can create custom events. The problem was that duplicate event values don’t get sent, so I thought it wasn’t working. In other words, this works…

Device Type—
sendEvent(name: ‘customEvent’, value: ‘customValue’)

Smart App–
subscribe(xswitch, ‘customEvent’, customEventHandler, [filterEvents: false])

However, if you send the event multiple times with the same value, it won’t get sent to the smart app. Only changes in value get sent. I thought maybe filterEvents: false would fix this, but it doesn’t seem to. In order to work around this, I am appending the time in milliseconds to each event that’s sent. My smart app just removes it on its end.

Hope this helps someone else.

(j w) #4

@Dan, here’s a link to a post I just created regarding my x10 support.