Problem with roomName

When I access the roomName property of a device, I get this error:
"java.lang.NullPointerException: Cannot get property 'roomId' on null object on line ..."

Here a minimal app to reproduce the error:

definition name:'jsTest', namespace:'de.schwider', author:'', description:'', iconUrl:'', iconX2Url:''

  page(name:'test', title:'', install:true, uninstall:true)
      input 'batteryDevices', 'capability.battery', title:'Battery Devices:', multiple:true, required:true

void installed()
  for (def device in batteryDevices) '- ' + device.roomName  // <-- BOOM!

void updated()
  installed ()

void uninstalled() {}

But no problems when I replace device.roomName with device.displayName...

Very strange: When I replace the complete line '- ' + device.roomName

with device.displayName + ' - ' + device.roomName

it's working!?! :thinking:

It seems that roomName needs some kind of initializing before working...?
Dear @Hubitat_Staff, could you please review the implementation?



Yes, that works: By using properties it seems that all the device properties are initialized (like using displayName). :thinking:

IMHO it should be an easy fix to make roomName consistent to displayName etc., shouldn't it? :wink:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.