Skip to content

Commit 0d14665

Browse files
committed
Switch to hub commands.
1 parent d9c3102 commit 0d14665

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

devicetypes/fireboy1919/milight-controller.src/milight-controller.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ metadata {
2828

2929
preferences {
3030
input "ip", "string", title: "IP Address",
31-
description: "The IP address of this MiLight bridge", defaultValue: "The MAC address here",
31+
description: "The IP address of this MiLight bridge", defaultValue: "The IP address here",
3232
required: true, displayDuringSetup: false
3333
/*
3434
input "port", "string", title: "Port number",

smartapps/fireboy1919/milight-manager.src/milight-manager.groovy

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,31 @@ def initialize() {
4848
}
4949
}
5050

51-
def httpCall(body, uri, mac, evt) {
52-
def group = evt.device.getPreferences()["group"]
53-
def path = "$uri/gateways/$mac/rgbw/$group"
51+
private String convertIPtoHex(ipAddress) {
52+
String hex = ipAddress.tokenize( '.' ).collect { String.format( '%02x', it.toInteger() ) }.join()
53+
log.debug "IP address entered is $ipAddress and the converted hex code is $hex"
54+
return hex
55+
}
5456

55-
log.debug("Sending to ${params['uri']}${path}.")
57+
def httpCall(body, host, mac, evt) {
58+
def group = evt.device.getPreferences()["group"]
59+
def path = "/gateways/$mac/rgbw/$group"
60+
path = "google.com"
61+
log.debug("Sending to ${path}.")
5662
try {
63+
def hubaction = new physicalgraph.device.HubAction(
64+
method: "PUT",
65+
path: path,
66+
body: JsonOutput.toJson(body),
67+
headers: [ HOST: convertIPtoHex(host), "Content-Type": "application/json" ]
68+
)
69+
/*
5770
httpPut(path, JsonOutput.toJson(body)) {resp ->
5871
if(settings.isDebug) { log.debug "Successfully updated settings." }
5972
//parseResponse(resp, mac, evt)
6073
}
74+
*/
75+
sendHubCommand(hubAction);
6176
} catch (e) {
6277
log.error "Error sending: $e"
6378
}

0 commit comments

Comments
 (0)