Switch on when it's past midnight and today's min temp is below X

Hi there! First timer here.
I’ve been managing simpler stuff, including getting HACS, but I’ve come up with an idea I’m not sure it’s even viable.

I have this electric water heater connected to a Meross smart plug. Right now I have an automation in the Meross app so that it turns on at half past midnight and turns off after 2 hours, enough to heat up the water. However, I’d like not needing to remember to take that off when the weather becomes warmer, and since the dashboard has a weather widget, I thought maybe there was a way to pull it?

My idea would be “if it’s Monday, Wednesday, or Saturaday, and the minimum temperature is over 16ºC, switch on at 0.30 and switch off at 2.30”. Is such a condition achievable in Home Assistant? and if so, how could I tackle it?

Thanks in advance!

Welcome! :smile:

Some suggestions…

First, make it two automations, one to switch on and one to switch off. You can combine them later when you get more confident, but starting out, there’s really nothing to be gained by cramming everything into one automation, and it can make things much harder.

Decide which of your “conditions” you want to be your trigger. Actually, a trigger is not a condition - it’s the change of state that starts the automation running - in this case probably the time. So, when the time changes from 00:29 to 00:30 the “turn on” automation starts.

The temperature is a condition. In an automation a condition’s function is to stop it running if it isn’t true, so your condition is > 16ºC.

Finally, the action is “turn on a switch”.

I’d suggest you get this working on a daily basis, then look at making it happen only on Monday, Wednesday or Saturday. There are several ways to do most things: you might set up a schedule helper, for example (look it up), or create three date time helpers (look it up) and have three triggers, or you might use a time condition, which can specify days of the week (look it up).

Finally, use the UI as much as you can. When you get something right you can look at the yaml to see how it works, but you don’t have to use yaml at all if you don’t want to.

So, what I’ve come up with looks like this

alias: Termo On
description: Si la mínima <15º a las 5.30am
trigger:
  - platform: time
    at: "00:30:00"
condition:
  - condition: state
    entity_id: weather.forecast_home
    attribute: temperature
    state: <15
    for:
      hours: 0
      minutes: 0
      seconds: 0
    weekday:
      - mon
      - wed
      - sat
action:
  - type: turn_on
    device_id: 0a578ef10f7ae1e13e5122c6d2498210
    entity_id: bf50c2a8b5d4f2496eae0758b79565f2
    domain: switch
mode: single

Will it do what I want?