Automation working sporadically

I have an automation that turns on my hot water via the Hive when it falls below 38C.
The sensor on the hot water tank used tosend an MQTT message ad the automation worked well, I then changed the sensor over to ESPHome.
My automation chaecks the water temp and the time, if between 23:00 and 06:00 it doesn’t switch the hot ware on.
The problem I’m having is that if the temp falls below 38 between 23:00 and 06:00 it stops the water from heating, as it should, but then it doesn’t trigger the hot water after 06:00 and I can’t figure out why?
Anyone got any suggestions?
Here’s the YAML: -

alias: Switch on Hot water boost
description: ""
  - type: temperature
    platform: device
    device_id: d098f5937883e18612fe1844648a8f8d
    entity_id: 23bd8d9c4b442e1186e79c415a92707a
    domain: sensor
    below: 38
  - condition: time
    before: "23:00:00"
    after: "06:00:00"
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
  - service: hive.boost_hot_water
      entity_id: water_heater.thermostat_3
      time_period: "00:30:00"
      on_off: "on"
mode: single

You need an extra trigger at the start if the time in your condition for that, and if that triggers you also need a condition for the temperature. Basically, if you have multiple conditions to be met, you need a trigger and a condition for each. In your case the conditions are the temperature and the timeframe. I explained it in this post, under “My automation does not always work”:

1 Like

OK, I thought that was the answer, and it probably is but I thought the Trigger was “when the hot water temp changes” so I thought that the trigger would happen every time the temp changed so if it went down to 36 before 06:00 and the 35 just after 06:00 then the trigger would be tested again and found to be below 38 and then would turn on the hot water.
Is it not the case that the trigger is tested whenever the temp changes, as it says?

Nope, the trigger is when the temperature goes below 38. So once it goes below that, it won’t trigger again unless it goes back above it first.

Fair enough, the description needs work then :slight_smile:

What do you suggest to improve it?

The current description for a Numeric State Trigger says it only triggers when the entity’s value crosses the threshold value. It also has an extensive Note explaining the meaning of “crossing the threshold”.

Crossing the threshold means that the trigger only fires if the state wasn’t previously within the threshold. If the current state of your entity is 50 and you set the threshold to below: 75 , the trigger would not fire if the state changed to e.g. 49 or 72 because the threshold was never crossed. The state would first have to change to e.g. 76 and then to e.g. 74 for the trigger to fire.

I think the confusion is that I used a Device trigger which doesn’t mention crossing a threshold it just states a temperature change.
I may be completely wrong but that’s what I did.

It’s always best to read the documentation and not infer behavior exclusively from the UI’s brief description.

The Device Trigger you selected is equivalent to a Numeric State Trigger.

Having said that, I do agree that what’s written in the UI can easily mislead one to believe it triggers for every change in the entity’s value.

Oh well, I live and learn. (maybe Paul Hibbert has a point)
I just added another time triggered automation to check the temp at 06:01 in the morning and if the temp is below 38 switch on the boost, hopefully that will fix it.