Monitor temperature and turn on a switch if no change after 4 hours?

Im wondering if someone can help me, im useless at creating rules.
Im after rule that does this.
If a temperature sensor remains unchanged for 4 hours, notify someone or it can be switch on a switch.
Example of rule : aqara temperature sensor reports at 4pm that temperature is 25c. At 8pm sensor is still 25c, notify someone as unchanged.

Can be either be on the fly monitoring all day or certain times of day monitoring, the less hub resources in use the better.

Thank you in advance

There may be a more elegant approach someone will chime in with, but what I would do is create a virtual switch where every time the temperature changes you flip the switch on. Set another routine to turn it off on a short timer. Then if the switch is off for specified period of time, send the notification.

You could skip the turn off step if you use a virtual button.

EDIT: there’s no If Changes for temperature so this idea won’t work.

Brilliant and simple, why didnt i think of that.
:rofl:

Is there a way to do this in the SmartThings app? I suspect there might be with the rules API, or with SharpTools, but I didn’t think there was an ā€œif changesā€œ condition in the basic routines in the SmartThings app. But maybe I missed it. :thinking:

I just used the switch is off with a pre condition and then a 'if temperature is above=1c"
In the ā€œthenā€ section, turn switch on and auto off after 20 seconds
So far seems to be working as i wanted…

Unfortunately i spoke too soon…
Sometimes it works and other times not, im not sure why tho…

I was rather surprised when you said it worked as the ā€˜equal or above’ condition in a Routine only provides a trigger when it transitions from false to true

The logic would work in the Rules API because you get to decide when you want the trigger, and there is also the alternative of a ā€˜changes’ condition that can test if a new value for a particular device attribute has been received.

2 Likes

Its strange, it works fine for 3-4 changes, then stops altogether.
I just wish i knew how to write rules with the rules api.

You can try using my instructions

Here is Rules API template for monitoring temperature changes

	   {
		 "if": {
		  "changes": {
			"operand": {
			  "device": {
				"devices": [
				  "-- temperature measurement ID --"
				],
				"component": "main",
				"capability": "temperatureMeasurement",
				"attribute": "temperature"
			  }
			}
		  },
		   "then": [
			  {
				"command": {
				  "devices": [
					"-- virtual switch ID --"
				  ],
				  "commands": [
					{
					  "component": "main",
					  "capability": "switch",
					  "command": "on"
					}
				  ]
				}
			  },		  
			  {
				"sleep": {
					"duration": {
						"value": {
							"integer": 1
						},
						"unit": "minute"
					}
				}
			  },
			  {
				"command": {
				  "devices": [
					"-- virtual switch ID --"
				  ],
				  "commands": [
					{
					  "component": "main",
					  "capability": "switch",
					  "command": "off"
					}
				  ]
				}
			  }	
			]
		}
	   }		 

Virtual switch makes 1 minute pulse every time temperature changes.

Notification using ST App routine

3 Likes

Derp, you are right, there isn’t an If Changes so my idea won’t work.

2 Likes

Holly sugar, it was that simple…
I imagined it would require to compare the temperatures for a change.
So now i can monitor if my aqara sensors drop off or go flat, no more waking up to a over heated propagation trays.
Thank you so much @TapioX

4 Likes