PV diverting control from Home Assistant (or other system)

the options available for diverting PV solar power to a water heater seem to be built around the microcontrollers (e.g. emontx, emonpi, Mk2 PV routers etc). They typically have a monitoring and a controlling component with a diverter logic running on the micro controller that does the monitoring.

I was hoping to decouple the monitoring and controlling components, and implement the logic somewhere else (not in the microcontroller firmware itself).

And build something more modular like:

Energy monitor > interface1 > Hub > interface2 > Load controller


  • energy monitor - could be an EmonTx+EmonHub or EmonTx with WiFi but could also be a smart utility meter
  • interface 1 - could be HTTP (like we have available on EmonCMS/EmonHub), or a smart meter interface like DSMR on a P1 port or Zigbee SEP.
  • the hub - a home automation system such as Home Assistant (for which integrations exist) or could be the EmonHub (if diverting control logic were added)
  • interface 2 - could be MQTT, HTTP, RF 433Mhz etc.
  • load controller - could be a Mk2, EmonTx via RF or a controller based on arduino or ESP, or even a smart plug, or DIY solution. To divert to a immersion heater, battery management system, electric car etc.

Disadvantage of this approach:

  • lower monitoring accuracy (depending on method used, the reporting interval)
  • delay in reacting to change in power measurements, diverted energy wouldn’t be as accurate as with microcontroller based systems.
  • multiple systems that can fail / complexity.

Benefits of this approach:

  • leverage energy monitoring capabilities of smart meters and PV inverters that expose APIs. (and no calibration needed)
  • modularity - change logic without changing firmwares. Extensibility.
  • allows for smarter diverting logic (create the logic as automations in your hub of choice, add loads, remote loads, include other parameters such as weather etc)
  • make energy diverting more easily available to a large community of home automation enthousiasts.

The main component which I believe is still missing (or seems to require a lot of DIY) is the load controller (to drive the triac/SSR and divert a specific amount of energy) with a more open API like MQTT. In its simplest form you could then expose this as a dimmable device to a home automation system. For example based on an EmonTx with WiFi.

Has anyone tried this?
Any negatives I have missed?
Any suggestions for a PLL diverter that can be controlled from Home Assistant or similar?

Kind of.
I run EmonTX to monitor the grid/solar/EV charger/battery. This is MQTT’ed to NodeRed, which makes the business decisions. My loads are fixed wattages, apart from the house battery which can vary its input. So the Hot Water heating is a fixed 600W, if there’s 600W of export, NR switched on the micro immersion heater. If the car is charging, it can only start from 1400W, so if it’s less than that NR puts the charger into standby (which may bring the immersion heater back online), if the export goes over 1400W/1800W/2200W/3400W then NR will increase the charge rate to car. All the while it will attempt to fit in the immersion, with the battery getting whatever is left over. If the immersion has heated the whole tank to 40C, then it will switch off and bring in a small 500W convector heater to warm the house a bit. I’ve not cracked reading the SOC from the car over bluetooth yet to get when to automatically stop the charge.
I have a vague plan to add a 100W electric element to the bathroom radiator to have a small load that would slot into the plan nicely.

Having it controlled from a central point certainly helps the mix and match, as the more loads you have the more complicated it gets. Just wish I had more PV capacity!


I wanted to divert solar power to sockets for ceramic heater and I thought there would be a bit much work with emon products.

I have only a couple of days experience trying something similar to what you are describing. I’m from a Unix background so went the Linux route. My laptop is Ubuntu 20.04 and I am tinkering with that base.

I have a Hildebrand/Glowmark IHD that has an MQTT output.
I installed Mosquitto on my laptop and Home Assistant. After a bit of frustration I got the json data into HA , the configuration HA has has changed recently and tutorials/info is catching up.
I installed an SMA Sunny Boy 3.0 which comes with a wifi connection and I enabled Modbus just in case.
I bought a Tapo/TP Link P110 from Currys for £10 which has in built power monitoring. I got that picked up in HA with a custom component from Github.
So in HA I have sensors that can read my current power consumption - net of solar, I can read power in and out from my Smets2 smart meter. I can see what is coming from each strand of my solar panels and see how much is going in to the grid. I can control the power socket and read how much power is being consumed by the device connected. This is as near real time as I need, about 10 seconds for each. device.
My next step is to have a bash at some automation/control but I have not got that far.


That’s awesome! I like the idea of having many relatively small loads and a single variable load diverter like the immersion heater to consume whatever power is left. I also hadn’t considered variable loads with discrete increments. Is this common for car chargers?
I guess this works as long as the variable load/immersion heater is lowest priority.
I’m curious what your NodeRed flows look like.

Is that EmonTx > (RF) > EmonCMS > (MQTT) > NodeRed ?

Do you mind sharing what type charger you use and how you control this? I have yet to start looking into smart car chargers and house batteries.

pretty cool.

I love that SMA allows local access, (the SMA home assistant integration is using Local polling) so you don’t rely on a cloud service.

I use a Sonof S31 lite (zigbee) with similar capabilities (and also local access). Energy monitoring features of the plug seems quite useful to know how much the load is consuming (for example when it is on but not drawing a lot of power), but I guess it’s not absolutely required to be able to automate.

Good luck with the automations!

I jiggled things about a bit. I have two solar installations, one is a bit experimental in the garden with vertically mounted panels to an old second hand Sunny Boy 1200 that is dumb, I ran the supply through the tapo plug which does not know anything about power direction but I assume if there is power their it’s positive. I get a max of around 800 w of 6 panels so the plug should be fine. It seems generate most around the equinoxes but early days.
I’ve added 2 Local Bytes tasmota plugs to control the heaters, I could not get any Tapo ones they were out of stock everywhere I tried. They work fine.
The Home Assistant code - the yaml is not my favourite. I got it to divert power in an unscientific way, I am sure Robin’s ways is better but this works for what I need. I monitor what the house is using and how much power is coming in and turn things on or off depending on the sums. I’ll post a bit of code that I am using so people can see what yaml looks like. ( Bear in mind I have had a week learning this stuff :slight_smile: )

alias: Turn on Plug 1
description: Turn on plug 1 if threshold reached - heaters use around 570 or 1050 watts
# Poll every 10 seconds
  - platform: time_pattern
    seconds: /10
  - condition: and
      - condition: template
        value_template: "{% if available_power|int > trigger_value|int  %}true{% endif %}"
      - condition: numeric_state
        entity_id: sensor.liveelectricity
# power in kWh
        below: 0.01
  - type: turn_on
    device_id: 1105d9fe85213dfa257d70ee7d15cf27
    entity_id: switch.tasmota_1
    domain: switch
  available_power: >-
    {{ states.sensor.sb3_0_1av_40_308_grid_power.state|int +
    states.sensor.tapo1_current_energy.state|int }}
# heater power + a bit for house
  trigger_value: 700
mode: single

Looks like the # in my code has made my comments bold, never mind.

For future reference, when posting code or output, please put 3 ‘backticks’ (normally found at the top left of the keyboard) on a line of their own before the code, and 3 more backticks also on a line of their own after the code:


If it is something like php you can add a language identifier after the first 3 backticks: ```php or even ```text if you don’t want any language markup applied.

What the power usage of the heaters?
I realise that the plugs are “13A”, but trust me THEY ARE NOT!
I’ve used a few 13A plugs, but even running 2kW heaters for longer periods with destroy the plugs, and by destroy, I mean melt/char/smoke and potentially fire!
If they are less than 1kW you’ll probably be OK.

Yes, that’s it. There’s a “publish to MQTT” option in the Misc section, in the Input processing.

Ah, it’s a old dumb Rolec charger, with a new Viridian EPC (the actual controller) installed in it. This can can be ‘commanded’ by a resister value across one of its input ports, to set the charge power, this is set by a BBC Microbit controller with a DIY add-on board that I built. Don’t do this! :man_facepalming:
I recently found out the original Rolec EPC can be reprogrammed (it’s basically an Arduino!), to give it most of the features of an OpenEVSE controller (the features it can’t do are due to missing hardware in the box), this controller can be commanded over a serial link, so I’m going to give it a Pi Zero W (or maybe a ESP32) to connect it to the wifi network. This will also mean that the EPC can be commanded in 1A steps (from 6A to 32A) giving even better control over spare PV capacity! I just need to find the time…

Hmm… I looked at a picture, thought about the size, and… I believe you!

Assuming the switching element is a semiconductor device and not a relay, you’ve only got to think about the voltage drop across the switch and carrying 13 A, hence the power to be dissipated in an enclosed box of the size it is, to realise it could get mighty hot.

I’m using small ceramic heaters with a max out put of 1200w, but I use multiples at 600w, I’ve run them at 1200w for weeks over the summer but had to drop them back to 600w to extend the period of operation in the winter and I am adding another one.
Running small multiples gets round the fact I can’t vary the power out put based on available solar power and offers bit of fault tolerance and I can locate them where needed.

:+1: Excellent, safety first!

One other thought, these small smart plugs make an audible click when they are remotely turned on and off. So perhaps they do have some kind of small relay inside. I’ve not taken one apart - yet.

This would make a lot more sense. But do make sure you don’t have a large inductive load - the contact rating on inductive loads will be a small fraction of that for a purely resistive load.

just mentioning I do sort of the same . with my energymonitor which is based on wemos R3( uno/esp + espeasy) and emontx shield .

for reference the energymonitor will cascade up to 3-4 SSRs . but you can set a specific on wattage for the contact relays that will also cascade up to 4 contact relays ( timed delayed relays). when the fixed relays come on the SSR natural drops their loads to the heating elements to a specific set wattage point and then turn off the relays in sequence … I use time delayed relays, so if say I have and stove top electric element cooking something and it consonantly pulsing to control the heat output the fixed relays will stay on for x number of minutes/seconds before they turnoff just so I do not end up with contact relay loads pulsing on and off too quickly.
also the SSR and the contact relays can be controlled independently via domoticz, kapacitor or even within the espeasy firmware that at a specific time or condition turn on and off a specific relays or SSRs