Code by Scott שאול בן ישוע
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sha'ul ben Yeshua
Hubitat Public Repo
Commits
c300d9ef
Verified
Commit
c300d9ef
authored
Jan 25, 2020
by
Sha'ul ben Yeshua
🎗
Browse files
Fixed incorrect command name and added nut restart
parent
b77a5d00
Pipeline
#285
passed with stage
in 4 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
drivers/Send Telnet Command.groovy
View file @
c300d9ef
/*
/*
A simple driver that will run a command via telnet
Useful with Rpi's
...
...
@@ -25,7 +25,7 @@ metadata {
name:
"Send Telnet Command"
,
namespace:
"sgrayban"
,
author:
"Scott Grayban"
,
importUrl:
"http://sgrayban.borgnet.online:8081/hubitat-public-repo/
drivers/
Send%20Telnet%20Command.groovy"
importUrl:
"http://sgrayban.borgnet.online:8081/hubitat-public-repo/Send%20Telnet%20Command.groovy"
)
{
...
...
@@ -33,7 +33,9 @@ metadata {
capability
"Telnet"
capability
"Switch"
command
"Reboot Device"
command
"RebootDevice"
command
"PowerOff"
command
"RestartNut"
}
attribute
"Telnet"
,
"String"
...
...
@@ -42,7 +44,7 @@ metadata {
input
"ip"
,
"text"
,
title:
"Target System IP"
,
description:
""
,
required:
true
,
displayDuringSetup:
true
input
"port"
,
"text"
,
title:
"Target System Telnet Port"
,
description:
""
,
required:
true
,
displayDuringSetup:
true
input
"username"
,
"text"
,
title:
"Username"
,
description:
""
,
required:
true
,
displayDuringSetup:
true
input
"password"
,
"
text
"
,
title:
"Password"
,
description:
""
,
required:
true
,
displayDuringSetup:
true
input
"password"
,
"
password
"
,
title:
"Password"
,
description:
""
,
required:
true
,
displayDuringSetup:
true
input
name:
"logEnable"
,
type:
"bool"
,
title:
"Enable debug logging"
,
defaultValue:
true
}
}
...
...
@@ -68,13 +70,37 @@ def on() {
sendEvent
(
name:
"switch"
,
value:
"on"
)
def
msg
=
"sudo reboot"
if
(
logEnable
)
log
.
info
"Sending msg = ${msg}"
sendEvent
(
name:
"Command Sent"
,
value:
msg
)
sendHubCommand
(
new
hubitat
.
device
.
HubAction
(
"""$msg\r\n"""
,
hubitat
.
device
.
Protocol
.
TELNET
))
runIn
(
5
,
sendEvent
(
name:
"switch"
,
value:
"off"
))
}
def
reboot
(){
def
RebootDevice
(){
on
()
}
def
RestartNut
()
{
initialize
()
if
(
logEnable
)
log
.
info
"Send Reboot"
//sendEvent(name: "switch", value: "on")
def
msg
=
"sudo service nut-server restart"
if
(
logEnable
)
log
.
info
"Sending msg = ${msg}"
sendEvent
(
name:
"Command Sent"
,
value:
msg
)
sendHubCommand
(
new
hubitat
.
device
.
HubAction
(
"""$msg\r\n"""
,
hubitat
.
device
.
Protocol
.
TELNET
))
//runIn(5,sendEvent(name: "switch", value: "off"))
}
def
PowerOff
()
{
initialize
()
if
(
logEnable
)
log
.
info
"Send PowerOff"
sendEvent
(
name:
"switch"
,
value:
"on"
)
def
msg
=
"sudo poweroff"
if
(
logEnable
)
log
.
info
"Sending msg = ${msg}"
sendEvent
(
name:
"Command Sent"
,
value:
msg
)
sendHubCommand
(
new
hubitat
.
device
.
HubAction
(
"""$msg\r\n"""
,
hubitat
.
device
.
Protocol
.
TELNET
))
runIn
(
5
,
sendEvent
(
name:
"switch"
,
value:
"off"
))
}
def
parse
(
String
msg
)
{
if
(
logEnable
)
log
.
debug
"Telnet Response = ${msg}"
if
(
msg
==
"permitted by applicable law."
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment