Temp increase or decrease as condition

The title says it all.
Could it be possible to use temp increase or decrease as conditions?

Say I set my trigger as Temp changed. Could I then have conditional actions based on whether the change is an increase or a decrease, and possibly, conditioned on the amount of increase or decrease?

I do exactly this for my water heater and furnace modes. If it becomes X degrees, (changed as trigger) I switch from heating to cooling mode, and similar but different temp to change back from cooling to heating.

For water heater, ifchanged below X temp, it is high demand mode or above X it goes to heat pump mode.

Sound like you are using specific temps. I want to use increase and decrease regardless of actual temp.

Yes, I am using specific temps. What are you trying to do exactly? How would you use or apply this logic?

I currently use 2 rules to control a blower. The first sets a variable...

The second uses temp change as a trigger and compares the current temp to the variable...

This all works fine but, if I could use increase and decrease as conditions, I could accomplish this with one rule and eliminate the variable.

I would think this should be fairly easy to implement. Back when Stringify was a thing, I was able to do exactly what I am suggesting by, basically, creating a flow-chart in a simple GUI.

Or, if anyone has a cleaner way of accomplishing what my rules are doing now......

I would have done what you did above, or I would have used two sensors and compared ambient to stack temp.

I am out of my league much beyond this. There is an app you should check out for an example of how to do a rise, in this case, humidity. Smart Humidity Fan Maybe you could adapt that, or use it as an example for a new app. Please be sure to ask the author if you decide to publish any of this code though.

Maybe someone else has a suggestion for you.

Why not at the end of your rule set the base temp to the current temp therefore at the next change you can check for the rise from the last time you ran the rule?

Could always use the WATO app, too. It has increasing/decreasing triggers. Although I don;t think you can have the rising a different threshhold than the decreasing. Anyway, take a look.

Doesn’t this work?

Use changed as an event and a variable. Like this:

if  temp > lastTemp then
    Increasing 
end if
lastTemp = temp
1 Like

Since I have the blower turning off when temp decreases below 90, that would set the base to 90 and effectively my app becomes a simple thermostat turning on and off at 90.

.....nevermind, I got the logic now. The rule still runs whenever temp changes therefore, as temp drops off, the base is still being updated.

Where are you getting "lastTemp" ? Are you creating it as a variable within the app?

lastTemp in that context is a user created local variable.

1 Like

For my bathroom humidity fan control, I created a slow-moving average device, and then compare current humidity with the slow-moving average to detect when it rises. This has proven to be a very reliable detector of when someone is showering.

image

The averager App is derived from Bruces code, with some modifications by me.

definition(
name: "Average Humidity",
namespace: "hubitat",
author: "Bruce Ravenel",
description: "Average a humidity sensor",
category: "Convenience",
iconUrl: "",
iconX2Url: "")

preferences {
	page(name: "mainPage")
}

def mainPage() {
	dynamicPage(name: "mainPage", title: " ", install: true, uninstall: true) {
		section {
			input "thisName", "text", title: "Name this humidity averager", submitOnChange: true
			if(thisName) app.updateLabel("$thisName")
			input "humidSensor", "capability.relativeHumidityMeasurement", title: "Select Humidity Sensor", submitOnChange: true, required: true
			input name: "nOption", type: "number", defaultValue: "10", range: "10..200", title: "Number of Samples to average.", description: "10 samples will be very responsive, while 200 samples is quite slow.", required: true

		}
	}
}

def installed() {
	initialize()
}

def updated() {
	unsubscribe()
	initialize()
}

def initialize() {
	def averageDev = getChildDevice("AverageHumid_${app.id}")
	if(!averageDev) averageDev = addChildDevice("hubitat", "Virtual Humidity Sensor", "AverageHumid_${app.id}", null, [label: thisName, name: thisName])
	averageDev.setHumidity(50)
	subscribe(humidSensor, "humidity", handler)
}

def averageHumid() {
	def n = nOption as Integer
def averageDev = getChildDevice("AverageHumid_${app.id}")
	def float av = averageDev.currentHumidity
	av -= av / n
	av += humidSensor.currentHumidity / n
	return av.toDouble().round(1)
}

def handler(evt) {
	def averageDev = getChildDevice("AverageHumid_${app.id}")
	def avg = averageHumid()
	averageDev.setHumidity(avg)
}
1 Like

napalmcsr and asj gave me the clues needed!

It would still be nice to be able to use temp increase and decrease as conditions but, for now, this will do just fine.

Thanks to all for your assistance and inspiration!

1 Like