SmartApp Executing Twice

I have a very basic SmartApp that sends a couple of infrared commands to my TV via the Global Cache IP2IR device. The SmartApp was working fine performing many different commands until recently. Now whenever my SmartApp runs, it executes all commands twice, and therefore sends multiple IR commands in a sequential order. Instead of sending 4-pause-8, I get 4-pause-8-4-pause-8. I cannot be the only person experiencing this. Anyone else out there!?


def A = “sendir,1:2,1,37764,1,1,171,171,21,64,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,64,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,64,21,64,21,21,21,64,21,64,21,64,21,64,21,1776\r"
def B = “sendir,1:2,2,37764,1,1,171,171,21,64,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,64,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,64,21,21,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,64,21,21,21,21,21,64,21,64,21,64,21,64,21,1776\r"
sendHubCommand(new physicalgraph.device.HubAction(””"$A\r\n""", physicalgraph.device.Protocol.LAN, “${deviceNetworkId}”))
sendHubCommand(new physicalgraph.device.HubAction("""$B\r\n""", physicalgraph.device.Protocol.LAN, “${deviceNetworkId}”))

Maybe a ghost instance didn’t fully delete? I hear support can help with that.

Thanks Brian. I had reached out to support and they couldn’t see anything wrong, but I’m trying again with your terminology. Much appreciated.


If you look at live logging do you see the duplicates being sent out?

There may be an issue with you smartApp executing multiple commands, not sure why.

I was able to perform a packet capture and was a little wrong in my assumptions. When I send the button 4-pause-8, it actually only repeats the last command and sends 4-pause-8-delay-8. I added debugs after each command in my SmartApp and do not see the debug messages outputting twice. I believe the commands are only being sent once to the Hub, and the hub is then repeating the last command sent over the LAN once all the commands from the SmartApp have been sent. This must be some kind of bug in the Hub itself. Support sees nothing wrong, which would make sense if the issue is actually on the Hub LAN command side. The cloud piece probably is working fine.

I had something similar when multiple hubcommands were sent quickly (e.g. by lighting automation to multiple devices) i saw dual commands appearing. I first introduced a pause of 1000 , that did not work, when 2000 it worked and the dual commands disappeared…do not know if related, but maybe worth a shot…

Hi Twelso,

I am looking to integrate a Global Cache iTach IP2IR device but I am reasonably new to ST. I have the hub but wondered if you could share your full code with me to see how I can achieve the following:

  1. Turn on TV with Sat Receiver and AMP on the correct channels
  2. Turn on as above but for a Kodi/Android box
  3. Again, the same for a PS4 (but this maybe more tricky)

If I could look at your code I could have a good crack at changing it for my own set up.



I use the following with the IP2IR device to:

  1. Turn on Bose Audio Bar
  2. Turn on Sharp TV
  3. Turn on FIOS DVR

I had to use a device handler that would turn a ON/OFF switch into a pushbutton switch because my devices don’t have separate IR codes for ON and OFF. I had to toggle instead.

preferences {

section(“When this switch is turned on, send the command.”) {
input “button”, “capability.momentary”, title: “Which button?”, required: true

def installed() {
log.debug "Installed with settings: ${settings}"

def updated() {
log.debug "Updated with settings: ${settings}"

def initialize() {
subscribe(app, pushHandler)
subscribe(button, “momentary.pushed”, pushHandler)

def pushHandler(evt) {
def deviceNetworkId = “C0A801C8:1386” // converted to hex
def theAudio = “sendir,1:3,1,38109,1,1,343,171,21,22,21,65,21,22,21,65,21,65,21,65,21,22,21,65,21,22,21,22,21,22,21,22,21,22,21,65,21,22,21,65,21,22,21,22,21,65,21,65,21,22,21,22,21,65,21,22,21,65,21,65,21,22,21,22,21,65,21,65,21,22,21,65,21,1569\r"
def theTV = “sendir,1:1,5,38109,1,1,10,70,10,29,10,29,10,29,10,29,10,29,10,70,10,70,10,29,10,70,10,29,10,29,10,29,10,70,10,29,10,1759,10,70,10,29,10,29,10,29,10,29,10,70,10,29,10,29,10,70,10,29,10,70,10,70,10,70,10,29,10,70,10,1679\r"
def theCable = “sendir,1:2,1,38109,1,1,341,172,18,86,18,172,18,86,18,172,18,86,18,86,18,86,18,86,18,86,18,86,18,86,18,86,18,86,18,172,18,172,18,86,18,1290,341,86,18,3361,341,86,18,3361,341,86,18,3800\r"
sendHubCommand(new physicalgraph.device.HubAction(”””$theAudio\r\n""", physicalgraph.device.Protocol.LAN, “C0A801C8:1386”))
sendHubCommand(new physicalgraph.device.HubAction("""$theTV\r\n""", physicalgraph.device.Protocol.LAN, “C0A801C8:1386”))
sendHubCommand(new physicalgraph.device.HubAction("""$theCable\r\n""", physicalgraph.device.Protocol.LAN, “C0A801C8:1386”))

Thank you James. I managed to get it going in the end with something i am sure was quite similar.

I am seeing that the request is being made twice (from the server perspective) when the send hub command is only being called once. When I debug the smart app, I have logging statements around the sendhubcommand. It only gets called the one time, but on my local server I see the request being duplicated. Seems like some type of hub issue to me.