Automating conditional power state for Hot Water Cylinder

Hi All

First time poster here and am looking for help to automate my hot water cylinder in order to reduce electricity consumption. Any guidance or tips are welcome, I am looking to learn how to do more complex automations but am struggling with the conditionals and multiple time triggers.

Sensors availabe:

  • Smart Switch controlling the power to the hot water cylinder
  • Temperature probe in the middle of the cylinder
  • Temperature probe at bottom of cylinder

Cylinder set up:

  • Heating coil at the bottom (manual, controlled by internal thermostat)
  • Fireplace Wet-back coil that occupies the middle 3rd of the cylinder

Here is how i am trying to go about it:

  • 0700 Turn off power to the hot water cylinder (Peak Power Rate)
  • 0900 Turn on power (Standard Power Rate)
  • 0920 Turn off power (20 minutes is enough to heat the cylinder to 55C at bottom, we normally do not use hot water during the day)
  • 1600 Turn on power (1 hour should be enough to bring the cylinder up to temp before peak power)
  • 1700 Turn off power (Peak Power)
  • 2100 Turn on power (Free Power)
  • 2200 Turn off power (Standard Power)
  • 2300 Turn on power (Low Power Rate)

That is the simple set up. What I am struggling with is how to set further conditions.

  • Condition 1: from 0000 - 0700, 0900 - 1700, 2100 - 2359 when the middle temperature sensor reaches 50C turn on until the bottom sensor reaches 55C

  • Condition 2 from 0700 - 0900 & 1700 - 2100 when middle sensor reaches 25C Turn on until bottom sensor reaches 40C

This is what I have so far automation wise (made in visual editor, exported as .yaml)

alias: Hot Water cylinder POWER SAVER
description: “”
triggers:

  • trigger: time
    at: “07:00:00”
    conditions:
    actions:
  • action: light.turn_off
    metadata: {}
    data: {}
    target:
    entity_id: light.hotwatercylinderpower
  • delay:
    hours: 1
    minutes: 0
    seconds: 0
    milliseconds: 0
  • action: light.turn_on
    metadata: {}
    data: {}
    target:
    entity_id: light.hotwatercylinderpower
  • delay:
    hours: 0
    minutes: 20
    seconds: 0
    milliseconds: 0
  • action: light.turn_off
    metadata: {}
    data: {}
    target:
    entity_id: light.hotwatercylinderpower
  • choose:
    • conditions:
      • condition: time
        after: “09:20:00”
        before: “16:00:00”
        weekday:
        • mon
        • tue
        • wed
        • thu
        • fri
        • sat
        • sun
      • type: is_temperature
        condition: device
        device_id: 24033a0f0fbfc31bfdd2b519a8eb66de
        entity_id: b23c9e7d45492ffd25e7bbda568e0c7f
        domain: sensor
        below: 50
        sequence:
      • action: light.turn_on
        metadata: {}
        data: {}
        target:
        entity_id: light.hotwatercylinderpower
      • if:
        • type: is_temperature
          condition: device
          device_id: 9681e962b629c3e40208342a11d413d5
          entity_id: 661ee82a03a7b3090eaf5616ff24bac3
          domain: sensor
          above: 50
          then:
        • action: light.turn_off
          metadata: {}
          data: {}
          target:
          entity_id: light.hotwatercylinderpower
  • choose:
    • conditions:
      • condition: time
        after: “17:00:00”
        weekday:
        • sun
        • sat
        • fri
        • thu
        • wed
        • tue
        • mon
          sequence:
      • action: light.turn_off
        metadata: {}
        data: {}
        target:
        entity_id: light.hotwatercylinderpower
      • wait_for_trigger:
        • trigger: time
          at: “21:00:00”
      • action: light.turn_on
        metadata: {}
        data: {}
        target:
        entity_id: light.hotwatercylinderpower
        mode: single

To start with, don’t try to do it all in one automation. Write a separate automation for each process you can identify - you can combine them later if you want to but there’s no real advantage in that, and it can make maintenance much harder.

In this case, for example, you might have one automation with multiple time triggers to turn power on and another to turn it off. When those are working you can think about adding conditions. Those too could be separate automations, with temperatures as triggers and times as conditions.

Secondly, it’s not a good idea to have delays of more than a minute or two - if Home Assistant restarts the automation will be aborted and won’t run again until the trigger fires again.

Thirdly, you’ll find it easier if you use entity IDs rather than device IDs.

Finally, please post code as preformatted text (</> in the toolbar - in the cogwheel menu if you’re using a tablet or phone). This makes it easier to follow, and others can copy your code to try it out.

Is the heater a electric heater?
Is that smart switch beefy enough for the job?

And I would rather make that automation using a schedule helper to make a visual, easy to maintain interface.
Then the automation just triggers on the schedule

Thanks for the feedback and questions.

I did have the Hot water Cylinder as part of multiple automations but was concernered about them possibly conflicting with each other. Will run it as separeate automations from here as that is much easier to do.

I was not aware of the potential issue around delays possibly not working over long periods and will check my other automations for this.

I will have a look at using entity ID’s in my automations, I have just been using the visual builder so far.

Thanks for the heads up around the </> function. I have seen others .yaml code here and did not realise it could be done through this text box. Make sense in hindsight though.

As to the questions:
The hot water cylinder has an electric coil in it (3KW)
The smart switch is cheap, but supposedly rated to 6KW. (this one)

I will have a look at schedule helpers, thanks!

Regards

Konrad