[DEPRECATED] [PORT] Hue B Smart

It also might save a few clock cycles using JsonSlurper() with INDEX_OVERLAY as the JsonParserType rather than JsonSlurperClassic(). I tried it out some last night and it didn't crash anything, but I didn't get a chance to run it through a profiler to see how much faster it was -- I've never run debug/profilers on java/groovy code so I haven't had a chance to setup an environment for it yet.

@Collisionc @xap Finished re-installing and configuring Hue B Smart this morning. With the stock scenes removed it's definitely performing better for me. I still get a slow down periodically (probably during the scheduled refresh) but it's not as disruptive as before. I'd say the delay is only a few seconds now, not perfect, but MUCH improved.

@xap noticed this in my logs, don't know if it's a problem or something that should even be displaying with debug logging disabled. The two devices are hue white (2700k) groups.

dev:33452018-11-21 11:04:44.217 pm debugParsing (ignoring) 'mac:00178849D586, ip:c0a801c1, port:50, headers:SFRUUC8xLjEgMjAwIE9LDQpTZXJ2ZXI6IG5naW54DQpEYXRlOiBUaHUsIDIyIE5vdiAyMDE4IDA4OjA0OjQ0IEdNVA0KQ29udGVudC1UeXBlOiBhcHBsaWNhdGlvbi9qc29uDQpDb25uZWN0aW9uOiBjbG9zZQ0KQ2FjaGUtQ29udHJvbDogbm8tc3RvcmUsIG5vLWNhY2hlLCBtdXN0LXJldmFsaWRhdGUsIHBvc3QtY2hlY2s9MCwgcHJlLWNoZWNrPTANClByYWdtYTogbm8tY2FjaGUNCkV4cGlyZXM6IE1vbiwgMSBBdWcgMjAxMSAwOTowMDowMCBHTVQNCkFjY2Vzcy1Db250cm9sLU1heC1BZ2U6IDM2MDANCkFjY2Vzcy1Db250cm9sLUFsbG93LU9yaWdpbjogKg0KQWNjZXNzLUNvbnRyb2wtQWxsb3ctQ3JlZGVudGlhbHM6IHRydWUNCkFjY2Vzcy1Db250cm9sLUFsbG93LU1ldGhvZHM6IFBPU1QsIEdFVCwgT1BUSU9OUywgUFVULCBERUxFVEUsIEhFQUQNCkFjY2Vzcy1Db250cm9sLUFsbG93LUhlYWRlcnM6IENvbnRlbnQtVHlwZQ0K, body:W3sic3VjY2VzcyI6eyIvZ3JvdXBzLzEwL2FjdGlvbi9vbiI6ZmFsc2V9fV0='

dev:33402018-11-21 11:04:44.136 pm debugParsing (ignoring) 'mac:00178849D586, ip:c0a801c1, port:50, headers:SFRUUC8xLjEgMjAwIE9LDQpTZXJ2ZXI6IG5naW54DQpEYXRlOiBUaHUsIDIyIE5vdiAyMDE4IDA4OjA0OjQ0IEdNVA0KQ29udGVudC1UeXBlOiBhcHBsaWNhdGlvbi9qc29uDQpDb25uZWN0aW9uOiBjbG9zZQ0KQ2FjaGUtQ29udHJvbDogbm8tc3RvcmUsIG5vLWNhY2hlLCBtdXN0LXJldmFsaWRhdGUsIHBvc3QtY2hlY2s9MCwgcHJlLWNoZWNrPTANClByYWdtYTogbm8tY2FjaGUNCkV4cGlyZXM6IE1vbiwgMSBBdWcgMjAxMSAwOTowMDowMCBHTVQNCkFjY2Vzcy1Db250cm9sLU1heC1BZ2U6IDM2MDANCkFjY2Vzcy1Db250cm9sLUFsbG93LU9yaWdpbjogKg0KQWNjZXNzLUNvbnRyb2wtQWxsb3ctQ3JlZGVudGlhbHM6IHRydWUNCkFjY2Vzcy1Db250cm9sLUFsbG93LU1ldGhvZHM6IFBPU1QsIEdFVCwgT1BUSU9OUywgUFVULCBERUxFVEUsIEhFQUQNCkFjY2Vzcy1Db250cm9sLUFsbG93LUhlYWRlcnM6IENvbnRlbnQtVHlwZQ0K, body:W3sic3VjY2VzcyI6eyIvZ3JvdXBzLzIvYWN0aW9uL29uIjpmYWxzZX19XQ=='

Nope, that's nothing to worry about. However, it shouldn't be logged if debug logging is switched off. I suggest check if you are running the latest device drivers and double check your debug logging setting.

Hi folks

I have had a go at optimising the device polling so that it only polls the state of lights and groups. It should still discover scenes correctly when setting up.

I am not planning to do any more modifications to these drivers now. They work perfectly for me at the moment and my intent was just to cover the gap in functionality until HE natively supports scenes. I hadn't intended to build a competing driver.

Please feel free to fork the code if anyone wants to make further changes.

Cheers :smile:

I ended up finding out what was causing the latency issues on the hubitat driver:

tl;dr: Hubitat does some talking to their amazon server as each minute ticks over, and it looks like it is not setup to run via async. Because your version of hue doesn't automatically stick the hub to refresh at xx:xx:00, you are missing the 1-5 seconds where the hub is unable to send any network commands.

The amazon server is probably being used for either cloud access or alexa.

That's interesting. I guess Hubitat is polling for incoming messages hence synchronous maybe.

The biggest impact on the performance I've seen whilst testing is simply when debugging is on. Converting the JSON into a string for logging seems to have a significant impact. If you're doing any performance testing just make sure debug is disabled (as I'm sure you do :slight_smile: )

I doubled checked that I have the latest drivers, and my logging is disabled in the app settings. But, the referenced debug logging is still occuring on the "smart lux group". Anything else I should be checking for?

Edit: Compared the code for smart lux group and the other groups and found some differences in the parse events into attributes section.

// parse events into attributes
def parse(String description) {
log.debug "Parsing (ignoring) '${description}'"
}

def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}

def updated(){
log.debug "Updated with settings: ${settings}"
sendEvent(name: "transitionTime", value: tt)
}

def initialize() {
}

I went ahead and modified it to match the others and it seemed to fix it.

1 Like

Nope, I had missed some calls to log.debug that needed to be changed. I've done that now, if you grab the latest Lux group driver it should be fixed.

Ha, you are too quick, I should have waited for your reply! LOL

1 Like

@xap one more question I forgot to ask. Can you think of any reason why one of my lights seems to miss off commands when using RM occasionally? I have a couple of RM rules that turn off more than one light after a motion timeout and for whatever reason it seems one of the lights stays on after the rule completes.

As a work-a-round I created "off scenes" for areas that were troublesome which seems to resolve it, but I thought it was strange. I think I saw the same thing happen with the HE built-in integration too.

The two rules that were't working as expected are both turning off a "group" and a single bulb (not part of the group), not sure if that would matter.

Just tried to add a new scene using the latest code, no bulbs or scenes are being discovered in the setup menu. Perhaps the change in polling didn't work as planned?

Yep, something is definitely wrong now, it found my bulbs and groups, no scenes, then lost all but the groups.

I'm thinking a roll-back would be a good idea? Unfortunately I don't have the code for the pre-polling change can you provide a copy?

There ya go, it's in github.

@xap thanks for the quick post, any idea what might have caused setup to go haywire with the change in polling method?

Truth is, it's not my code. I just ported it. I'm just hacking at it to make it behave a bit better. Ideally I would write my own integration from scratch but it currently does what I need it to so I'll just leave it as is for now.

Got ya, well I hope that HE developers take a look at this code and perhaps use it as an example of how they could improve the stock integration.

BTW got an error when I tried deleting a scene from hue b smart after the code change:

app:49722018-11-22 10:29:09.119 am errorjava.lang.NullPointerException: Cannot get property 'label' on null object on line 575 (chooseScenes)

Seemed to work fine, but thought you'd want to know anyway.

Thanks for porting (I'm the original coder). Planning on getting onto this platform soon. Let me know if you have any questions.

4 Likes

Definitely looking forward to any input you can give with regards to optimization of your code for the HE platform. @xap has done a great job, but I'm sure your expertise could help even more.

No probs. It could probably do with the more knowledgeable touch of the original author, you may want to re-port it as I simplified a fair bit for my purposes. :slight_smile:

1 Like

This seems to be working great but I can't use flash with rule machine. Anyone else have that problem? All of the flash buttons work on the device page but when I set rulemachine to flash a single bulb or group it gives the error "Command 'flash' is not supported by device"