IP Control of Amp - Looking for solutions

Threw together a simple Telnet driver you might be able use to test with:

Driver Code
 /*

 */


@SuppressWarnings('unused')
static String version() {return "0.0.0"}

metadata {
    definition (
        name: "Telnet Test", 
        namespace: "thebearmay", 
        author: "Jean P. May, Jr.",
        importUrl:"https://raw.githubusercontent.com/thebearmay/hubitat/main/xxxx.groovy"
    ) {
        
        capability "Telnet"

        command "connectTelnet"
        command "disconnectTelnet"

    }   
}

preferences {

    input(name: "ipAddr", type: "string", title:"IP Address", required: true)
    input(name: "portNum", type: "number", title: "Port Number", required: true)
}

@SuppressWarnings('unused')
def installed() {

}
void updateAttr(String aKey, aValue, String aUnit = ""){
    sendEvent(name:aKey, value:aValue, unit:aUnit)
}

def connectTelnet(){
    try{
        telnetConnect([termChars:[10]], ipAddr, (int)portNum, null, null)
    } catch (ex) {
        updateAttr("error", ex)
    }
}

def disconnectTelnet() {
    telnetClose()
}

def sendMsg(message) {
    sendHubCommand(new hubitat.device.HubAction("""$message\r\n""", hubitat.device.Protocol.TELNET))
}

def parse(message) {
    updateAttr("parsedMessage", message)
}

def telnetStatus(message){
        updateAttr("statusMessage", message)
}

Messages returned are not retained by the driver, but will display on the device page. Enter the IP address and port number, click on connect, and then type the command (-p 1, -p 0, etc) in the Send Message box and click it to send. Click disconnect when done.

2 Likes