Hi all,
I have a custom device with a custom driver that I'm using to store information I want available to multiple apps. The custom device is called "Room Monitor Device" and some simple commands like:
When I run these commands from the device page, it produces the correct response. When I call those commands from a custom application, the device debug log records the correct response but the application does not.
Application Code
def roomInfo = roomsDevice.getRoomInfo(id)
if (functionLogEnable) log.debug "refresh: roomInfo: ${roomInfo}"
Is this a parent/child app? If so, that should work, but a more complete example might show what's going wrong where.
If it's an arbitrary app that has selected this device as an input/setting, it won't work. Commands can't "return" values -- they are just something an app (or the user) can execute on a device. (Internally, the driver may very well return a value from the method that implements the command for other reasons, e.g., sending a Z-Wave or Zigbee command -- one use for return values from driver commands at the platform level.) To get something an arbitrary app can access, you'd need a device attribute or other way of sharing this information -- or, of course, to make them parent/child.
Yes, it's an arbitrary app that has selected the device as a setting. I didn't realize device commands couldn't return values
Indirectly related question, if an app has access to a device (by selecting it in the app settings) does it automatically have access to the child devices fo said device?
You could send a command to the parent that then sends a command to a child (or children). So you would only ever need to directly "talk" to the parent.
Yes, that is available on any device reference: getDataValue(), along with ways to write/update and remove such values (though regarding the specific concern of being "dynamic" I'm not sure what this would do for you that an attribute wouldn't).