My automation won't start next day even it works just fine today

Hello,

I created “simple” automation to start/stop my Sonoff TH10 “power supply” based on temperature values receiving from temp sensor…

It all works as I expect, but… only for a single day, next day when I expect it start again at 8:00 if condition met (which is always met) nothing happen and I have to stop/start the automation itself, then it is immediately triggered properly…

I believe I miss something in my automation - can someone please help? Automation is done through automation UI not in the automation.yaml directly as I dont have enough knowledge yet …

- id: '1604173344710'
  alias: < 22° ON
  description:
  trigger:
  - platform: numeric_state
    entity_id: sensor.tasmota_ds18b20_temperature
    below: '22.0'
  condition:
  - condition: time
    after: 08:00:00
    before: '17:00:00'
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
  action:
  - type: turn_on
    device_id: 72203f9875e8b2dc75b5648a96de6a21
    entity_id: switch.tasmota
    domain: switch
  mode: single
  
- id: '1604173380783'
  alias: > 23° OFF
  description:
  trigger:
  - platform: numeric_state
    entity_id: sensor.tasmota_ds18b20_temperature
    above: '23.0'
  condition:
  - condition: time
    after: 08:00:00
    before: '17:00:00'
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
  action:
  - type: turn_off
    device_id: 72203f9875e8b2dc75b5648a96de6a21
    entity_id: switch.tasmota
    domain: switch
  mode: single

Thanks a lot

You use a numeric state as a trigger. This will only trigger when the threshold has been crossed.
In your example the automation will trigger the first time when the value goes from above 22 to below 22, it will then only trigger again when the value goes above 22 and then below 22 again.
If the value stays below 22 it will not trigger.

1 Like

Going out on a limb here but this trigger gets a lot of ‘grief’ over misunderstanding about how it works.
It does not fire just being below 22 degrees.
It fires on the transition from 22 degrees (or above) to below 22 degrees.

You would be better to check the time pattern trigger (say every 10 minutes)
Check conditions : -
Mon to Fri
Between 08:00 and 17:00
And if < 22 then turn on

The second automation makes no sense
If it’s just below 23 degrees (say 22.9) at 16:59 the heating won’t turn off and a minute later it can’t turn off because of your time limits.
Remove the second time limits and just to be sure turn the heating off at 17:00 anyway

@Burningstone Snap.!

1 Like

thanks a lot, I got your point and this is exactly why I will never learn “programming” as…my head does not gets this logic :slight_smile:

can you suggest how to improve it so it will will continuously check the threshold and if its within 8 - 17 every day it will trigger if the value is below and not only on the transition/cross?

thank you very much as well…
second condition is to turn off once its above 23, then leave the room temperature to drop below 22 and trigger again the first automation - and it works in this way but… when it stays below 22 after 17h then another day it wont start again because of what @Burningstone just explained to me probably

in fact what is my goal is to keep room temperature between 22 - 23 degrees during a day and after 17h another automation (not listed here) takes over and do the same but with values between 19-21 degrees

Use a time pattern trigger as @Mutt suggested to check the temp every x mins.

This will do as you requested : -

automation:
  - alias: au_weekday_heat_on
    trigger:
      - platform: time_pattern
        minutes: '/10'
    condition:
      - condition: time
        after: '08:00:00'
        before: '17:00:00'
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
      - condition: template
        value: "{{ states('sensor.tasmota_ds18b20_temperature') | float < 22 }}"
    action:
      - service: switch.turn_on
        entity_id: switch.tasmota

  - alias: au_weekday_heat_off
    trigger:
      - platform: time_pattern
        minutes: '/10'
    condition:
      - condition: template
        value: "{{ states('sensor.tasmota_ds18b20_temperature') | float > 23 }}"
    action:
      - service: switch.turn_off
        entity_id: switch.tasmota

Note : if the temperature is EVER above 23 (when checked every 10 minutes) this will turn the switch ‘off’ (ie this will happen at weekends and outside your times for heat too, but turning a switch off that is already off is okay.
Note: the /10 minutes checks the value of the current minute (of the current hour) and if the minute ‘x’ when divided by 10 has no remainder (ie 0, 10, 20, 30, 40, 50) it will trigger.

Note that if at if at 17:00 the temperature is at 22.9 degrees, the heating will stay on. if it remains at 22.9 degrees for the next 12 months then the heating will stay on. be careful what you ask for as these things can have some peculiar side effects.

What I’d probably do in this situation is use the generic thermostat and I’d change the set point via a sensor so that it is at 22° between the times you want and at all other times would sit at say 6° (for frost protection) But this is a bit beyond the scope of this question.

2 Likes

Sticking my nose in as I was thinking the same thing… stembus I think this might achieve what you want much more nicely.

@Burningstone @Mutt thanks a lot guys, finally I realized that I misunderstood trigger, now its clear to me and I will follow your advice with trigger timer and temp value under condition and not in trigger …

I will also try to implement “template” way of code, which I like a lot :slight_smile:

Thank you

@Dolores now I see generic Thermostat is not only “term” but its real piece of code, I am going to discover that one as well…

Thank you all

1 Like