Smartthings and iTach IP2IR Example Code?

Dear ST Community,

I am looking to do the following, create a button to Turn on my TV, Amp and Humax with one button on the ST App. Once this is achieved I want to be able to call out the command to Amazon’s Alexa. I have the following setup:

Devices:
Sony Bravia TV (Non IP, IR only)
Onkyo Amp (Non IP, IR only)
Humax Sat Receiver (Possibly IP and IR)

To bind this together I have an iTach IP2IR unit on the network (192.168.210.12)

On the IP2IR the following command will work to switch On the Onkyo Amp:
sendir,1:1,1,38000,1,1,342,171,21,21,21,63,21,21,21,21,21,63,21,21,21,63,21,63,21,63,21,21,21,63,21,63,21,21,21,63,21,63,21,21,21,21,21,21,21,63,21,21,21,21,21,21,21,21,21,21,21,63,21,63,21,21,21,63,21,63,21,63,21,63,21,63,21,1484,342,85,21,36

I believe in ST I need to add something like this:
sendHubCommand(new physicalgraph.device.HubAction("""$theCom\r\n""", physicalgraph.device.Protocol.LAN, “${deviceNetworkId}”))

The complete command should look like this (I think):
sendHubCommand(new physicalgraph.device.HubAction("""$sendir,1:1,1,38000,1,1,342,171,21,21,21,63,21,21,21,21,21,63,21,21,21,63,21,63,21,63,21,21,21,63,21,63,21,21,21,63,21,63,21,21,21,21,21,21,21,63,21,21,21,21,21,21,21,21,21,21,21,63,21,63,21,21,21,63,21,63,21,63,21,63,21,63,21,1484,342,85,21,36
\r\n""", physicalgraph.device.Protocol.LAN, “${0xC0A8D20C}”))

Where I am struggling is how to write this as a SmartApp, how will it show up? How will associate a button to it and how do I associate a name to the App.

Can anyone help by showing me an example program of this type, I am new to ST but I think if I can be shown once I will be able to get to grips with it?

Kind thanks in advance.

Did you search the forum at all? There are multiple Itach threads that should be of interest.

For example,

(I’ve moved yours to projects so you can get individual responses regarding your own set up and code.)

Hi JD,

I did but I needed a bit of personal guidance as there are a lot of gaps in my knowledge. I have created the following:

/**

  • Watch FreeSat
  • Copyright 2016 George Ghir
  • Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at:
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  • on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  • for the specific language governing permissions and limitations under the License.

*/
definition(
name: “Watch FreeSat”,
namespace: “george.ghir”,
author: “George Ghir”,
description: “SmartApp to turn on Sony TV, Humax STB, Onkyo Amp, all via iTach IPtoIR device.”,
category: “Convenience”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”,
iconX3Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”)

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

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

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

def initialize() {
subscribe(trigger, “switch.on”, switchOnHandler)
}

def switchOnHandler(evt) {
def deviceNetworkId = “C0A8D20C:1386"
def theCom = “sendir,1:1,1,38000,1,1,342,171,21,21,21,63,21,21,21,21,21,63,21,21,21,63,21,63,21,63,21,21,21,63,21,63,21,21,21,63,21,63,21,21,21,21,21,21,21,63,21,21,21,21,21,21,21,21,21,21,21,63,21,63,21,21,21,63,21,63,21,63,21,63,21,63,21,1484,342,85,21,3655\r"
sendHubCommand(new physicalgraph.device.HubAction(””"$theCom\r\n""", physicalgraph.device.Protocol.LAN, “C0A8D20C:1386”))

}

However, when I go into the ST app on my Windows Phone I see the ‘Watch FreeSat’ button under a menu called ‘Convenience’, however when I go into it, it asks me for ‘Which Switch’. However it only shows access to a Power Plug that I have and not a trigger button that I would expect?

I am trying to understand where i am going wrong.

KR

Okay, so I managed to get it working on the ST and iTach side by creating a Virtual Button named “FreeSat” and assigned it to the following code:

/**
 *  Watch FreeSat
 *
 *  Copyright 2016 George Ghir
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
definition(
    name: "Watch FreeSat",
    namespace: "george.ghir",
    author: "George Ghir",
    description: "SmartApp to turn on Sony TV, Humax STB, Onkyo Amp, all via iTach IPtoIR device.",
    category: "Convenience",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")


preferences {
section("When this switch is turned on, send the command.") {
input "trigger", "capability.switch", title: "Which switch?", required: false
}
}

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

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

def initialize() {
subscribe(trigger, "switch.on", switchOnHandler)
}

def switchOnHandler(evt) {
def deviceNetworkId = "C0A8D20C:1386"
def theCom = "sendir,1:1,1,38109,1,1,343,171,22,21,22,64,22,21,22,21,22,64,22,21,22,64,22,64,22,64,22,21,22,64,22,64,22,21,22,64,22,64,22,21,22,21,22,64,22,21,22,21,22,21,22,21,22,21,22,21,22,64,22,21,22,64,22,64,22,64,22,64,22,64,22,64,22,3810\r"
sendHubCommand(new physicalgraph.device.HubAction("""$theCom\r\n""", physicalgraph.device.Protocol.LAN, "C0A8D20C:1386"))

}

1 Like

The issue now is that I cannot get Alexa (Echo) to call trigger the Virtual Switch when I say “Alexa, turn on FreeSat”. Looking at the Alexa App I cannot see my Virtual Button there but I can see a ST Power plug that i own?

This is probably too obvious, but have you authorized echo to use that specific button?

Whenever you add a new device, you have to individually authorize it before echo can use it.

See step 10 in the following:

If you did that already, open up the Alexa app and see if the button shows up in your list of devices, and if so what device class it is. It’s also possible that you used a device class that echo doesn’t know what to do with.

JD - You are spot on. Once I re-authorised Alexa it started working! Thanks for your support, this is the first app that I have written but the power of Alexa with ST has really got me thinking! I was determined not to use IFTTT and it looks like I can. Thanks again for your support.

1 Like

this is a old thread:
I am a newbie to Smartthings:

How do you add the device iTach IP2IR to Smartthings to be able to use it like this?

I am ordering a Smartthings hub and have a iTach IP2IR already but not in use yet.
I have just purchased 2 Ring Flood lights and they came with free Eco dots from Best Buy, also purchased Amazon fireTV stick 4K.
I already have a Rind Door bell Pro installed.
I have linked the Eco to the fireTV stick and can say to Eco to show the door bell on the fireTV,

My issue is that I have the fireTV on HMDI 2 on the Samsung TV and need a Eco command to use the iTach IP2IR to switch the Samsung TV back to the Samsung TV input it was previously on.

Any assistance would be greatly appreciated
Thank you in advance
Scat