Help with an automation for solar diversion to spa

I’ve got my hot tub (spa) integrated into HA (I can control everything), I soley want to turn Economy mode on, or Regular mode on.

I’ve got my Solar completely integrated, along with my grid export metering.

I want to create an automation that switches the hot tub from Economy mode to Standard mode (to heat) , during the day only, IF grid export exceeds 1800 watts.

Howerver, I ran into a conundrum once I started to think about the “companion automation” that will turn it back to economy mode .

As soon as the main automation kicks in, when there is 1800w or more of grid export, the automation won’t be satisfied any more (as the spa will; pull about 3500W, so if I create a second script to turn the spa back to economy mode once the grid export drops to below, say 1500w, it’ll activate immediately.

Any thoughts on how to approach this?

FYI - the tub has its own built in timer and runs in Ecxo mode from 6am till midnight - it heats between midnight and 6am when I pay a LOT less for electricity. The aim is simply to harvest energy that is being wasted into the grid (which I don’t get paid for)

Of course it’s just occurred to me that I could crate a second automation to turn economy mode back on when grid import exceeds hot tub power (3500w) less 1800w (ISH). That should cover most eventualities.

Is there a more elegant way of doing this I wonder ?

There are many ways to do things in HA.

You could set up a simple automation with two triggers

  1. Triggers
    • If ISH exceeds 1800 W for more than 15 min
    • If ISH is lower than 1800 W for more than 15
  2. Conditons
    • a simple if/else:
      If ISH > 1800 W then switch Hot tub to standard
      else switch to economy

Set it up in the automation UI, That way you don’t have to bother about the yaml syntax.

The 15 min is something up to your decision. You should define a time hysteresis in order to not have the tub switching on an doff with every cloud.

EDIT: You can define a third trigger for your 3500 W threshold. Rather than a simple if/then you would have three options that address the cases. Set up a small table with your thesholds and actions you want to perform and you will quickly see which triggers you need…

Hmmm - trying to get my head round the logic of this

  • an automation is triggered by its trigger - its’ not always “running” - so I have to consider enabling AND disabling my “switch” in all circumstances, but I don’t want the “off” part to trigger unless the “on” part has run before - if you see what I mean (monitor change of state of automation I guess?)

  • I want this:

If Grid Export >1800W for 3 mins

Then - Change hot tub mode to “standard”.

And then I want to consequently monitor:

If grid IMPORT >1800W

Then - change the hot tub mode back to “Economy”

(the 1800W figures being the same for import and export is a coincidence - hot tub uses 3500w heating. 3500-1800 = 1700. 1800 gives a little hsyteresis)

So I’ve created an automation like this: (You can’t see the mode change in my screen grab so I’ve added captions)

(more below)

By my reckoning, it’ll trigger if I’m exporting over 1800w for 3 mins, OR, importing more than 1800W for 2 mins, THEN, it’ll EITHER turn on standard mode (heating) IF Export is STILL over 1800W, othewise it’ll switch back to Economy mode.

And it’ll only operate between 9am and 23:50 (as I always want it on Eco mode from midnight till 9am as I have a super cheap tarrif then. - Eco mode actually tells the hot tub (internally) to never heat outside of 00:00 to 06:00.). Standard mode tells it to heat when it wants.

The only catch with all of this is now, during the day, if I have something like the oven on, but I want to manually heat the tub some more, the automation will trigger and keep turning off the heating as it’ll see a big power import.

I almost thing I want two automations - One that sees export power wastage and turns on the tub, and a seperate one that only runs once the first one has been triggered.

I think I’m talking myself round in circles :slight_smile: