device.getChildDevices() returns null instead of empty list

From the Documentation,


Gets a list of all child devices for this device.

List<ChildDeviceWrapper> getChildDevices()



Question: Is it expected that a method which should return a List would ever return null? This is not normal for Java, so I would not expect it to be the case in Groovy either. I have code that worked in the past which called:

child.getChildDevices().sort({ .... })

I don't know when the behavior changed, but I had to change the code to read:

child.getChildDevices()?.sort({ .... })

I would never expect a List returning function to return null since an empty list typically means there are no contents, and null would mean there is no list at all.

Should this be fixed in Hubitat code, or should I update the Documentation to include Null as a possible return value?

1 Like

Huh, so it used to return an empty list as it should, and now it doesnt?
Any idea how long ago it used to work?

I have no Idea when it started returning a null. The last time I used the function in my code was about 2-3 months ago. The code in question was not modified for quite some time. And it seems to occur when the device is newly created. I believe it is something new in one of the new updates, but I only just received reports of the problem in my code. It was an easy fix, though I use of lot of this notation. I can roll back the hub to older versions of firmware if so desired, and see if I can reproduce the issue. work around is easy enough, it just seems inconsistent to return null on a method that returns a list, unless the null has a specific meaning that differs from an empty list, so I figured I would ask.

I know it was working back in December of 2020, as I had to test it back then for an update I was rolling out, that involved my deleting my devices, installing the app, and adding my devices back in.

1 Like

no need to roll back, we should be able to track this down.


@mike.maxwell Don't really understand OP's post, as it is beyond my understanding...but wonder if this is related... sometime over the last few days, I no longer have any child devices listed at...

http://[my hub]/hub/zigbee/getChildAndRouteInfo


I can’t speak for mike and the rest of the Hubitat staff, but I would not believe so. My post is I in regards to a function for writing apps and device drivers. The function sometime returns nothing instead of an empty list. What you are describing is a web based api call that returns a list. If the list is expected to be empty, it may be related, but from little I know about the API call, it would seem it is likely a different issue.


found it, it will be fixed in platform 2.2.7


Thanks Mike! (Now If I can figure out what is breaking these roku drivers from working on mesh...)