Temperature control app help

Hi, all!
I'm trying to write a custom app that will set temperatures and modes for three separate thermostats based on time of day, holidays, etc. I'm looking to go beyond the generic functionality of some of the built-in apps, to better suit my needs.
Can anyone point me to an existing app that reads and sets temps in more than one thermostat, that I can use as a reference? I'm struggling to figure out how to reference the thermostat in my app. I'm sure it's been done before!

You can only reference devices that the user has chosen from an input. Your can have one for each thermostat, or you can use multiple: true on a single input and the field will refer to a List of devices rather than a single device.

I'm not aware of any specific examples quite like you want, but Hubitat has several example apps published: https://github.com/hubitat/HubitatPublic/tree/master/example-apps. There is also lots of open community code on the forum.

So maybe something like:

input "theThermostats", "capability.thermostat", title: "Select thermostats", required: true, multiple: true

input "theTemperature", "number", title: "Temperature to set", required: true

Then elsewhere something like:

theThermostats.each {

Just to give one very general example.

If you are not comfortable writing custom code, I'd also encourage you to check out Rule Machine instead (requires some learning, but it's not code per se), or describe more of what you want and someone might be able to suggest a built-in alternative. Good luck!

Thanks so much for the help.

With the code below, I'm getting this error:
2021-12-14 02:25:34.021 pm office setpoint null
I'm sure I've got something pretty basic wrong. Would you mind taking a quick look?

It appears officeThermostat is defined, but officeThermostat.heatingSetpoint isn't.

Thanks again!

name: "Temperature Manager",
namespace: "ns",
author: "Len Hodder",
description: "Building Temperature Manager",
iconUrl: "",
iconX2Url: "",
iconX3Url: "",
singleInstance: true)

preferences {
page(name: "pageConfig")

def pageConfig() {
dynamicPage(name: "", title: "", install: true, uninstall: true, refreshInterval:0) {

section("Inputs") {
    input "officeThermostat", "capability.thermostat", title: "Office Thermostat", required: true
    input "eastShopThermostat", "capability.thermostat", title: "East Shop Thermostat", required: true
    input "westShopThermostat", "capability.thermostat", title: "West Shop Thermostat", required: true


def installed(switchInstance) {
log.debug "installed"
def updated() {
log.debug "updated"
def initialize() {
log.debug "initialize"

//Refresh devices
def uninstalled() {
log.debug "uninstalled"

def checkDevices() {
log.debug "office setpoint " + officeThermostat.heatingSetpoint

You need to use device.currentValue("heatingSetpoint") or device.currentHeatingSetpoint instead of device.heatingSetpoint. Attributes are not fields by name on the device. I normally use currentValue(), though they are also provided as a field in that other (currentX) format.

That worked. Thanks for the help!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.