Creating automation, at a certain time and with a certain temperature

One standard phrase …
I am new to the world of smart home, I have read a lot and I have managed to do a lot of things on my own. :slight_smile:
I have a problem at the moment, I want the recirculation pump motor to start at a certain time, for example from 05:30 to 06:30, but to run until it reaches a temperature of eg 45c and to switch off, and to start the motor again when the temperature drops below 40c .

Sorry English is not my native language, which is probably recognizable
I use a sonoff with temperature sensor and ESPHOME …
I tried everything …
last configuration is:

alias: Recirculation Pump Turn on 
trigger:
  - platform: numeric_state
    entity_id: sensor.temperature
    below: '40'
condition:
  - condition: time
    after: '05:30'
    before: '06:30'
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
action:
  - type: turn_on
    device_id: 1abe2e05006ad89cb1739e294f449112
    entity_id: switch.sonoff_th16_relay
    domain: switch
mode: single

and I have another automation to turn off

alias: Recirculation Pump Turn off
trigger:
  - platform: numeric_state
    entity_id: sensor.temperature
    above: '45'
condition: []
action:
  - type: turn_off
    device_id: 1abe2e05006ad89cb1739e294f449112
    entity_id: switch.sonoff_th16_relay
    domain: switch
mode: single

But unfortunately it doesn’t work, can anyone help me

Thanks in advance
Peter

It works without this part:

condition:
  - condition: time
    after: '05:30'
    before: '06:30'
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri

But I want to stop the pump run at night, and while I’m at work…

Use a Generic Thermostat instead, then turn the thermostat on or off at the desired times.

1 Like

Thanks, I’ve been thinking about it, but I don’t know where to start :slight_smile:
I can understand when I read the config.yaml file what it is about, but I don’t know how to make it myself, can it help a little, for the time and temperature worked …

I prefer a visual editor, which is why I tried to do something in that part of HA

Well, there’s no way to configure a generic thermostat via the UI at the moment.

For the generic thermostat, you’ll need at the very least:

  • A temperature sensor
  • A switch to control the heat

You seem to have both. Take a look at the examples in the docs, this might work for you:

# Put this into your configuration.yaml, then go to Configuration -
# Server Controls, Check Configuration. If there's no error, restart HA.
climate:
  - platform: generic_thermostat
    name: Recirculation # Maybe choose sth. more descriptive here
    heater: switch.sonoff_th16_relay
    target_sensor: sensor.temperature # Are you sure this is the right sensor?
# Optional:
    min_temp: 30 # Minimum Temperature the Thermostat can be set to
    max_temp: 50 # Max. Temp. the Termostat can be set to 

Then, in the UI (Lovelace), create a new thermostat card, and select the thermostat you’ve created on the left. If all goes well, you now have a beautiful thermostat in your UI, we can automate it in the next step.

2 Likes

Thank you very much for helping me, we are moving towards something

Nice! :smiley:
The min/max temps can be adjusted in the config, you can also add a min_cycle_duration or a cold_tolerance if your setup requires that, see the docs for that, just add them as a key like min_temp

Set the temperature to 45°C, if that is the temperature you want to maintain.
If you want to maintain this temperature 24/7, you don’t need an automation, just turn on the Thermostat and set the temperature - that’s it!

Now for the automation, which is time-based, right?
So, create two automations (in theory, one could do it as well, but it’s not as intuitive):
The first automation will turn on the thermostat (e.g. at 05:30), the other will turn it off (e.g. at 06:30).
Turning the thermostat on/off only means that HA will keep an eye on the temperature and heat as needed (Well, just like a regular thermostat).
You’ll do that by setting a time trigger, which you’ve already done in the one you’ve pasted here, so now you’ll need to add an action, this will be a Call Service action, as the service, select climate.turn_on or climate.turn_off.

Here is an overview of all climate services (obviously stuff like set_swing_mode won’t work for you, since there’s no fan configured in your setup)

Now, you could also call climate.set_temperature after turning on the thermostat to make sure it’s at 45°C. If you don’t, it will use the latest temperature that was set (either in the UI or via an automation)

2 Likes

Thank you so much.
I succeeded :slight_smile:
I may not be grateful, but I have another question, if I want to choose a time for certain days of the week, can I do it with Conditions instead of Triggers?
It’s hard to wait for changes to test something.
Anyway I learned a lot and thank you very much. :beer:

Hey, good job! :partying_face: If my answers helped you, you can mark one as the solution as well.
You could try sth. like this:

Basically, set the time as a trigger, then check for the weekday in a condition, yes.
Have fun!

I will, but I don’t know how :rofl: :rofl: :rofl: :rofl:

Oh, maybe that’s not available in this forum.
If it is, there should be a “Solution” button next to the posts :thinking:
Anyway, you’re here to get your Home Assistant working, not to send me internet points :smiley:
Have fun on your journey :slight_smile:

1 Like