question

agamos69 avatar image
agamos69 asked

How to enable/disable ESS using MQTT

I have a the following setup:

Multiplus II 48/5000

MPPT 450/100

Cerbo GX

Pylontech batteries


I have it setup as ESS with charging schedules for overnight charging during cheap rate. I have a Home Assistant automation that sets the SOC limit using MQTT based upon expected solar generation the next day. I had expected an individual ESS schedule to stop when the SOC level has been reached but it continues to draw power from the grid until the schedule ends. My preference would be to automate the battery charging overnight via MQTT rather than using the schedule. Is this possible? And if so, can someone please provide some advice on how it is achieved.

Thanks.

ESSMQTT
1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Ben Watts avatar image Ben Watts commented ·
I’ve played around with the Pymodbus package a few times from a laptop and raspberry pi.


It felt like a relatively low code way of controlling some basic aspects of my Victron. After looking up the register number for a setting (e.g. the grid set point), you could quite easily make changes over local LAN connection.


I’d be interested to know if anyone could contrast the experience of this with MQTT. Is either obviously superior?


I agree with the original question that the default scheduled charging behaviour is not as I would expect. If I set the SOC to 50% and it enters the off peak period already at 75%, I’d expect it to continue discharging to that level and then switch to grid, or at least have an option for that behaviour.


Many people are surprised just how cheap some of the EV tariffs are for off peak, and from what I understand they are probably loss leading. That said, I suspect future dynamic tariffs will have plenty of very cheap periods at time of abundant wind generation (in GB at least!). The round trip efficiency is also a valid point. For me, having my batteries in my utility, the waste heat isn’t entirely lost, as it gently warms my house especially while charging overnight. I guess it would be different were the batteries outdoors.

0 Likes 0 ·
5 Answers
johnone avatar image
johnone answered ·

A good question - something I'm part way through developing for my system (which is v similar to your setup).

Here's an example of setting an ESS scheduled charge SOC target:

mosquitto_pub -h cerbo.lan.ip.address -t "W/xxxxxxxxxxx/settings/0/Settings/CGwacs/BatteryLife/Schedule/Charge/0/Soc" -m '{"value": "59"}'

In e.g. MQTT Explorer all of the schedule charge settings are available in the area of 'settings/0/Settings/CGwacs/BatteryLife/Schedule'. Then just a matter of setting each parameter as your scripts require.

If you don't mind, how are you calculating 'expected solar generation the next day'?

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

agamos69 avatar image
agamos69 answered ·

Thanks for your response.

I am already using those MQTT messages to set the schedule and the SOC level. Although I cannot find any MQTT message to enable/disable a schedule per se. I notice that a disabled schedule has it's day set to -7, which I have successfully used to disable a schedule but switching it back to a valid day (or 7 for every day) does not reenable it, I find I have to go to the Cerbo's page and manually enable it, which defeats the purpose.

That being said, this does not resolve the issue that the schedule does not terminate upon reaching the SOC, it simply stops charging the battery and the house load remains to be fed from the grid, which in my mind is wasteful. I was tinkering with setting up 30 minute intervals and using the previously mentioned -7 -> 7 to try and enable a future schedule on demand but this fails as noted.

Expected solar generation for today/tomorrow is from the HA Met integration: https://www.home-assistant.io/integrations/met - it is a reasonably close approximation and I just add some SWAG to err on the side of caution.

Still the open question: is there a way via MQTT to enable and disable the ESS process so as to programatically switch from feeding from the grid to going back to battery? I'm sure it is possible but I have stumbled across the exposed MQTT message(s) that provide it. I guess what I'm looking to do is to disable the ESS module on the Cerbo and implement it in Home Assistant using my own algorithms based upon live information of solar production and expected house usage.

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

johnone avatar image johnone commented ·

Is it possible to programmatically change a scheduled charge's time settings - when the SOC is reached set the end point to current time?

Is it possible to emulate scheduled charging entirely using setpoint and Enable/Disable charge?

0 Likes 0 ·
johnone avatar image
johnone answered ·

Re during the time period of a scheduled charge "the house load remains to be fed from the grid, which in my mind is wasteful".

If you have a stable grid connection, I take it that the main purpose of a scheduled charge is time shifting energy consumption which is used for battery storage and high demand appliances - e.g. so that, ideally, grid consumption is only during an E7 period, or the various Octopus Energy periods or dynamically when there's excess wind/solar production.

If cheap energy is available during a time period, it doesn't make sense to store that energy in a battery and then, when the battery is 'full' start using the battery stored energy during the cheap period. The 'round trip' losses - caused by inverting AC to DC, battery storage losses, then inverting back to AC - are considerable, often over 25%.

With a stable grid connection, storing grid energy in a battery is a waste of money/energy unless you have a cheap rate period: ESS manages time shifted consumption by managing battery storage and enabling you to also use heavy-consumption devices during the cheap rate period without taking energy from the battery. When the cheap rate period ends you have the battery at the SOC you want and have also charged an EV, heated water etc.

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

agamos69 avatar image agamos69 commented ·

Ah, that's a good point re "the 'round trip' losses" - I hadn't taken that into consideration. I do use an E7 tariff while I'm between EVs, then I'll be back on IntelligentOctopus, so it makes sense for the house to run off the E7 tariff during the low rate period and have the battery charge to the minimum amount necessary based upon expected solar generation the next day. Thanks for the advice.

0 Likes 0 ·
natas avatar image
natas answered ·

Changing these settings via MQTT didn't work for me. I had to write to the dbus directly, either with dbus-send:

dbus-send --system --print-reply --dest=com.victronenergy.settings /Settings/CGwacs/BatteryLife/Schedule/Charge/0/Day com.victronenergy.BusItem.SetValue variant:int32:7

or with python:

import dbus
b = dbus.SystemBus()
b.call_blocking ('com.victronenergy.settings', '/Settings/CGwacs/BatteryLife/Schedule/Charge/0/Day', None, 'SetValue', 'v', [7])
1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

agamos69 avatar image agamos69 commented ·
Thank you, I'll look into how this can be incorporated into my Home Assistant flows as necessary.
0 Likes 0 ·
johnone avatar image
johnone answered ·

If it's any help, the following changed a schedule charge 'duration' while within the scheduled charge period - i.e. the system changed from 'scheduled charge' to 'external control'. Took around 1 second for remote console to show the change. This got round the BST E7 problem - a 7 hour scheduled charge starting at 1:00 am was still running after 8:00, even though the Cerbo had changed it's time to BST. Think that's a bug.

mosquitto_pub -h cerbo.lan.ip.address -t "W/xxxxxxxxxxx/settings/0/Settings/CGwacs/BatteryLife/Schedule/Charge/0/Duration" -m '{"value": "21600"}'

Having said that, @natas I prefer to do this with python and dbus. Thanks for the above.

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

agamos69 avatar image agamos69 commented ·
Oh, that appears to be a good workaround. I was under the impression you could not change a scheduled charge while it was currently in progress, I will try it out. I still have this add logic in my head that if I've calculated that I only need to charge the battery to a given level overnight (knowing that there is a good expectation of topping it up with solar during the day), I would prefer to not be consuming from the grid after the battery has reached that level. I understand about the losses but in switching to battery but I'd prefer to import the minimum from the grid if possible. My logic is probably flawed.
0 Likes 0 ·