Hello, all. I am a little embarrassed to ask for help with what seems like something I should be able to debug myself, but I’ve been struggling for a while. I wrote a quick app that is supposed to turn on a ceiling fan when the thermostat is in the “Heating” state. I have the below code but the app simply does nothing. It’s almost like my subscription is incorrect, but I’m not sure. I think that I’ve just confused myself at this point. I’d appreciate some fresh eyes.
/**
- Air Circulation
- Copyright 2016 Bob Solimine
- Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at:
-
http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
- on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
- for the specific language governing permissions and limitations under the License.
*/
definition(
name: “Air Circulation”,
namespace: “buhbob”,
author: “Bob Solimine”,
description: “This app will switch on a fan when the central air or heat is on.”,
category: “Green Living”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”,
iconX3Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”)
preferences
{
section(“When this Thermostat is Operating”)
{
input “watchedThermostat”, “capability.thermostat”, title: “HVAC”, multiple:yes
}
section(“Turn on this fan switch…”)
{
input “fan”, “capability.switch”, title: “Which fan?”
}
}
def installed()
{
subscribe(watchedThermostat, “thermostatOperatingState”, switchHandler)
// log.debug(“Subscribed to”)
// log.debug(watchedThermostat.thermostat)
}
def updated()
{
unsubscribe()
subscribe(watchedThermostat, “thermostatOperatingState”, switchHandler)
// log.debug(“Re-subscribed to”)
// log.debug(watchedThermostat.thermostat)
}
def switchHandler(evt)
{
log.debug(watchedThermostat.thermostatOperatingState)
if (watchedThermostat.thermostatOperatingState == “Heating”)
{
fan.lowSpeed()
}
else
{
fan.off()
}
}