diff --git a/devicetypes/fireboy1919/milight-controller.src/milight-controller.groovy b/devicetypes/fireboy1919/milight-controller.src/milight-controller.groovy index 9d4521a..3e1ba56 100644 --- a/devicetypes/fireboy1919/milight-controller.src/milight-controller.groovy +++ b/devicetypes/fireboy1919/milight-controller.src/milight-controller.groovy @@ -27,6 +27,7 @@ metadata { command "pair" command "unpair" command "whiten" + command "nighten" } preferences { @@ -67,9 +68,13 @@ metadata { standardTile("white", "device.switch", width: 2, height: 2, canChangeIcon: true) { state "default", label:"White", defaultState: true, action: "whiten", icon: "st.switches.switch.off" } + + standardTile("night", "device.switch", width: 2, height: 2, canChangeIcon: true) { + state "default", label:"Night", defaultState: true, action: "nighten", icon: "st.switches.switch.off" + } main(["switch"]) - details(["switch","levelSliderControl", "rgbSelector", "refresh", "pair", "unpair", "white"]) + details(["switch","levelSliderControl", "rgbSelector", "refresh", "pair", "unpair", "white", "night"]) } } @@ -117,6 +122,10 @@ def whiten() { sendEvent(name: "whiten", value: java.util.UUID.randomUUID().toString()) } +def nighten() { + sendEvent(name: "nighten", value: java.util.UUID.randomUUID().toString()) +} + def unknown() { sendEvent(name: "switch", value: "unknown") } @@ -151,7 +160,8 @@ def httpCall(body, ipAddress, code, group) { def ipAddress = getPreferences()['ipAddress'] def group = getPreferences()['group'] */ - def path = "/gateways/$code/rgbw/$group" + hexcode = convertToHex(code) + def path = "/gateways/$hexcode/rgbw/$group" def bodyString = groovy.json.JsonOutput.toJson(body) def ipAddressHex = convertIPtoHex(ipAddress) def port = convertToHex(80); diff --git a/smartapps/fireboy1919/milight-light.src/milight-light.groovy b/smartapps/fireboy1919/milight-light.src/milight-light.groovy index cb66567..aba72e9 100644 --- a/smartapps/fireboy1919/milight-light.src/milight-light.groovy +++ b/smartapps/fireboy1919/milight-light.src/milight-light.groovy @@ -35,8 +35,9 @@ def nameMiLights() { dynamicPage(name: "nameMiLights", title: "MiLight Wifi Hub Setup", uninstall: true, install: true) { section("Light") { input "miLightName", "text", title: "Light name", description: "i.e. Living Room", required: true, submitOnChange: false - input "code", "number", title: "Code", required: true, description: "Optional: will be autoassigned" + input "code", "number", title: "Code", required: false, description: "Optional: will be autoassigned" input "lightType", "enum", title: "Bulb Type", required: true, options: ['rgbw', 'cct', 'rgb_cct'], defaultValue: 'rgbw' + input "group", "number", title: "The group you wish to control (0-4), 0 = all", required: true, defaultValue: "1" } } } @@ -81,7 +82,7 @@ def initialize() { if(settings.code == null) { settings.code = parent.parent.incLights(); } - myDevice.setPreferences(["code": settings.code, "group":1, "lightType": settings.lightType ]) + myDevice.setPreferences(["code": settings.code, "group": settings.group, "lightType": settings.lightType ]) subscribe(myDevice, "switch.on", switchOnHandler) subscribe(myDevice, "switch.off", switchOffHandler) @@ -91,6 +92,7 @@ def initialize() { subscribe(myDevice, "pair", pairHandler) subscribe(myDevice, "unpair", unpairHandler) subscribe(myDevice, "whiten", whitenHandler) + subscribe(myDevice, "nighten", nightenHandler) log.debug("Subscribed") //subscribeToCommand(myDevice, "refresh", switchRefreshHandler) @@ -129,6 +131,11 @@ def whitenHandler(evt) { httpCall(body, parent.settings.ipAddress, settings.code, evt.device) } +def nightenHandler(evt) { + def body = ["command": "night_mode"] + httpCall(body, parent.settings.ipAddress, settings.code, evt.device) +} + def switchOnHandler(evt) { def body = ["status": "on"] //if(parent.parent.settings.isDebug) { log.debug "master switch on! ${settings.code} / ${evt.device.name}" }