How do I add a single temperature reading to a user input

(Dale C) #1

This seems so easy but everything I tried is returning errors.

In my thermostat smartapp after the user selects a temperature input, the next input is to enter the temperature setpoint.

What I want to do is display that single temperature reading from the temperature input that was just selected in on the mobile app screen to help me determine what setpoint I want to enter. Easy stuff I would think?

I looked at @krlaframboise code for Simple Device Viewer and also PlantLink-DirectMonitor by @sidjohn1 for examples on how to do this for my use of just a single temperature point in my thermostat app. but the method they use for dynamically getting all the devices I just couldn’t follow. I couldn’t find examples in the ST documentation to learn from either.

Can somebody help? I am not sure of the correct syntax to use I guess because everything I try returns errors.

(Kevin) #2

The Simple Device Viewer doesn’t use the value of one input to populate another input. I think you need to use something like submit on change (I can’t remember the actual command). I know that the feature didn’t always work right when using the Android app, but I’m not sure if they’ve fixed that yet.

The SmartApp CoRE does what you’re trying to a lot, but since that SmartApp is about 10,000 lines, trying to figure it out from there probably isn’t a good suggestion.

(Dale C) #3

So how do I just get the value of a temperature like you did when you display the entire list of all temperature devices? All I need to do is display that one temperature on the mobile app like you do but not all my temperature devices.

(Kevin) #4

I’ll review your code and get back to you later this evening.

(Dale C) #5

Yes I agree. I think it goes in the input line 62 for the Temperature Sensor input
submitOnChange: true

Thanks Kevin!

What I was hoping to achieve is something like this screen shot shows

(Kevin) #6

Just do something like:

section("Select a room temperature sensor to control the Evap Cooler..."){
    input "tempSensor", "capability.temperatureMeasurement", multiple:false, title: "Temperature Sensor", required: true, submitOnChange: true

if (tempSensor) {
    section("Enter the desired room temperature (${tempSensor.currentTemperature})..."){
        input "setpoint", "decimal", title: "Room Setpoint Temp", defaultValue: tempSensor.currentTemperature, required: true

(Dale C) #7

I’m on it tonight! Thanks so much for looking at it


@krlaframboise again you have come through! That was it! I wasn’t so close too. I didn’t have submitOnchange and I had improper syntax. :smile:

So is the purpose for having the IF in there is for a technique to prevent null errors from crashing the smartapp?