Created
September 30, 2021 09:46
-
-
Save LutfiTekin/fe0ffa361232d989ca072a90aadd0452 to your computer and use it in GitHub Desktop.
Control Lights with Gradle Build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//under project level gradle | |
classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.2' | |
//app level gradle under android {} | |
def put = new URL("http://[hue bridge ip]/api/[hue username key]/lights/[light number]/state").openConnection(); | |
def message = '{"on": true,"xy":[0.400,0.922]}' | |
put.setRequestMethod("PUT") | |
put.setDoOutput(true) | |
put.setRequestProperty("Content-Type", "application/json") | |
put.getOutputStream().write(message.getBytes("UTF-8")) | |
def postRC = put.getResponseCode() | |
println(postRC) | |
if(postRC.toString().equals("200")) { | |
println(put.getInputStream().getText()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment