Control space heater base on temperature condition

Hi everyone,
I’m a newbie, just decide to go with Smartthing to do some automation which Google Home (even with Google home scrips) could not do it.
Please help as I’d like to do this:

x, y : temperature value in F; z:smart power plug

Program Start
Start loop @ Time
- Check if Temperature is <= xF
Turn On “z” # smart power plug

  • Check if Temperature is >= yF
  • Turn Off “z”
    End loop @ Time

exit the loop when time range is not matched

    Turn Off "z"

Program End

Which is the best (cheap) temperature sensors, you recommend?
Thanks in advance

You could, in theory, create an automation as you describe. Might I politely suggest that you might like to do something different. You are battling against how platforms like Google Home and SmartThings work.

A switch would send out a report when it is turned on or off. A contact sensor would send out a report when it is opened or closed. A temperature sensor is going to send out temperature reports when the temperature changes by a certain amount, or after a certain period if the temperature hasn’t changed.

SmartThings, or whatever, is going to create events based on those reports. Automations can subscribe to those events and then decide if they need to do anything as a result.

The basic automation provided in SmartThings is a Routine. They have a simple ‘If … Then …’ structure but there can be added complexity under the bonnet. Don’t expect to use just a single Routine to accomplish tasks.

So in SmartThings you could could consider your requirement in five parts.

  1. At the start of the time range, if the temperature is <= x turn on z.
  2. At the start of the time range, if the temperature is >= y turn off z.
  3. During the time range, if the temperature is <= x turn on z.
  4. During the time range, if the temperature is >= y turn off z.
  5. At the end of the time range turn off z.

Steps 1) and 2) are only required because comparisons in Routines only make things happen when they first become true. However they can be combined with 3) and 4) because it is a recognised common requirement. So you’d probably need three Routines.

Thanks for clear explanation and suggestions.
As I understand, step1 can combine with step 3, and 2 with 4?
So routine 1 should be like this ?
If Time:
Time period 10: PM to 8:00 PM
Run at start time switch : On # it will start 2 10:00 PM ?
# Add what will trigger this routine
Temperature <= 60F
# There are 2 switches under: “stay this stay for how long?” and " Use as precondition ?" which one I choose?
Then:
Turn on “z”

  I still confuse, which routine 2, it will check at start time 10:00 PM, if temperature is >= 65F (for ex) turn off "z". So during the period of time does the routine 1 & 2 keep running?

I can do the test yet, still waiting for Aeotec Smarthing hub, and have not decide which temperature should I pick??

Although Routines are not scripts, you can perhaps think of them as working something like:

repeat all day every day
    wait until an update to a condition causes the Routine to be triggered
    if
        all the preconditions have evaluated to true
    then
        if
            one or all (as selected) of the conditions have evaluated to true
        then
            carry out the requested actions

The second line is doing a lot of heavy lifting there. Conditions and preconditions are actually evaluated as true or false immediately something changes that will affect them, but evaluating a precondition never triggers the Routines, and evaluating a condition doesn’t always trigger the Routine.

The example hopefully covers what preconditions are in Routines. Under the bonnet preconditions are just conditions that have been set to never trigger, but in Routines they fit in a specific place in the logic. In your case you want changes in temperature to make things happen so they should be ordinary conditions. The time ranges in Routines are implemented as preconditions so nothing actually happens by default when they become true.

Technically the ‘stays this way for’ wraps the base condition up in a parent condition that only becomes true when the child condition has been true for a period of time. An example would be clearer though. If you have a condition that tests ‘door A is open’ it would, if left to itself, become true when the door is opened (and also trigger the Routine immediately). If you add the option to stay that way for 10 minutes it would become true ten minutes after the door opens, providing it hasn’t closed in the meantime. In other words a pretty bog standard function that has been buried somewhat.

As for temperature sensors … I tend to be buying at the low end of the market. I used to have a load of Aqara stuff and binned it all. I used to have a load of IKEA stuff and have junked all but some buttons that stopped working with SmartThings for a very long time and are now working again. Most of my temperature sensors are Sonoff, as are many of my buttons (I had to replace the IKEA stuff with something when it stopped working). The only Sonoff product I may buy in future is their ZB Micro (a USB-A smart plug). Third Reality are my favoured lower end sensor supplier at the moment, mostly because they use AAA batteries rather than the coin cells. , They are a notch or three up the price scale from the other brands I mentioned, though their pricing is a little eccentric. They’d inspire more confidence if they certified all their products with SmartThings (many are, the temperature sensor isn’t).

That’s just me though. I am in the UK which does affect the market place. Also my temperature sensors have no practical purpose for me. I just like having them.

1 Like

Thank you so much for spending time helping me, very clear and detail for operations.
For Aqara and THIRDREALITY temperature sensors, do they need to have their hubs? If we have Aeotec Smartthing hub?