iTach Integration

New to smartTHings. Newb question. I want to control my multi-media equipment with an IP2IR iTach device. I can send the “sendHubAction” command with the proper code inside a Device Handler in simulate mode (IDE which works) however i guess i am not sure of the overall architecture here. My intent is to use an Amazon Echo with voice command for on an off capabilities. Do i need a smartapp? Can I use just a virtual switch and then use the same action in the Device Handler? It does not appear to work. It seems I must have a device in order for the Echo to see it. Any advice or comments would be appreciated.

thanks much

Two separate questions.

The echo integration is easy because, yes, you can use virtual switches. The trick is then to tie that virtual switch to something that triggers the other device. You can just subscribed to that switches advance if you want, that is usually the easiest way if you’re writing your own code.

The following is a clickable link to the project topic in which I described using the echo to control how many activities via IFT TT. Your “man in the middle” will be your own smart app instead, but the same logic applies as far as how the virtual switches are used with echo, so it may be of interest.

As far as working when Itach, many community members do that through the Wi-Fi interface. Just search the forums for those topics. That should give you some more ideas. Here’s one that discusses several different options. Again, you may do years differently because you’re doing your own coding, but this might still be of interest.


thanks much for the reply. Can you clarify your statement about the virtual switches? You say the trick is to then tie the virtual switch to something that triggers the other device. Not clear on that. So a virtual switch is a device correct? Why does it need an additional device? Can’t i just say or push a button for the virtual switch (on or off) which then invokes the device handler? Am i off the track? :slight_smile: thank you again.

The virtual switch by itself does nothing except change of state from on to off. So something has to subscribe to that in order to affect anything else, even if it’s a smartapp that is Then going to send a command to the itach.

Amazon echo doesn’t control any switches itself either, it just sends a request to The controller of record (in this case Smartthings) to do something with the device.

So you tell echo to turn on the virtual switch, echo requests that Smartthings do so, Smartthings turns on the virtual switch, and something subscribes to that switch event.

If you’re just using the standard mobile app, then the something might be a routine or one of the officially published smartapps.

There’s also a very nice community created smart app called “Alexa helper” which let you associate a virtual switch with a routine or a mode change. Just to make it easy for nonprogrammers.

As a programmer, you can write your own smart app and have it subscribe to the switch events. :sunglasses:

JDRoberts, Ok…I will give it a try. I did have a look at the “Alexa Helper” app but that seems to be a bit of overkill with a mode/routine change etc… I think the piece i was missing was the on/off event. I assumed that in the ON function i could just call sendhubaction and have it work. This implies that something actually then needs to listen to the ON event (one more step). I am writing my own code so I will give it a try. Thank you again for you reply. I really appreciate it.

I rely on text to speech (I’m quadriparetic with limited hand function), so I don’t read code these days. (Groovy is not compatible with text to speech.) So hopefully some of the expert coders can help with more questions.

I just thought if you looked at the code from Alexa helper you should be able to see how virtual switch events are being processed. :sunglasses:

JDRoberts, i agree…learning by example is the best way! So if you use a SmartApp, doesn’t it have to be running somewhere to capture the event? (phone, etc…). Can you invoke or call a smartapp? See my point? How would Alex–>phrase–SmartHub—>device work with a smartapp if it has to be running. Do smartapps run in the background all the time?

Smart apps do not run all the time, but if they subscribe to a switch event they will get kicked on when the event occurs. That’s the point of the subscription. Again, the coders can tell you more.

No, they actually can’t SmartThings kills any app that runs for longer than ~20sec. Smartapps are triggered to run by subscribing to events (temp change, time of day, door unlock, window open, movement) the smart app will do its thing and go back to sleep till its triggered again.

1 Like


thanks much. I’ll give it a try!


in the smartapp, does the name of the switch correlate to device switch name?


heads up on hubAction, you can call this from a device, and that device (if it’s a switch) could then be visible to and controlled by the echo.
However hub action can’t deal with extended ascII (> int 127), they get “translated” into two bytes.
So hopefully all the commands you need are contained within the standard ascII character set.

1 Like


I think I’m good with the character set <127. How do you call it from a device? I tried in a device handler but it only works in simulate mode.



actually i’m sending raw data through hubaction with not issues.

in a device?, or a smartApp…

first in a Dev Handler which worked in simulate mode but not with a real device and then from a smartapp. How would i do this from a device?

	use the following to generate the actual device ip address and port in hex
	the resulting string needs to be assigned to your device's "device network id" (under my devices) in the IDE

def makeNetworkId(ipaddr, port) { 
	 String hexIp = ipaddr.tokenize('.').collect {String.format('%02X', it.toInteger()) }.join() 
     String hexPort = String.format('%04X', port.toInteger()) "${hexIp}:${hexPort}" 
\\example call
def unmute(){
	sendEvent(name: "switch", value: "unmuted")
	def msg = "whatever to send here\r\n"		\\  \r\n = crlf
    def ha = new physicalgraph.device.HubAction(msg,physicalgraph.device.Protocol.LAN, device.deviceNetworkId)
    return ha

There may be other ways, but I have gotten this to work.

So i hard coded the DeviceNetworkId in the hubaction call but did not associate it with the device in the device definition in the IDE…does that work for a virtual switch? thanks much.

Not sure you’re going to get this to work in the IDE with a virtual device.
It may work in the IDE if the device is already setup in my devices, and then you point the IDE to that.

I don’t usually test devices in the IDE, I create the device in my device list, using my published device type.
Once you do that, updating the device in the IDE and publishing it again allows you to test changes immediately.

Inserting the devicenetworkid in the hub action call does nothing in a device type.
The only way this works is with a device in my devices that has the device network ID filled out as I mentioned.
And to make life more fun, device.deviceNetworkid is not run time editable from the device.

Good/Bad/indifferent or screwed up, it is what it is.
making these types of calls from a device type isn’t supported to my knowledge, and it isn’t documented…

ya. I did try it with my published device type but did not have the device network id specific for the device in the definition. just the call. I’ll give that a shot. thanks.