Time trigger with temp

Just want to make sure I’m on the right track here.

If I want to turn my heater on between 2 times and when the temperature is below a certain level am I best to make the time the trigger and the temperature being below the condition? As opposed to triggering off the temperature?

So somewhat like this

trigger:
platform: time
after: ‘06:15:00’
before: ‘07:00:00’
condition:
platform: state
entity_id: sensor.yr_temperature
below: 12

Sorry I know the example isn’t in proper YAML form

Sorry. Here is the automation as I have it so far. Bit more to it but am I heading in the right direction?

alias: Turn on heater weekday by temp
  trigger:
    platform: numeric_state
    entity_id: sensor.yr_temperature
    below: 12
    platform: time
    after: '06:15:00'
    platform: time
    after: '16:45:00'
  condition:
    condition: and
    conditions:
      condition: time
      weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
      condition: state
      entity_id: input_boolean.heating_by_temp
      state: 'on'
      condition: or
      conditions:
        condition: time
        after: '06:15:00'
        before: '07:30:00'
        conditon: time
        after: '16:45:00'
        before: '21:00:00'
      condition: numeric_state
      entity_id: sensor.yr_temperature
      below: 12
  action:

Ok I am not that comfortable using multiple triggers, but I think that when doing so, then any trigger can trigger the automation which is not what you want.
And I haven’t had too much luck using ‘and’ and ‘or’ condition in one automation
For me the easiest way would be to use the time interval as a trigger, because this way the automation will not fire outside the desired time interval, and then use weekdays and temp in the conditions.
And the last trigger is uneccessary in your automation because everything that is after 16:45 will be after 06:15 :slight_smile:
I went towards creating multiple but simple automations, because it is better for trouble shooting later, when you have a handful of rules. You can turn them on and off one by one testing which causes what.
So this is what I would do:

alias: Turn on heater weekday by temp in the morning
trigger:
  platform: time
  after: '06:15:00'
  before: '09:00:00'
condition:
  condition: and
  conditions:
    condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
   condition: numeric_state
   entity_id: sensor.yr_temperature
   below: 12
   condition: numeric_state
   entity_id: sensor.some_inside_temp_sensor
   under: 26
action:

And I would create one for the afternoon from 16:45:00 - 05:59:00 to avoid heating during the day. And also notice the “sensor.some_inside_temp_sensor”, because you need a point where it is hot enough :slight_smile: Otherwise you would switch off the heating on your phone or tablet, and a minute later it turns on again…

Or you can just control heating with temp sensors that way your house, will always be around the desired temp. This way your heater can operate with less power but multiple times. Thats your decision.

Last but not least it is worth including a holiday sensor of somekind (either an input_boolean, or a google calendar trigger) in your conditions, so your automation only fires if you are at home, and not away to the bahamas…

good luck
tom

Thanks. I have always tried to keep each trigger separate and have more automations but I saw some posts describing how to get it all to work within one so had a go. I will stick with different ones for sure. I’m ok with the higher temp as the heater is actually a wall unit being set to a specific temp and automatically stops once it gets there. It’s more to turn it on before I get up and warm the house a bit. Same with the afternoon, I want to warm it up before we get home. I can turn off the unit manually later on.

As per my first comment though, because the temperature is a condition not a trigger, it doesn’t have to go below the lower temp during the time period, just be below it, right?

First, yes you can turn the unit off manually, but:

  • If you turn it off outside HA then HA will not be able to turn it back on, so it would seem that your automation is not functioning right
  • If you turn it off inside HA, then the time trigger fires every second (I think) so HA will turn it back on, because it does not know when to stop.

I am not sure I understand what you mean. The triggers fire every second it checks if the outside temp is below 12, if it is then turns on the heater, if it is not it does not.
So maybe it is also worth a condition to check if the heater is at the ‘on’ state.

tom

Sorry, I thought that might not make sense. For reference, I’m using a Remotec IR sensor to turn on and off a wall mounted reverse cycle ac unit.

In regards to the temp setting being a condition as opposed to a trigger, I saw in other forum posts that if you use the temp being below say 12 degrees as the trigger and then made the condition the time range (6am to 8am for example) then the automation would not work if the temp were to drop below 12 before the time range. If the time range is the trigger then the temp just has to be below 12 degrees to work not actually go below 12 at the right time. Make sense?

Unfortunately now I’m worried the automation will trigger continually through the trigger time period as it meets the conditons of temperature, day of the week and so forth.

On top of that my config is having issues with the “before” statement in the yaml for some reason.

I can probably solve the constant going off of the automation by doing what you said and recording the ac unit is actually on or not. I’m assuming I can find a way to log it being turned on, even though it isn’t really connected to HA per se. Then make that a condition of the automation.

Yeah. Actually I think it does not have time to “go under”, because triggering is a cycle, not a continuous something, and one cycle takes less then a second, so…

Ok I see you are starting to get the feeling… :slight_smile:
If you have thingies at home which are not even half way network linked (like I do), then you can use a Rpi and a relay board to switch things on and off.
something like this: https://www.youtube.com/watch?v=TFt480sxNWg
It can switch anything under 10Amps, which is 2200 W in case you are using 220 V. so it is more then enough for the most of household stuff switching.

with this everything becomes a switch in you HA config.

Unfortunately this setup rules out the usage of physical switches, because there is no way (or I have not found one working yet) to notify HA that you switched the switch, and also if the switch is on you can not turn off the device from HA :frowning:

Be careful with household electricity because it can kill you!
cheers