Code by Scott שאול בן ישוע
Unverified Commit 56f4c44c authored by Stephan Hackett's avatar Stephan Hackett Committed by GitHub
Browse files

Added body and content type inputs

parent 76ed58ea
......@@ -31,6 +31,8 @@ metadata {
input(name: "devicePort", type: "string", title:"Device Port", description: "Enter Port of your HTTP server (defaults to 80)", defaultValue: "80", required: false, displayDuringSetup: true)
input(name: "devicePath", type: "string", title:"URL Path", description: "Rest of the URL, include forward slash.", displayDuringSetup: true)
input(name: "deviceMethod", type: "enum", title: "POST, GET, or PUT", options: ["POST","GET","PUT"], defaultValue: "POST", required: true, displayDuringSetup: true)
input(name: "deviceContent", type: "enum", title: "Content-Type", options: getCtype(), defaultValue: "application/x-www-form-urlencoded", required: true, displayDuringSetup: true)
input(name: "deviceBody", type: "string", title:"Body", description: "Body of message", displayDuringSetup: true)
}
}
......@@ -38,6 +40,10 @@ def parse(String description) {
log.debug(description)
}
def getCtype() {
map cType = ["application/x-www-form-urlencoded","application/json"]
}
def push() {
//toggle the switch to generate events for anything that is subscribed
sendEvent(name: "switch", value: "on", isStateChange: true)
......@@ -61,10 +67,11 @@ def off() {
def runCmd(String varCommand, String method) {
def localDevicePort = (devicePort==null) ? "80" : devicePort
def path = varCommand
def body = ""
def body = ""
if(deviceBody) body = deviceBody
def headers = [:]
headers.put("HOST", "${deviceIP}:${localDevicePort}")
headers.put("Content-Type", "application/x-www-form-urlencoded")
headers.put("Content-Type", deviceContent)
try {
def hubAction = new hubitat.device.HubAction(
......
Supports Markdown
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