Help with LAN device

I am basing my code on the Sonos(Connect) example. I can initiate ssdp and the subscribed locationHandler is able to discover the device and I add it to a state.devices list. The app (run from My Apps) shows the device as found but the name tag is “null”. I cannot for the life of me figure how to get the device to have a meaningful “name”. In my case the device is typed as “STB”. The selection pane looks like Select STB (1 found), but the checkbox item is tagged “null”.
Anyone know what stupid thing I am doing/not doing here?

You probably need to give it a label. You can do the either via the app (+ -> Not configured devices) or via the devices page in the IDE.

Thanks, I tried adding a label but that didn’t change the “null” tag in the device selection list.

Do you have code somewhere we can look at?

1 Like

Hi, I figured it out. The missing field is the “Name” field. The way the Sonos works:

  1. ssdp
  2. HTTP GET configuration (found device ip:port)
  3. locationFound() will get the HTTP response which will contain the device ID (Name) and that is set into the Name field.

Then, in addChildDevice, the list of params is [label: name] so in the end, Dianoga is correct, I had to add a label.

When I call “addChildDevice”, I am getting the error: “java.lang.NullPointerException: Cannot invoke method getDataValue() on null object @ line 274”. Has anyone seen this or have any idea what could be wrong?? Line 274 is not from my SmartApp… it only has 74 lines. I am stumped.

d = addChildDevice(“com.obycode”, “MacThing”, “$iphex:$porthex”, theHub, [label:"$theName", name:"$theName", completedSetup: true])
Or, if I pass a value as the fourth parameter instead of null (as above), then I get this error instead:
groovy.lang.MissingMethodException: No signature of method: physicalgraph.device.HubService.get() is applicable for argument types: ( values: []
Possible solutions: get(java.lang.String), grep(), getAt(java.lang.String), grep(java.lang.Object), wait(), any() @ line 57

What is the value of theHub going into addChildDevice()? I’m assuming the device does not get created? How big is your device type? Is there anything weird there at line 274?

It’s hard to guess too much without more of the code.