current_bright <- 0.5; current_scene <- 2; const low_scene = 0; const high_scene = 3; const lowest_bright = 0.0; const highest_bright = 1.0; const bearer = "YOURBEARERIDS"; related_scenes <- [IFNEEDED+YOURSCENEIDSHERE]; function motion(data) { if(data.dir == "TAP") { server.log(data.count); //do something cool here (I did a custom animation) } if(data.dir == "FORWARD") { local request = http.put("https://api.lifx.com/v1/lights/group_id:YOURGROUPID/state", { "Authorization":"Bearer "+bearer, "content-type": "application/json" },http.jsonencode({"power": "on"}) ); local response = request.sendsync(); } if(data.dir == "BACK") { local request = http.put("https://api.lifx.com/v1/lights/group_id:YOURGROUPID/state", { "Authorization":"Bearer "+bearer, "content-type": "application/json" },http.jsonencode({"power": "off"}) ); local response = request.sendsync(); } if(data.dir == "LEFT") { current_bright -= 0.1; if(current_bright < lowest_bright) { current_bright = lowest_bright; } local request = http.put("https://api.lifx.com/v1/lights/group_id:YOURGROUPID/state", { "Authorization":"Bearer "+bearer, "content-type": "application/json" },http.jsonencode({"brightness": current_bright}) ); local response = request.sendsync(); } if(data.dir == "RIGHT") { current_bright += 0.1; if(current_bright > highest_bright) { current_bright = highest_bright; } local request = http.put("https://api.lifx.com/v1/lights/group_id:YOURGROUPID/state", { "Authorization":"Bearer "+bearer, "content-type": "application/json" },http.jsonencode({"brightness": current_bright}) ); local response = request.sendsync(); } } device.on("direction.sent", motion);