I am struggling inserting a string to get a driver attribute value. My code is below where i am trying to take an input value and pass to get a devices attribute value.
input (name: "SelectedAttribute", title: "Select PM25 Sensor Attribute", type: "enum", options: attributeList.sort(), submitOnChange:true, width:3, defaultValue: 1)
def sAttribute = String.valueOf(SelectedAttribute)
If i use the string variable either just the variable itself or by trying to impose the value as a string i get a null value. Even though sAttribute is "pm25"
Integer value = ChosenDevice.currentValue("${sAttribute}")
If i use the following code and put a string directly into the currentValue method i get the result and see the sensors value.
Integer value2 = ChosenDevice.currentValue("pm25")