Device type for MiLight / EasyBulb / LimitlessLED Wifi controller

@Will_Hogg I was doing work on the code today and the 500 error is the result of me. I have hopefully fixed this bug, can you please tell me if you are having success?

I now get the below output from live logging
d0f0191c-f8ab-4923-99c8-35844d83d4ff 07:07:51: debug resp data: [status:success, action:rgbw, group:0, option:on]
d0f0191c-f8ab-4923-99c8-35844d83d4ff 07:07:50: debug My path: rgbw/on
d0f0191c-f8ab-4923-99c8-35844d83d4ff 07:07:50: debug Device setOn
d0f0191c-f8ab-4923-99c8-35844d83d4ff 07:07:50: debug resp data: [status:success, action:rgbw, group:0, option:off]
d0f0191c-f8ab-4923-99c8-35844d83d4ff 07:07:49: debug My path: rgbw/off
d0f0191c-f8ab-4923-99c8-35844d83d4ff 07:07:49: debug Device setOff

but nothing happens!? the light doesnt turn off or on
 :)pensive:

@Will_Hogg Hi Will, If you stick the hub back into udp mode for a sec can you switch on and off via the milight iphone/android app?

Hi @1bigwink Yes mate i can. What do you suggest?

@Will_Hogg The only thing I did notice is that in your Bridge config you are using the original MiLight IP address in your bridge protocol config. I honestly have no idea if that makes a difference, but mine is set to the IP of my Bridge. Try changing the value to TCP,Server,8899,192.168.0.20 (your Bridge IP). Also I’m curious; re your Bridge and SmartThings hub on the same subnet?

Also can you check your mode on the bridge is set to STA and confirm what the TCP timeout value is set to?

I’ve made that change but it still isn’t turning off the bulb. See below config:-

Output from live logging
0f0191c-f8ab-4923-99c8-35844d83d4ff 08:58:13: debug resp data: [status:success, action:rgbw, group:0, option:on]
d0f0191c-f8ab-4923-99c8-35844d83d4ff 08:58:13: debug My path: rgbw/on
d0f0191c-f8ab-4923-99c8-35844d83d4ff 08:58:13: debug Device setOn
d0f0191c-f8ab-4923-99c8-35844d83d4ff 08:58:09: debug resp data: [status:success, action:rgbw, group:0, option:off]
d0f0191c-f8ab-4923-99c8-35844d83d4ff 08:58:09: debug My path: rgbw/off
d0f0191c-f8ab-4923-99c8-35844d83d4ff 08:58:09: debug Device setOff

Config from LimitlessLED

To re-iterate - If I set the bridge back to UDP - it controls the bulb no problem via the MiLight App. As soon as I change the bridge back to TCP - neither the app nor ST works.

Sounds identical to what you were experiencing @1bigwink

Also @1bigwink - Yes the ST hub is on the same subnet as the MiLights hub.

@hamishahern Hi Hamish - I am trying to troubleshoot my ST / MiLight setup and was wondering whether there was anyway I could view logs on the wifi bridge to see whether the ST hub is communicating with it?

@Will_Hogg So strange, those messages are pretty much what I get so it seems the call was successful. My TCP timeout is set to 500, when I set to 300 it didn’t always work (maybe a coincidence) but 500 works faultlessly. I would guess your router is blocking inbound requests - try disabling all firewalls/protection etc on your router (including port scan protection etc, everything) temporarily. It seems the requests are getting to Jared’s cloud server ok (hence messages) but just not back in. Let me know how you get on bud. If it transpires it is your router then you could put the ST hub into a DMZ, open the relevant ports or do some port forwarding.

Thanks @1bigwink - I have changed the timeout to 500 but sadly it still doesnt work. I am not aware of my router blocking things - but at least it gives me another avenue to continue my investigation - thank you.
It’s curious that my symptoms are seemingly identical to those you were experiencing - what was stopping yours frm working? Would you mind comparing my screenshots to your set up to see if there are any differences?

@Will_Hogg Hi Will, Mine was a combination of things (a small bug on Jared’s server (now fixed so shouldn’t affect you), me not selecting a hub in graph, some settings not saving 1st time when I SET on the bridge & the incorrectly formatted mac). Throughout all of this though I never got the success message that you are getting. From what I can see the the request is managing to get from the smartthings server to Jareds cloud server (hence success message) but just not back into your LAN. If you have the port blocked, a firewall set or your router see’s it as a scan or attack (as can often be the case) then it will likely block the request - particularly on thos ‘non-standard’ ports that are normally blocked by default on some routers anyway. What router do you have?

RE screenshots yeah no problem, although I won’t be home till a bit later today, but all looks good your end from what I can see. The fact that the app works and you are getting success messages tells me that your bridge config is ok - and I think your ST too. If Jared can’t confirm an issue on his cloud server then I would bet it’s a routing/firewall issue.

@1bigwink I have tried disabling the firewall but alas it still isnt working. Am struggling with where to go next now :frowning:

@Will_Hogg Are you able to check the logs on the router to see if you can sniff out any requests passing through? Also when you change the settings on the bridge are you doing a restart each time - failing that can you try a manual power cycle (off for 10 secs then back on) on the bridge and your ST hub. When you set up your device type did you change any code at all?

Post the code from your device type if you can and PM me your public IP so I can check your open ports.

/**

  • MiLight / EasyBulb / LimitlessLED Light Controller
  • Copyright 2015 Jared Jensen / jared /at/ cloudsy /dot/ com
  • 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.

*/
metadata {
definition (name: “MiLight Controller”, namespace: “cloudsyjared”, author: “Jared Jensen”) {
capability "Switch Level"
capability "Actuator"
capability "Switch"
capability "Color Control"
capability “Polling”

    capability "Refresh" 
    
    command "setAdjustedColor"
}

preferences {       
   input "mac", "string", title: "MAC Address",
             description: "The MAC address of your MiLight bridge", defaultValue: "DE:AD:BE:EF:CA:FE",
          required: true, displayDuringSetup: true 
   
   input "group", "number", title: "Group Number",
             description: "The group you wish to control (0-4), 0 = all", defaultValue: "0",
          required: true, displayDuringSetup: true
   }

tiles(scale: 2) {
    multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
        tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
            attributeState "on", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821", nextState:"off"
            attributeState "off", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"on"
        }
        tileAttribute ("device.level", key: "SLIDER_CONTROL") {
            attributeState "level", action:"switch level.setLevel"
        }
        tileAttribute ("device.color", key: "COLOR_CONTROL") {
            attributeState "color", action:"setAdjustedColor"
        }
    }

    main(["switch"])
    details(["switch","levelSliderControl", "rgbSelector"])
} 

}

// handle commands
def setLevel(percentage) {
log.debug "setLevel ${percentage}"
if (percentage < 1 && percentage > 0) {
percentage = 1 // clamp to 1%
}

def path = buildPath("rgbw/brightness", percentage, group);

return httpCall(path);

}

def setAdjustedColor(value) {
log.debug “setAdjustedColor: ${value}”

int r = value.red
int g = value.green
int b = value.blue

def path = buildColorPath(r, g, b, group);

return httpCall(path);

}

def on() {
log.debug "Device setOn"
def path = buildPath(“rgbw”, “on”, group);

return httpCall(path);

}

def off() {
log.debug “Device setOff”

def path = buildPath("rgbw", "off", group);

return httpCall(path);

}

private buildPath(option, value, grp = 0) {
def path = “”

if(grp == 0 || grp == null) {
    path = "$option/$value"
} else {
    path = "$option/$value/$grp"
}

log.debug "My path: $path"

return path;

}

private buildColorPath(red, green, blue, grp = 0) {
def path = ""
def value = “”

value = "rgbw/color/r/$red/g/$green/b/$blue"

if(grp == 0 || grp == null) {
    path = "$value"
} else {
    path = "$value/$grp"
}

log.debug "My path: $path"

return path;

}

private httpCall(path) {
def params = [
uri: ‘http://lights.cloudsy.com:9292/v1/’,
path: “$path”,
contentType: ‘application/json’,
headers: [MAC:"$mac"]
]
try {
httpGet(params) {resp ->
log.debug “resp data: ${resp.data}”
}
} catch (e) {
log.error “error: $e”
}
}
above is the code I have used for the device. I don’t remember changing anything - famous last words


I have tried powering off router but still nothing. Current set up is as per my previous posts - only difference is the timoeut value is now 500.

Thanks again for your help mate! really appreciate it!

What is your MAC address

AC:CF:23:50:77:BA @jared

do you have the rgbw bulbs or the white bulbs

RGBW bulbs @jared
Can you see my MAC address?

Yes, my code is sending your hub commands.

[2015-12-02T09:54:15] INFO: WebAPI/MAC: AC:CF:23:50:77:BA, LIGHTS OFF, GROUP: 0
[2015-12-02T09:54:15] INFOl: TCPServer/MAC: AC:CF:23:50:77:BA, sending QQBV

good stuff @jared - at least that narrows down the issue some what. Thank you.