Water boiler automation using helper

Hello HA Community,
please can you help me

I am struggling to make this automation work.
Namely, I have four time helpers created:

  - entity: input_datetime.geyser_on_time_mon_fri
  - entity: input_datetime.geyser_on_time_sat_sun
  - entity: input_datetime.geyser_off_time_mon_fri
  - entity: input_datetime.geyser_off_time_sat_sun

nothing to special with them and the automation as:

- id: "00050"
  alias: Geyser ON Automation
  description: Geyser ON Automation
  mode: single
  trigger:
    - platform: time_pattern
      minutes: /05
  condition:
    - condition: and
      conditions:
        - condition: numeric_state
          entity_id: sensor.geyser_ds18b20_temperature
          below: "52"
        - condition: and
          conditions:
            - condition: state
              entity_id: switch.geyser_switch
              state: "off"
            - condition: time
              after: 'input_datetime.geyser_on_time_mon_fri'
              before: 'input_datetime.geyser_off_time_mon_fri'
              weekday:
                - mon
                - tue
                - wed
                - thu
                - fri
            - condition: time
              after: 'input_datetime.geyser_on_time_sat_sun'
              before: 'input_datetime.geyser_off_time_sat_sun'
              weekday:
                - sat
                - sun
  action:
    - service: switch.turn_on
      entity_id: switch.geyser_switch

This is unfortunately not triggering at all :cry:
There are no errors but it is simply not working

Can anyone help and point me in the right direction, what am I doing wrong? :thinking:

Why do you have a time pattern trigger when you have a perfectly fine numeric state that could be the trigger?

I assume you meant numeric state of the temperature sensor?
If that’s the case, I don’t want to keep the water heater water always hot, hence creating automation based on conditions :slight_smile:

Hope that answers

Your condition with date and time will never trigger as the condition is AND and you are verifying the days in two conditions which are exclusive: you cannot be between mon and fri AND between sat and sun at the same time so try the following:

- id: "00050"
  alias: Geyser ON Automation
  description: Geyser ON Automation
  mode: single
  trigger:
    - platform: time_pattern
      minutes: /05
  condition:
    - condition: and
      conditions:
        - condition: numeric_state
          entity_id: sensor.geyser_ds18b20_temperature
          below: "52"
        - condition: state
          entity_id: switch.geyser_switch
          state: "off"
        - condition: or
          conditions:
            - condition: time
              after: 'input_datetime.geyser_on_time_mon_fri'
              before: 'input_datetime.geyser_off_time_mon_fri'
              weekday:
                - mon
                - tue
                - wed
                - thu
                - fri
            - condition: time
              after: 'input_datetime.geyser_on_time_sat_sun'
              before: 'input_datetime.geyser_off_time_sat_sun'
              weekday:
                - sat
                - sun
  action:
    - service: switch.turn_on
      entity_id: switch.geyser_switch

But you run the automation every five minutes.
It will not remain off for very long. And you have nothing turning off the heater anyways either.

Post how you want the automation to function. A time pattern is never the solution

I have another automation that turns the water heater off based on water temperature :slight_smile:
I do agree that there are more elegant ways for this, I guess I just didn’t;'t find them yet

I would prefer using numeric_state if it also had day input, e.g. numeric state for mon,tue…fri and then another one for sat, sun…

I changed it and am testing it now :slight_smile:
Will advise asap

Second question: could you share the time you have entered for those helpers:

  - entity: input_datetime.geyser_on_time_mon_fri
  - entity: input_datetime.geyser_on_time_sat_sun
  - entity: input_datetime.geyser_off_time_mon_fri
  - entity: input_datetime.geyser_off_time_sat_sun

because even with the proposal I made, this could not trigger neither…

example: let’s say that you entered 10PM for input_datetime.geyser_on_time_mon_fri and 6AM for input_datetime.geyser_off_time_mon_fri, the following automation will never be true:

            - condition: time
              after: 'input_datetime.geyser_on_time_mon_fri'
              before: 'input_datetime.geyser_off_time_mon_fri'
              weekday:
                - mon
                - tue
                - wed
                - thu
                - fri

as the time being after 10PM and before 6AM will never be true. example: let’s say that the actual time is 10:30PM, so the condition after 10PM is true but the condition before 6PM is false ! because HA is considering the condition “before 6PM” as the actual time is between (00:00 and 06:00AM)…

Perfectly possible. still no reason to use time patterns.

Post how you want the on/off to function and we can help you.
Posting suggestions of how to fix a bad automation is not helpful. It’s better to remove the crap (time pattern) and do a proper automation

In this case is off_time is BEFORE on_time, you have to write your conditions like this:

- id: "00050"
  alias: Geyser ON Automation
  description: Geyser ON Automation
  mode: single
  trigger:
    - platform: time_pattern
      minutes: /05
  condition:
    - condition: and
      conditions:
        - condition: numeric_state
          entity_id: sensor.geyser_ds18b20_temperature
          below: "52"
        - condition: state
          entity_id: switch.geyser_switch
          state: "off"
        - condition: or
          conditions:
            - condition: time
              before: 'input_datetime.geyser_off_time_mon_fri'
              weekday:
                - mon
                - tue
                - wed
                - thu
                - fri
            - condition: time
              after: 'input_datetime.geyser_on_time_mon_fri'
              weekday:
                - mon
                - tue
                - wed
                - thu
                - fri
            - condition: time
              before: 'input_datetime.geyser_off_time_sat_sun'
              weekday:
                - sat
                - sun
            - condition: time
              after: 'input_datetime.geyser_on_time_sat_sun
              weekday:
                - sat
                - sun
  action:
    - service: switch.turn_on
      entity_id: switch.geyser_switch

So in simple, I would like to have on-off time for mon-fri and then on-off time for sat-sun

I do have an off automation for when the water temperature reaches 70C
Once the water temp fall under 52C, it should turn on if its between the time specified.

Hope I make sense

I see…I will do so and advise :slight_smile:

Ok, so it did turn the water heater on :slight_smile:

Here is two automation that are supposed to manage the water heater, sorry for not uploading before

  alias: Geyser ON Automation
  description: Geyser ON Automation
  mode: single
  trigger:
    - platform: time_pattern
      minutes: /05
  condition:
    - condition: and
      conditions:
        - condition: numeric_state
          entity_id: sensor.geyser_ds18b20_temperature
          below: "52"
        - condition: or
          conditions:
            - condition: state
              entity_id: switch.geyser_switch
              state: "off"
            - condition: time
              after: 'input_datetime.geyser_on_time_mon_fri'
              before: 'input_datetime.geyser_off_time_mon_fri'
              weekday:
                - mon
                - tue
                - wed
                - thu
                - fri
            - condition: time
              after: 'input_datetime.geyser_on_time_sat_sun'
              before: 'input_datetime.geyser_off_time_sat_sun'
              weekday:
                - sat
                - sun
  action:
    - service: switch.turn_on
      entity_id: switch.geyser_switch
      
###############################################

- id: "00051"
  alias: Geyser OFF Automation
  description: Geyser OFF Automation
  mode: single
  trigger:
    - platform: time_pattern
      minutes: /05
  condition:
    - condition: and
      conditions:
        - condition: state
          entity_id: switch.geyser_switch
          state: "on"
        - condition: time
          after: "input_datetime.geyser_off_time_mon_fri"
          before: "input_datetime.geyser_on_time_mon_fri"
          weekday:
            - mon
            - tue
            - wed
            - thu
            - fri
        - condition: time
          after: "input_datetime.geyser_off_time_sat_sun"
          before: "input_datetime.geyser_on_time_sat_sun"
          weekday:
            - sat
            - sun
  action:
    - service: switch.turn_off
      entity_id: switch.geyser_switch

###############################################```

Ok than my first proposal will work… no need to split the ON/OFF time condition as your OFF time is greather than the ON time…

now its just not turning off :thinking:

What about this?

alias: New Automation
description: ''
mode: single
trigger:
  - platform: numeric_state
    entity_id: sensor.geyser_ds18b20_temperature
    below: '52'
    id: 'on'
  - platform: numeric_state
    entity_id: sensor.geyser_ds18b20_temperature
    above: '70'
    id: 'off'
condition: []
action:
  - choose:
      - conditions:
          - condition: time
            after: input_datetime.geyser_on_time_mon_fri
            before: input_datetime.geyser_off_time_mon_fri
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
          - condition: trigger
            id: 'on'
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.geyser_switch
      - conditions:
          - condition: time
            after: input_datetime.geyser_on_time_sat_sun
            before: input_datetime.geyser_off_time_sat_sun
            weekday:
              - sat
              - sun
          - condition: trigger
            id: 'on'
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.geyser_switch
      - conditions:
          - condition: trigger
            id: 'off'
        sequence:
          - service: switch.turn_off
            data: {}
            target:
              entity_id: switch.geyser_switch
    default: []

Keep in mind that this means the temperature has to pass the threshold values as opposed to the time pattern methods.

Edit.

I forgot to turn on if the temperature is already below but before time. This added a time trigger to make sure it gets going in the morning.

alias: New Automation
description: ''
mode: single
trigger:
  - platform: numeric_state
    entity_id: sensor.geyser_ds18b20_temperature
    below: '52'
    id: 'on'
  - platform: numeric_state
    entity_id: sensor.geyser_ds18b20_temperature
    above: '70'
    id: 'off'
  - platform: time
    at: input_datetime.geyser_on_time_mon_fri
    id: on_time_weekday
  - platform: time
    at: input_datetime.geyser_on_time_sat_sun
    id: on_time_weekend
condition: []
action:
  - choose:
      - conditions:
          - condition: time
            after: input_datetime.geyser_on_time_mon_fri
            before: input_datetime.geyser_off_time_mon_fri
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
          - condition: trigger
            id: 'on'
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.geyser_switch
      - conditions:
          - condition: time
            after: input_datetime.geyser_on_time_sat_sun
            before: input_datetime.geyser_off_time_sat_sun
            weekday:
              - sat
              - sun
          - condition: trigger
            id: 'on'
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.geyser_switch
      - conditions:
          - condition: trigger
            id: 'off'
        sequence:
          - service: switch.turn_off
            data: {}
            target:
              entity_id: switch.geyser_switch
      - conditions:
          - condition: trigger
            id: on_time_weekday
          - condition: time
            weekday:
              - mon
              - tue
              - thu
              - wed
              - fri
          - condition: numeric_state
            entity_id: sensor.geyser_ds18b20_temperature
            below: '52'
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.geyser_switch
      - conditions: 
          - condition: trigger
            id: on_time_weekend
          - condition: time
            weekday:
              - sat
              - sun
          - condition: numeric_state
            entity_id: sensor.geyser_ds18b20_temperature
            below: '52'
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.geyser_switch
    default: []
1 Like

Same reason than explained above (the actual time cannot be before and after the triggers at the same time), you have to split your conditions:

- id: "00051"
  alias: Geyser OFF Automation
  description: Geyser OFF Automation
  mode: single
  trigger:
    - platform: time_pattern
      minutes: /05
  condition:
    - condition: and
      conditions:
        - condition: state
          entity_id: switch.geyser_switch
          state: "on"
        - condition: or
          conditions:
             - condition: time
               before: "input_datetime.geyser_on_time_mon_fri"
               weekday:
                 - mon
                 - tue
                 - wed
                 - thu
                 - fri
             - condition: time
               after: "input_datetime.geyser_off_time_mon_fri"
               weekday:
                 - mon
                 - tue
                 - wed
                 - thu
                 - fri
             - condition: time
               before: "input_datetime.geyser_on_time_sat_sun"
               weekday:
                 - sat
                 - sun
             - condition: time
               after: "input_datetime.geyser_off_time_sat_sun"
               weekday:
                 - sat
                 - sun
  action:
    - service: switch.turn_off
      entity_id: switch.geyser_switch
1 Like

I need to leave now, but I will be able to do some testing in the afternoon

Thank you both for great ideas and suggestions!
I really appreciate it :slight_smile:

I will provide feedback later in the day

After a bit more then 2 hours, I gave up on this solution :weary: :sob:

Water heater didn’t turn on and when I went through automation debugger, it executes and immediately turns off for some reason :cry:

How did you test the automation?