Code by Scott שאול בן ישוע
Verified Commit f141cbb3 authored by Sha'ul ben Yeshua's avatar Sha'ul ben Yeshua 🎗
Browse files

New sample telnet driver

parent 8d5cd79c
Pipeline #208 passed with stage
in 3 seconds
...@@ -18,7 +18,13 @@ ...@@ -18,7 +18,13 @@
*/ */
metadata { metadata {
definition (name: "Send Telnet Command", namespace: "sgrayban", author: "Scott Grayban") definition (
name: "Send Telnet Command",
namespace: "sgrayban",
author: "Scott Grayban",
importUrl: "http://sgrayban.borgnet.online:8081/hubitat-public-repo/Send%20Telnet%20Command.groovy"
)
{ {
capability "Initialize" capability "Initialize"
capability "Telnet" capability "Telnet"
...@@ -50,6 +56,7 @@ def installed(){ ...@@ -50,6 +56,7 @@ def installed(){
def updated(){ def updated(){
log.info "Preferences updated" log.info "Preferences updated"
runIn(5,sendEvent(name: "switch", value: "off"))
} }
def on() { def on() {
...@@ -59,7 +66,7 @@ def on() { ...@@ -59,7 +66,7 @@ def on() {
def msg = "sudo reboot" def msg = "sudo reboot"
if (logEnable) log.info "Sending msg = ${msg}" if (logEnable) log.info "Sending msg = ${msg}"
sendHubCommand(new hubitat.device.HubAction("""$msg\r\n""", hubitat.device.Protocol.TELNET)) sendHubCommand(new hubitat.device.HubAction("""$msg\r\n""", hubitat.device.Protocol.TELNET))
runIn(2,sendEvent(name: "switch", value: "off")) runIn(5,sendEvent(name: "switch", value: "off"))
} }
def reboot(){ def reboot(){
on() on()
...@@ -83,3 +90,4 @@ def telnetStatus(String status){ ...@@ -83,3 +90,4 @@ def telnetStatus(String status){
sendEvent(name: "Telnet", value: "Connected") sendEvent(name: "Telnet", value: "Connected")
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment