Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ metadata {
command "pair"
command "unpair"
command "whiten"
command "nighten"
}

preferences {
Expand Down Expand Up @@ -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"])
}
}

Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions smartapps/fireboy1919/milight-light.src/milight-light.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this isn't actually autoassigned (because I couldn't figure out a way to do that after an hour or so of looking), this is actually needed, and the app was throwing exceptions when I didn't require it. So this would produce a bug.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess i felt like if something were optional, it shouldn't be required... :)

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"
}
}
}
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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}" }
Expand Down