Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * LiFX
- *
- * Copyright 2014 Josh Doehla / TechUnity
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
- * for the specific language governing permissions and limitations under the License.
- *
- */
- preferences {
- input("server", "text", title: "Server", description: "Server IP")
- input("port", "text", title: "Port", description: "Server Port")
- input("url", "text", title: "URL", description: "Server URL")
- input("group", "text", title: "Group", description: "Group # ('0' for all bulbs)")
- }
- metadata {
- definition (name: "MiLight", namespace: "DougWare", author: "Doug Eubanks") {
- capability "Switch"
- capability "Color Control"
- capability "Switch Level"
- capability "Configuration"
- capability "Color Control"
- capability "Color Temperature"
- }
- }
- simulator {
- }
- tiles {
- standardTile("offSwitch", "device.switch", width: 1, height: 1, canChangeIcon: true) {
- state "off", label:'Off', action:"switch.off", icon:"st.Lighting.light11", backgroundColor:"#bbbbbb"
- }
- standardTile("onSwitch", "device.switch", width: 1, height: 1, canChangeIcon: true)
- {
- state "on", label:'On', action:"switch.on", icon:"st.Lighting.light11", backgroundColor:"#ffffff"
- }
- controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 3, inactiveLabel: false)
- {
- state "level", action:"switch level.setLevel"
- }
- controlTile("rgbSelector", "device.color", "color", height: 3, width: 3, inactiveLabel: false) {
- state "color", action:"setColor"
- }
- main "offSwitch"
- details(["offSwitch","onSwitch","levelSliderControl","rgbSelector"])
- }
- def on() {
- httpGet("https://${settings.server}:${settings.port}/Milight/milight1.php?command=on&group=${settings.group}", successClosure)
- sendEvent(name: 'level', value: "100")
- }
- def off() {
- httpGet("https://${settings.server}:${settings.port}/Milight/milight1.php?command=off&group=${settings.group}", successClosure)
- sendEvent(name: 'level', value: "0")
- }
- def setLevel(value) {
- def levelDecimal = new BigDecimal(value)
- httpGet("https://${settings.server}:${settings.port}/Milight/milight1.php?command=brightness&group=${settings.group}&brightness=${levelDecimal}", successClosure)
- }
- def setColor(colormap) {
- httpGet("https://${settings.server}:${settings.port}/Milight/milight1.php?command=color&group=${settings.group}&color=${colormap.hex}", successClosure)
- }
- def successClosure = { response ->
- log.debug "Request was successful"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement