I was able to create a driver for controlling my iTach IP2IR device. I use this to turn on/off televisions. For now I create a separate driver for each channel (1 - 3) of the device. It's not elegant but it works.
/**
* iTach IP2IR Control Device Type for Hubitat
* Carson Dallum (@cdallum)
* Originally based on: Mike Maxwell's and Allan Klein's code
*
* Usage:
* 1. Add this code as a device driver in the Hubitat Drivers Code section
* 2. Create a device using iTach_IP2IR as the device handler
*
* 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.
*
*/
metadata {
definition (name: "iTach IP2IR (Family Room)", namespace: "cdallum", author: "Carson Dallum") {
capability "Initialize"
capability "Telnet"
capability "Switch"
}
}
// device commands
def on() {
log.debug "Powering On Family Room Television"
sendEvent(name: "switch", value: "on")
def msg = "sendir,1:2,1,38000,1,1,172,172,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,64,22,21,22,21,22,64,22,64,22,21,22,21,22,64,22,21,22,64,22,64,22,21,22,21,22,64,22,64,22,21,22,1820"
return new hubitat.device.HubAction("""$msg\r\n""",hubitat.device.Protocol.TELNET)
}
def off() {
log.debug "Powering Off Family Room Television"
sendEvent(name: "switch", value: "off")
def msg = "sendir,1:2,1,38000,1,1,173,173,21,65,21,65,21,65,21,21,21,21,21,21,21,21,21,21,21,65,21,65,21,65,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,65,21,65,21,21,21,21,21,65,21,65,21,65,21,65,21,21,21,21,21,65,21,65,21,21,21,1832"
return new hubitat.device.HubAction("""$msg\r\n""",hubitat.device.Protocol.TELNET)
}
// General App Events
def initialize(){
telnetConnect("192.168.1.xxx", 4998, null, null)
log.debug "Opening telnet connection"
}
def installed(){
initialize()
}
def updated(){
initialize()
}