So here is what I have so far, however it never seems to connect via Telnet. Nothing is ever logged from the parse() routine. This is my first attempt at using the new Telnet Capability in Hubitat, so I am sure I am doing something wrong.
@bravenel - Bruce, can you take a look and provide me with a hint on what to change? Have you tested the telnet capability with a Raspberry Pi yet? Any special things to be aware of? When I click Save on the Device Details page, it tries to connect via Telnet, however my Chrome browser shows the web page constantly being loaded (spinning activity indicator on the tab for the device.)
/**
*
* File: Alexa_TTS_Driver.groovy
* Platform: Hubitat
* Modification History:
* Date Who What
* 2018-08-26 Dan Ogorchock Original creation for Hubitat
*
* Copyright 2018 Dan Ogorchock
*
* 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.
*
*
*/
def version() {"v0.1.20180826"}
preferences {
input "ip", "text", title: "RPi IP Address", description: "IP Address in form '192.168.1.142'", required: true, displayDuringSetup: true
input "port", "text", title: "RPi Telnet Port", description: "port in form of '23'", required: true, displayDuringSetup: true
input "username", "text", title: "RPi Username", description: "username in form of 'pi'", required: true, displayDuringSetup: true
input "password", "text", title: "RPi Password", description: "password in form of 'raspberry'", required: true, displayDuringSetup: true
input "echoName", "text", title: "Echo Device Name", description: "Name of your echo in form of 'Kitchen'", required: true, displayDuringSetup: true
}
metadata {
definition (name: "Alexa TTS", namespace: "ogiewon", author: "Dan Ogorchock") {
capability "Speech Synthesis"
capability "Telnet"
}
}
def installed() {
initialize()
}
def updated() {
log.debug "Attempting to close Telnet session"
telnetClose()
initialize()
}
def initialize() {
state.version = version()
log.debug "Attempting to connect via Telnet - IP = ${ip}, Port = ${port.toInteger()}, Username = ${username}, Password = ${password}"
telnetConnect([termChars:[13,10]], ip, port.toInteger(), username, password)
//give it a chance to start
pauseExecution(1000)
}
def speak(message) {
def msg = '/home/pi/ha-alexa-tts/alexa_remote_control.sh -d "' + "${echoName}" + '" -e speak:"' + "${message}" + '"\r\n'
sendMsg(msg)
}
def sendMsg(String msg) {
log.debug "Sending msg = ${msg}"
return new hubitat.device.HubAction(msg, hubitat.device.Protocol.TELNET)
}
def parse(String msg) {
// process incoming telnet messages
log.debug "Telnet Parse = ${msg}"
}