Hubitat allows for opening and maintaining a connection to a telnet endpoint from the hub. All code needs to be contained in a driver; there is no option to open a telnet connection from an app. Hubitat provides methods to connect and disconnect to the endpoint. In addition, it is required to create a method in the driver that accepts incoming messages (parse) and another method that will be called with any status updates for the endpoint (telnetStatus).
void telnetConnect(Map options, String ip, int port, String username, String password)void telnetConnect(String ip, int port, String username, String password)ip - The IP Address of the endpoint you want to connect toport - The port number of the endpoint, typically 23 for telnet interfacesusername - The username to use to log in, pass null if no username is requiredpassword - The password to use to log in, pass null if no password is requiredoptions - Optional; a Map of options to use when connecting to the telnet interface. Possible values:
reuseExisting - possible values: true, false. If true, keeps an existing telnet interface instead of recreating it.usernamePrompt - The text that marks the username prompt. Defaults to "ogin:".passwordPrompt - The text that marks the password prompt. Defaults to "assword:".byteInterface - possible values: true, false. If true, messages are handled as byte arrays and will be hex string encoded. Defaults to false.termChars - A List of character codes appended by the terminal interface. Defaults to [13, 10] (carriage return and line feed).ignoreList - A List of output fragments to be filtered out by the telnet interface.terminalType - The terminal type sent during telnet negotiation.multiThread - possible values: true, false. Selects multi-threaded processing. Defaults to false.persistentMessages (since 2.2.6) - possible values: true, false. Retains queued outgoing messages across reconnects. Defaults to false.asyncConnect (since 2.2.6) - possible values: true, false. Sets up the connection asynchronously. Defaults to false.secureSocket (since 2.5.1) - possible values: true, false. Use TLS.ignoreSSLIssues (since 2.5.1) - possible values: true, false. Ignores certificate issues for TLS connections.caCertificate (since 2.5.1) - The CA certificate, in PEM format, used to validate the server.certificate (since 2.5.1) - The client certificate, in PEM format, for TLS authentication.privateKey (since 2.5.1) - The private key, in PEM format, paired with the client certificate.tlsVersion (since 2.5.1) - The TLS protocol version to request.void telnetClose()
Methods with the following signatures must be provided in your code and will be called as described.
parse(String message) - This method is called with any incoming messages from the telnet endpoint. This is a standard method for drivers.telnetStatus(String message) - This method is called with any status messages from the telnet connection (disconnections, errors during connect, etc)