Thermostat Fan Recirculate

OK. That makes a lot more sense :-). I’m not familiar with the time math you are using so I can’t comment. I am familiar with using runIn() to schedule a handler some seconds in the future but I suspect what you are doing has the same end result.

I think you also need to handle the case where the fan in ON and heating or cooling starts. You unschedule() which means, I think that, once cooling or heating call is done (idle), the fan will stay on. I think you can resolve this by sending fanAuto() in your schedule_start_circulate() method.

I’m still curious about this code:

def eventHandler(evt){
	DEBUG("eventHandler: ${evt.value}: ${evt}, ${settings}")
	if(evt.value == "idle")
		schedule_start_circulate()
	if(evt.value == "heating"|| evt.value == "cooling")
		unschedule()

I think you might need some closures, like this:

def eventHandler(evt){
	DEBUG("eventHandler: ${evt.value}: ${evt}, ${settings}")
	if(evt.value == "idle") {
		schedule_start_circulate()
        }
	if(evt.value == "heating"|| evt.value == "cooling") {
		unschedule()
        }

. . . to make sure the compiler knows not to put the second IF nested under the first. I am learning that the groovy compiler just handles a lot of coding variations and figures things out. However, in this case, I don’t see how it would know. But, if it’s working, it must have been correctly sorted . . . .

Good catch on the fan condition. I appreciate you taking the time to look at the code. I moved the fanAuto():

def eventHandler(evt){
	DEBUG("eventHandler: ${evt.value}: ${evt}, ${settings}")
	if(evt.value == "idle"){
		schedule_start_circulate()
	}
	if(evt.value == "heating"|| evt.value == "cooling"){
		unschedule()
		settings.device.fanAuto()
	}
}

That way when we get the event from the heator AC turning on, we kill the pending cron jobs (unschedule()) and set the fan back to auto.

The schedule command uses a cron type syntax. Take a look at the Unix cron command.

The if statement will execute the next line only if the condition is true. But you’re right, for ease of reading the code I should use some {}.

Thanks again for your help!

1 Like

I agree this is the best way. The way I suggested covers the issue @tslagle13 reported (see posts earlier in this thread) but what he described shouldn’t be. . . so I think it’s OK not to handle it

yea, I get that. But, without the closures, how does the compiler know that the second if statement is to be executed every time and not just when (evt.value == "idle") is TRUE.
.
Thanks!

I understand your fanAuto() placement now. Moved it from the eventHandler to schedule_start_circulate().

I also changed the cron calculations. The way it was populating the crontab, it started the process at specific time each hour instead of on the interval designated by the user. If the user gave thirty mins, it would default to every half hour on the half hour.

I do have to think about values greater than 59 minutes on the user input. Have not accounted for that.

On the closures, if statements have been handled that way since K&R C. Probably even longer. However, probably falls under some kinda poor coding standard. (I’m EE by profession, not CS :wink: )

Sidenote: Noticed the bass clef. Music background?

Cool.

You might look at the runIn() method. It’s pretty easy. It would like something like this:

runIn(amountOfTimeSelectedByUserMinutes*60, handlerToRunAtEndOfDelay)

You don’t have to do any time math to make this work and the result is the same . … running the handler at a certain time in the future. No issues with times greater than 59 minutes. On the handler, don’t use “()”. For some reasons this causes problems. From the docs:

I’m an ME by profession so I’m even further removed so I have to take your word for this ;-).

Yep. In my copious spare time, I play bass guitar in a classic rock band.

Ok. I took your advice and explored runIn(). Much easier to work with!

It made the code much more compact.

Classic rock band. Neat! Now, showing my age, classic rock would be Allman Bros. (my first concert), Stones, Mountain, Zepplin, Deep Purple, Grand Funk, etc. Am I in the right era?

Super.

Ha! If your handle is a clue to your age, we are about the same age. We do a few from this century but mostly 60’s through 90’s. No Mountain or Zep, however.

Looking forward to seeing your code once you have something working.

Happy holidays

Hello Bob,
I have two questions for you:

  1. Is there any way to code the option of the app only working when the thermostat reads a certain temp? I only want it to run when temps are over say 75F.

  2. Is there a way to create an on/off switch for the app? My wife wants to be able to turn the app on or off without uninstalling/re-installing the app. The best would be for it to integrate into a tile in the device manager. Never seen this before though I don’t think.

Thanks.

I have been hoping to come across an app like this!

Great job @midyear66 , any way you can incorporate a rule into the App to run only during certain times or the days or modes? For example I only want to run this at nighttime (say 11:00PM - 6:30AM) or alternatively when ST is in ‘Night’ mode.

@eicher_ian and @jotto : Thanks! You guys pose some great improvements!

I have been working on iPhone presence reliability but I’m getting frustrated. This will be a welcomed distraction!

Thank you

Anytime Bob! I’ll even test for free!

Ok. Got a test version for you guys.

Link to the Github: https://goo.gl/V2cTLf

It contains an interface to a virtual button that can be placed in the ‘Things’ page to halt the scheduling of the recirculate with uninstalling the app. It also has the min temp setting as well.

I did not integrate a time range since the Smartthings interface allows you to choose what ‘mode’ the app is operational under.

Let me know if you see any issues! thanks!

Thanks @midyear66 - New test version of the App is exactly what I was looking for!!

Having some trouble installing virtual switch to get the app to run though. Tried your code and SmartThings ‘On/Off Button Tile’ and neither show up in the app as a switch available to control operation. Have to admit I am new to working with IDE but steps I took was My Device Types -> +New Smart Devices -> From Template -> On/Off Button Tile -> Create -> Publish for Me
Again its not showing up on my devices or under app setting as switch available to control. Am I missing a step?

Almost there!
The next step in the IDE is to goto My Devices -> +New Device

Fill in the Name.
Device Network ID (any alphanumeric)
Type (Should be the device you just published)
The version should be Published
Location should be a drop down with only one entry
Hub should be the name of your hub.
Click create.
You should end you with a ‘blue #1’ by the plus sign at the bottom of the app panel.
touch the + with the blue one and there should be a ‘Not configured Item’. Choose that and walk through the steps.

Next install the Recirculate and choose your just created switch during the install steps.

Hope this helps!

Works! :smile: Thanks again Bob! Functions perfect for me so far.

I also didn’t like using Ecobee (thermostats I use) automatic recirculate settings as I was forced to choose min fan run (5min intervals) / 1 hour… and that would run 24/7. Not ideal when I am away from home. Allowing me to choose what ‘mode’ the app is operational under (night for me) is perfect as it allows me to circulate the air at night

You are the man Bob! Works perfect! Glad you helped jotto out as I needed the same help. Cheers!

1 Like

Bob, the virtual switch isn’t working for me now. Whether I have the switch on or off it is controlling the fan forcing it into auto or circulate. I tried uninstall and reinstall and it’s still doing it. I can’t control the fan manually in the device type at all. Any ideas?

Yup. Good catch! Improperly (actually missing) brackets.

Try it again please. New code in github.

https://goo.gl/V2cTLf

1 Like

Thanks Bob, I’ll try it out.

Bob,
This is still not working. Even when the switch is turned off, the fan recirc app still is controlling the device, turning the fan off when I have it set to on via the device. Here’s the log of the device:

4:05:23 PM: debug Parse returned [[value:fanAuto, name:thermostatFanMode, displayed:false, isStateChange:true, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat thermostat fan mode is fanAuto]]

4:03:17 PM: debug Parse returned [[value:fanOn, name:thermostatFanMode, displayed:false, isStateChange:true, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat thermostat fan mode is fanOn]]

3:57:29 PM: debug Parse returned [[value:76.5, unit:F, name:temperature, isStateChange:false, displayed:false, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat temperature is 76.5°F]]

3:57:29 PM: warn Unexpected zwave command ThermostatFanStateReport(fanOperatingState: 1, reserved01: 0)

3:57:28 PM: debug Parse returned [[value:76.5, unit:F, name:temperature, isStateChange:true, displayed:true, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat temperature is 76.5°F]]

3:57:28 PM: warn Unexpected zwave command ThermostatFanStateReport(fanOperatingState: 1, reserved01: 0)

3:52:28 PM: debug Parse returned [[value:fanAuto, name:thermostatFanMode, displayed:false, isStateChange:false, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat thermostat fan mode is fanAuto]]

3:40:24 PM: debug Parse returned [[value:fanAuto, name:thermostatFanMode, displayed:false, isStateChange:true, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat thermostat fan mode is fanAuto]]

3:35:24 PM: debug Parse returned [[value:fanOn, name:thermostatFanMode, displayed:false, isStateChange:true, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat thermostat fan mode is fanOn]]

3:29:26 PM: debug Parse returned [[value:idle, name:thermostatOperatingState, isStateChange:false, displayed:false, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat thermostat operating state is idle]]

3:29:24 PM: debug Parse returned [[value:fanAuto, name:thermostatFanMode, displayed:false, isStateChange:false, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat thermostat fan mode is fanAuto]]

3:29:22 PM: debug Parse returned [[value:auto, name:thermostatMode, isStateChange:false, displayed:false, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat thermostat mode is auto]]

3:29:19 PM: debug Parse returned [[value:76, unit:F, displayed:false, name:coolingSetpoint, isStateChange:false, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat cooling setpoint is 76°F]]

3:29:17 PM: debug Parse returned [[value:68, unit:F, displayed:false, name:heatingSetpoint, isStateChange:false, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat heating setpoint is 68°F]]

3:29:15 PM: debug Parse returned [[value:55, unit:%, name:humidity, isStateChange:false, displayed:false, linkText:Z-Wave Thermostat, descriptionText:Z-Wave Thermostat humidity is 55%]]

And here is the log of the switch:

f4ac73ae-93c6-428a-8d52-e8f17d7c938e 3:52:24 PM: info Running Switch Off Event
f4ac73ae-93c6-428a-8d52-e8f17d7c938e 3:52:24 PM: debug off
f4ac73ae-93c6-428a-8d52-e8f17d7c938e 3:17:17 PM: info Running Switch On Event
f4ac73ae-93c6-428a-8d52-e8f17d7c938e 3:17:17 PM: debug on

Any ideas on what’s going on? I did a full uninstall/ reinstall of the app.

Thanks.