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:''
preferences
{
page(name:'test', title:'', install:true, uninstall:true)
{
section('')
{
input 'batteryDevices', 'capability.battery', title:'Battery Devices:', multiple:true, required:true
}
}
}
void installed()
{
for (def device in batteryDevices)
log.info '- ' + 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
log.info '- ' + device.roomName
with
log.info device.displayName + ' - ' + device.roomName
it's working!?!
It seems that roomName needs some kind of initializing before working...?
Dear @Hubitat_Staff, could you please review the implementation?