I am writing an app intended to aggregate discrete sensor values in various ways (e.g. contact, motion or shock sensors) and map the result to an output virtual sensor.
I would like the user (well, me) to select the capability, device(s), device attribute and attribute value to be aggregated/mapped, as it is often done in built-in apps. However I seem to be unable to programmatically retrieve the possible attribute values.
With this code:
input name: "inputSensors", type: selectedSensorCapability, title: "Sensors to aggregate", multiple:true, required: true, showFilter: true, submitOnChange: true
if (inputSensors) {
def capabilities = inputSensors[0].getCapabilities()
def targetCapability = capabilities.find { it.name.toLowerCase() == selectedSensorCapability.substring("capability.".length()).toLowerCase() }
logObjectProperties(targetCapability)
logObjectProperties(targetCapability.attributes[0])
(...)
private void logObjectProperties(obj) {
log.debug "properties of ${getObjectClassName(obj)} BEGIN"
obj.properties.each { property, value ->
log.debug "${property}=${value}"
}
log.debug "properties of ${getObjectClassName(obj)} END"
}
I get:
In particular, the possibleValues property of the Attribute object is null.
What am I doing wrong? Are these documented classes not accessible somehow?