Going crazy with a simple automation that I can't get to work, help please!

So I have a Wemos D1 Mini with a Dallas Temp Sensor DS18B20 probe.
The probe is inside a paddling pool and is providing temperature readings.
I also have a small pump that is connected to power through a Tapo TP105 plug.
What I want is:

  • Wemos reports the water temperature every 5 minutes
  • If the temperature is under 29 degrees, the pump must turn on
  • If the temperature is over 29 degrees, the pump turns off
  • All the above needs to be done between 09:00 and 18:00
  • If at 09:00 the pump is off, it needs to turn on
  • If at 18:00 the pump is on, it needs to turn off

Here’s what I have so far:

alias: POOL Heating Pump depending on water temp and time
description: ""
trigger:
  - type: temperature
    platform: device
    device_id: fc8bc4f467b946e489d52a49230079d2
    entity_id: 85b0502350dc5685f07ad3191ec2add3
    domain: sensor
    below: 29
    id: Temp below 29 degrees
  - type: temperature
    platform: device
    device_id: fc8bc4f467b946e489d52a49230079d2
    entity_id: 85b0502350dc5685f07ad3191ec2add3
    domain: sensor
    id: Temp above 29 degrees
    above: 29
condition:
  - condition: time
    after: "09:00:00"
    before: "18:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Temp below 29 degrees
        sequence:
          - type: turn_on
            device_id: 36ecb0da9389b8eef7dc54033a08e022
            entity_id: a88b180b1393eb390401de31b1671420
            domain: switch
      - conditions:
          - condition: trigger
            id:
              - Temp above 29 degrees
        sequence:
          - type: turn_off
            device_id: 36ecb0da9389b8eef7dc54033a08e022
            entity_id: a88b180b1393eb390401de31b1671420
            domain: switch
mode: single

The automation does not work and there is nothing in the logs. Yet, I can manually turn the pump on and off through the entity switch

You nee to realize two things:

  • Triggers only happen when the test in it changes from false to true
  • Each condition you have also needs a trigger

The reasons why can be found in this post:

To get it to work reliably, you need to add triggers for the start of the timeframe, and with it also extra conditions that test for the temperatures (again). That is the bit in the post linked above with the title " My automation does not always work (AKA: why won’t the trigger always fire)".

It will complicate using trigger ids in the action part, so using separate automations for on and off might be a lot easier to read and understand.

Your automation is designed to trigger when the temperature crosses the threshold value of 29 degrees. In other words, at the moment in time when the temperature decreases from above 29 to below 29 or vice versa. So if the current temperature is 27, nothing will happen until the moment it rises above 29.

After it crosses the threshold value, it checks if the current time is between 9:00 and 18:00. If it is then it proceeds to either turn on or turn off the switch. If it is not within the time range, nothing happens and nothing will happen until the automation is triggered again.

The automation does nothing when the time becomes 09:00 or 18:00 because there’s no Time Trigger.

Is that how you expected it would work?

Thank you @Edwin_D
I can almost understand the link you posted, but almost.
I also tried this, which I assume for the same reasons didn’t work:

alias: POOL Heating pump ON if temp under 29 degrees
description: ""
trigger:
  - type: temperature
    platform: device
    device_id: fc8bc4f467b946e489d52a49230079d2
    entity_id: 85b0502350dc5685f07ad3191ec2add3
    domain: sensor
    below: 29
condition: []
action:
  - type: turn_on
    device_id: 36ecb0da9389b8eef7dc54033a08e022
    entity_id: a88b180b1393eb390401de31b1671420
    domain: switch
mode: single

Hi @123
No, it’s not, I have definitely messed it up, but I cannot get my head around how to introduce this check to be done periodically instead of only when crossing the threshold, or how to introduce a Time Trigger.
For the first part, I am completely clueless.
For the second, I can create a simple automation that turns the pump on at 09:00 and turns it off at 18:00. I think that’s the easy part.

No worries, it’s very common to misunderstand how a Numeric Trigger works. It only triggers when the value crosses the threshold because, for most applications, that’s the most efficient method.

@Edwin_D , shouldn’t this one be working?

alias: POOL Heat Pump Turn ON if water temp under 29 degrees
description: ""
trigger:
  - platform: time_pattern
    minutes: "5"
condition:
  - condition: time
    after: "09:00:00"
    before: "18:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
  - condition: numeric_state
    entity_id: sensor.wemos1_temp
    below: 29
action:
  - type: turn_on
    device_id: 36ecb0da9389b8eef7dc54033a08e022
    entity_id: a88b180b1393eb390401de31b1671420
    domain: switch
mode: single

It would, but as explained in the post I linked it is not the best way to go about it, and it is not necessary to check every five minutes. For one, it could now take up to 5 minutes to respond to temperature changes. And if you want some form of manual control, you cannot.

if your automation only fires on the temperature trigger and at the one time of the day time the automation should start being active, or at the end of the period if that is when it should turn off, then that is enough. So at 9:00 and 18:00 like you said in your first post.

It is all explained in the post I linked. You need one trigger on temperature and one on a specific time (9:00 for on, 18:00 for off), and also a condition for the temperature and the time range.

1 Like

Thank you!

1 Like