I wonder If this Is possible and some help much appreciated
I have a sat box that I can shut down using this driver. I've managed to cobble this together after much trial and error for me.
What I would would like to happen Is for the switch to turn back off after the shutdown command has been sent.
/**
*
* 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: "VUDUO2Shutdown", namespace: "Kev", author: "Kev Burr") {
capability "Initialize"
capability "Telnet"
capability "Switch"
attribute "Telnet", ""
attribute "Switch", ""
}
}
// device commands
def on() {
initialize()
log.debug "Send Shutdown"
sendEvent(name: "switch", value: "on")
def msg = "shutdown -h now"
log.debug "Sending msg = ${msg}"
sendEvent(name: "switch", value: "off")
sendHubCommand(new hubitat.device.HubAction("""$msg\r\n""", hubitat.device.Protocol.TELNET))
}
// General App Events
def initialize(){
telnetConnect([terminalType: 'VT100'], '192.168.1.20', 23, "root", null)
log.debug "Opening telnet connection"
}
def parse(String message) {
log.debug "parse: ${message}"
}