Automation to turn on a Sonoff switch when temperature drops below specific point?

I was aware that changes were coming so I moved the control over my house heating into Automation Routines, but they are not doing anything and I am unsure of how to troubleshoot this as I am longer seeing any logging as before.

I have thermostats that are working fine with ST and I can I see in the thermostat’s history that they are reporting the temperature. So my simple automation is that if the temperature drops below a set value it should turn on a Sonoff switch (which are also working fine with ST) which turns on the heat.

So right now the value is set to 25 degrees (celcius) and the reported heat is 24.1 but the automation is not activating. Could someone more clever than me please help me. Thought such a simple automation could not fail and I have no idea of how to find out the problem.

As far as I am aware, the ‘less than 25C’ condition will only trigger the Routine to do anything when the condition transitions from false to true. So the temperature would need to have been reported above 25C since the Routine was last saved and then dropped. Would that be consistent with what you are encountering?

Just by posting here I think I have solved the problem. The thermostat is reporting heat in 0.1 increments, so the heat might be 24.1. In my automation I typed in 25. So I just went back in and noticed that there is a . at the top of the screen and when I entered 25.0 the automation kicked in.

It seems that ST didn´t understand and wasn´t smart enough to convert my input into integer, which is a rather sloppy programming.

So if you are using temperature in your automations make sure you are using the same format as your thermostat is reporting in.

I think this only solved one part of the problem. The automation ran, as I placed a notification on the routine. The notification says the automation ran, but the Sonoff switch did not switch on.

In the device list I noticed that the Sonoff switches are running on the cloud. Is that causing a problem?

The problem was the other accompanying routine (each room needs two routines, one to turn on the heat and one to turn the heat off).

I set the OFF routine to activate at 25.1 and typed in 25.0 in the ON routine, but ST converts 25.0 to 25, and since that is the core problem I had to change that to 24.9 and now everything seems to work.

Now if only if ST had an IF THEN ELSE capability ;p. If there is a better way to create an automation to turn the heat off and on at a set temperature then please let me know as this is not an elegant solution.

1 Like

I have a lot of routines I created that seem like sometimes they work and sometimes they don’t. If I create a routine for example that states (if temperature is between 36.6 F and 38.5 F precondition) (and humidity is below 45%) (Then turn on switch) and save it. Then this routine won’t run until the temperature has gone above 38.5 F and the humidity has been above 45%? I have 40 different routines to cover all the temperature ranges from 38.5 F down to -15 F. All of these ran fine in the cloud but now I migrated all of my devices to Edge and the routines run locally and now there all flaky. was this different in the cloud? When they ran in the cloud did it not matter if the conditions had not gone above first? I have another routine that states 22% humidity or above, does this mean for this routine to run it would have to have been below 22% since I saved the routine for this to work? This is all super confusing. They told us that we could migrate Webcore and smartapps to routines but the routines suck and don’t work properly

Let’s look at in in webCoRE terms. You could consider your Routine is something like:

only when temperature is between 36.6F and 38.5F
    if humidity is less than 45%
        (turn the switch on)
    end if

I am ignoring some of the undesirable things only when can cause for this discussion.

That piston will be fired every time there is a humidity event. It will not be fired when there is a temperature event.

If the piston is fired it will only get into the only when block if the temperature is in range. It will then only turn the switch on if the humidity is less than 45%. Next time there is a humidity event and the temperature is within limits and the humidity is less than 45% it will attempt to turn the switch on again (webCoRE might not actually do it in practice, but the task will execute).

So far so similar to the SmartThings Routine. Except that webCoRE has something called the Task Execution Policy (TEP). The default setting of this is that tasks (i.e. turning on the switch) will always run. However you can also set it so that the tasks will only run if the condition controlling them has changed states. If you do that the switch is only turned on the first time the condition changes from false to true.

The SmartThings Rules API does something broadly similar with some of its conditions. They can be set to only make the piston trigger if the condition changes from false to true.

The developers of the Routines would appear to have taken the latter option when deciding how to implement the Routines as Rules.

I should add that I don’t know exactly how the starting conditions work, so when you first save a Routine it isn’t clear if the condition is considered to be true or false?

One thing to look into is when your temperature and humidity sensor report a change back to ST. I went into settings of my temperature sensor and set the Temperature Reporting Threshold to 0.1 degree, but the default was 0.5 degrees. So my understanding is that this will force the sensor to update more often. So if your humidity sensor has high reporting threshold then ST will not know the current humidity.

Thank you. The routines really suck when you’re trying to do something more then control a light or something really simple. I created these routines while I was still using a smartapp that I installed years ago called Auto adjusting Humidifier. The routines worked flawlessly and matched what the smartapp was doing. I created all of my smartapp logic in routines and they were all working so I decide to complete my migration and moved everything to Edge drivers and removed all of my smartapps, DTH’s and Webcore. That’s when the problems started. All of the routines became local instead of cloud and then sometimes they would run and sometimes they wouldn’t, no rhyme or reason. I ran logcat and all of the devices were reporting correctly but the routine just wouldn’t run most of the time. Im going to move everything to Sharptools. For 2.50 a month its worth it. When I have everything working again then I will work on getting something that runs local again.

@MagnusBergs Thanks for the explanation

1 Like