Trying to learn how to create an app that will let the user select a device and then an attribute of the device

Working on my first app and trying to use my air sensors AwAir Element to calculate an AQI value. Does anyone know of an app out there that will calculate based on a value from a device. I have looked at the examples on Hubitats documentation site and can get to the point where i can select my AwAir device using capability.polling

What do you do to get down into the device and select an attribute value. Essentially, i want to take the pm25 throw that against a series of conditions, select a condition and then calculate the AQI within that conditional range.

My use case for this is to track and maintain the AQI within my house during fire season.
Workflow for the App is:

  1. User selects Device (AwAir or whatever Air Quality Device they have installed)
  2. User sees attribute options or sensors and selects the PM25 sensor
  3. Go through a switch statement to calculate the AQI
  4. Returns AQI Number, AQI Color and AQI Description for USA calculations

I can get to the device attributes and ask the user to choose the attribute they want. I now am struggling to get the value from the Input "Selected Attribute" to pass into the .currentValue() property. If i hard code in "pm25" it pulls the value from the device. but i want the app to pass in the pm25 sensor the user chose.

Check out this document:


Thanks. I do have the logic all written out, actually referenced this a bit earlier. I am mostly struggling with how to locate the PM2.5 field off my AwAir. The driver grabs it from the api and i need to use a custom value inside of my rule machine to locate it. Are there any good reference items on how to use an app to reference that field from a driver.

This is a piece of code from the driver i am using. I am trying to hit this specific attribute. or at least let the app pull up a list of options. let the user choose and then grab that as a parameter to calculate the aqi formula.

Ah. Because you seem to be using Rule Machine, the trick is to create a variable (either a local variable or Hub Variable), then assign the custom attribute to the variable, then use the variable from that point on.

1 Like

I should rephrase. I was using rule machine to try and grab values for a conditional rule. deciding that wasnt happening I decided to try and write an app.

Here is a chunk of my code trying to get at the attribute level which has the PM25 value within the driver. I am thinking i shouldnt be trying to reference attribute but some other object

Here is what my output is looking like when i got to install the custom app

I would suggest adjusting the title of the topic and your original post to clarify the issue you are requesting assistance with. I can't offer anything more than that at this stage....


Thanks i changed my title and added a workflow to original post.

1 Like

Download the Hubitat app