{"id":360,"date":"2023-02-10T11:07:18","date_gmt":"2023-02-10T11:07:18","guid":{"rendered":"https:\/\/asdfghjkl.me.uk\/blog\/?p=360"},"modified":"2023-02-10T13:31:01","modified_gmt":"2023-02-10T13:31:01","slug":"multiplus-aes-node-red","status":"publish","type":"post","link":"https:\/\/asdfghjkl.me.uk\/blog\/multiplus-aes-node-red\/","title":{"rendered":"Disabling\/enabling AES (power saving) programmatically on Victron inverters with Node-RED"},"content":{"rendered":"\n<p><em>Want to do this yourself? Grab everything you need from <a href=\"https:\/\/github.com\/asderferjerkel\/node-red-aes-victron\">my Github<\/a>!<\/em><\/p>\n\n\n\n<p>Living off-grid means we have to be pretty careful with our electricity usage, especially in the winter when solar output can be a tenth of the summer highs. We don't have a huge number of mains appliances (fridge, laptops, coffee grinder, blender) and run as much as possible off 12 volts. Despite this, I honestly don't think we're missing out on anything! We use around 1kWh of electricity per day, just an eighth of the average UK household that Ofgem reckons uses 2900kWh each year.<\/p>\n\n\n\n<p>One reason I chose to install Victron gear is that I am simply too lazy to turn an inverter on and off whenever I want to use mains power. Their inverters have a power-saving function they call AES (automatic economy switch), which keeps the inverter off and blips the power every second to see if a load is connected. If it detects a load, it switches on fully. This does restrict your choice of appliances to those without too many electronics, but for a fridge with an old-school bimetallic strip thermostat it works great.<\/p>\n\n\n\n<p>The energy savings from using this \"search mode\" can be quite significant. My Multiplus 1600W inverter uses 10W when switched on with zero load, and 3W in power saving mode. Just considering the fridge, it tends to run in a 1-hour-off, 20-minutes-on cycle. So that's 18 fridge cycles per day, saving 7W * 18 hours = 126Wh compared to the inverter being left on 24 hours per day. That works out to an eighth of our average daily consumption saved. It's a much bigger deal in the winter, where the average day only gives us around 250Wh of solar power, so we're saving fully half of that!<\/p>\n\n\n\n<p>The only downside is that picking the wattage thresholds to turn on fully can be quite finicky. These inverters don't have a current transformer on the AC output, so the power usage they report is just an estimate based on battery current and efficiency. Reactive vs resistive loads will also skew this figure. Choosing the threshold takes a bit of experimentation to pick the lowest wattage where the inverter will go into power saving with no load, but still switch on when something's plugged in. This seems to vary between inverters, but a good place to start is 25W and work upwards until it works well. Mine is just about right at 35W start and 67W stop (in reality this means a 10W load will keep the inverter on).<\/p>\n\n\n\n<p>It's still not quite perfect, though. I noticed that newer USB-C laptop chargers will draw just a few watts to begin with, ramping up to full power after about 10 seconds. Since the \"blips\" in search mode only last for one AC cycle, they don't draw enough power to fully turn on the inverter before they reset. My lazy solution was to run the coffee grinder for a few seconds, but ideally I'd like to briefly disable AES, allowing the charger to ramp up before re-enabling it.<\/p>\n\n\n\n<p>I've been <a href=\"https:\/\/asdfghjkl.me.uk\/blog\/remote-webasto\/\" data-type=\"post\" data-id=\"344\">playing with Node-RED a lot recently<\/a>, so I figured I could find a programmatic solution. Problem is, there's a (sensible) divide in what Victron lets you access externally - you can change <em>state<\/em> but not <em>settings<\/em>, and AES is a setting so no dice. Luckily I came across <a href=\"https:\/\/community.victronenergy.com\/questions\/72183\/multiplus-forcing-inverter-to-come-on.html\">this hacky workaround<\/a>, which uses a digital input on the inverter to control the AES setting. The solution is described almost entirely there but took a lot of searching and keyword massaging to find, hence why I'm writing about it here!<\/p>\n\n\n\n<p>Alright, enough backstory. This isn't a recipe website. tl;dr:<\/p>\n\n\n\n<ul>\n<li>Add a relay to your GX device<\/li>\n\n\n\n<li>Connect the relay to an input on the inverter<\/li>\n\n\n\n<li>Add assistants to the inverter to use the input state to disable AES<\/li>\n\n\n\n<li>Find some cute way to trigger the relay<\/li>\n<\/ul>\n\n\n\n<p>First things first is the relay. I run Victron's Venus OS on a Raspberry Pi, so an external relay module is needed (GX devices have one or more built in). By default the Pi build only comes with one relay output, assigned to GPIO21 (pin 40), and I was already using that for my <a href=\"https:\/\/asdfghjkl.me.uk\/blog\/remote-webasto\/\" data-type=\"post\" data-id=\"344\">heating<\/a>. Easy solution: install Kevin Windrem's <a href=\"https:\/\/github.com\/kwindrem\/SetupHelper\">SetupHelper<\/a> then <a href=\"https:\/\/github.com\/kwindrem\/RpiGpioSetup\">RpiGpioSetup<\/a>, adding 5 more relays (though only 4 total are accessible through Node-RED).<\/p>\n\n\n\n<p>I then switched out my 1-relay module with a 4-relay one. For single relay modules, it seems like any old 5v relay module will do (they must be powered by 5v, but a 3.3v GPIO will trigger it). But when you go larger, you have to be careful - many of these seem to be active-low rather than active-high, and additionally require 5v to trigger them. Active-low doesn't work for Venus OS, as during the Pi's startup your relay will be turned on even if you invert its output later. So when you're looking for a relay module, avoid ones with a \"JD-VCC\" jumper (these require <a href=\"https:\/\/electronics.stackexchange.com\/questions\/505318\/how-to-properly-use-a-relay-module-with-jd-vcc-from-arduino-raspberry\">modification<\/a> to work with 3.3v signals) and pick one with a set of configurable active-low\/high jumpers (mine are labelled LOW-COM-HEIGHT, ha!).<\/p>\n\n\n\n<p>Connect DC+ to the same 5v power supply as your Pi, DC- to ground, and IN1 to IN4 to the GPIO pins. If you're using the RpiGpioSetup package, these will be GPIO21, 17, 27 and 22 (header pins 40, 11, 13 and 15). The full list is <a href=\"https:\/\/github.com\/kwindrem\/RpiGpioSetup\/blob\/main\/FileSets\/gpio_list\">here<\/a>. Make sure the low\/high jumpers are set to high.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/relays.jpg\" alt=\"Installing the 4-channel relay module\" class=\"wp-image-366\" width=\"419\" height=\"512\" srcset=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/relays.jpg 837w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/relays-245x300.jpg 245w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/relays-768x940.jpg 768w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/relays-624x763.jpg 624w\" sizes=\"(max-width: 419px) 100vw, 419px\" \/><\/figure><\/div>\n\n\n<p>Next, set up the inverter. My <a href=\"https:\/\/www.victronenergy.com\/inverters-chargers\/multi-500-va\">Multiplus 1600<\/a> is a smaller model without digital inputs, but it does have an input for a battery temperature sensor which can be reconfigured. Since mine is connected to the Pi via a VE.Bus to USB cable, it uses data from the battery monitor for temperature-compensated charging, so this input is spare.<\/p>\n\n\n\n<p>You can use Victron's <a href=\"https:\/\/www.victronenergy.com\/support-and-downloads\/software\">VEConfigure<\/a> software over USB, but if it's connected to the Pi it's much easier to configure remotely through the <a href=\"https:\/\/vrm.victronenergy.com\/\">VRM<\/a>. Go to <em>Device list<\/em> -&gt; <em>Remote VEConfigure<\/em> and click <em>Download<\/em> to get the config file. Open VEConfigure, choose <em>Port selection<\/em> then <em>Fake target from file<\/em> and pick the downloaded file.<\/p>\n\n\n\n<p>First, go to the <em>Virtual switch<\/em> tab and set <em>Do not use VS<\/em> (it's incompatible with assistants). Then, go to <em>Assistants<\/em>, add a <em>General flag user<\/em> and click <em>Start assistant<\/em> to configure it. Do the same again to add two <em>Programmable relays<\/em>. Configure them as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"406\" height=\"357\" src=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/assistants.png\" alt=\"General flag user:\n- Use general flag to disable AES\nProgrammable relay:\n- Use general flag\n- Set relay on\n- When temperature sense input is closed for 0 seconds\nProgrammable relay:\n- Use general flag\n- Set relay off\n- When temperature sense input is open for 0 seconds\" class=\"wp-image-365\" srcset=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/assistants.png 406w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/assistants-300x264.png 300w\" sizes=\"(max-width: 406px) 100vw, 406px\" \/><\/figure>\n\n\n\n<p>The \"general flag\" is a virtual switch that you can use to activate various features. Here, we use it to disable AES when it's \"on\". We then use a programmable relay to activate the flag when the temperature sense input is shorted, and another to deactivate it when it's open-circuit.<\/p>\n\n\n\n<p>Close VEConfigure (don't use the save function in the menu), and save the file when prompted. Go back to the VRM, click <em>Upload<\/em> and choose the file. The inverter will reset a couple of times.<\/p>\n\n\n\n<p>Now, connect the relay (COM and NO) to the temperature sense input. Either way round is fine. Use a small screwdriver to press in the orange tabs so you can insert the wires. I recommend ferrules if you want it to look neat!<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/temp_input.jpg\" alt=\"Connecting the relay to the temperature sense input\" class=\"wp-image-367\" width=\"512\" height=\"384\" srcset=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/temp_input.jpg 1024w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/temp_input-300x225.jpg 300w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/temp_input-768x576.jpg 768w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/temp_input-624x468.jpg 624w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/figure><\/div>\n\n\n<p>The simplest solution would have been to connect a switch or button to the input to disable AES - flick the switch or hold the button for a few seconds until the load picks up. But since we're in it already, let's add a couple of buttons to our Node-RED dashboard.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"826\" height=\"303\" src=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/flow.png\" alt=\"Node-RED flow\" class=\"wp-image-369\" srcset=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/flow.png 826w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/flow-300x110.png 300w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/flow-768x282.png 768w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/flow-624x229.png 624w\" sizes=\"(max-width: 826px) 100vw, 826px\" \/><\/figure><\/div>\n\n\n<p>As usual, this is more complicated than it needs to be. You can grab the completed flow from <a href=\"http:\/\/github.com\/asderferjerkel\/node-red-aes-victron\">my Github<\/a>. I added two buttons, one for 1 minute and one for 1 hour. These activate trigger nodes, which send <em>false<\/em> immediately, then <em>true<\/em> after the specified time. <em>false<\/em> and <em>true<\/em> go to a change node, which sets <em>msg.enabled<\/em> from the payload and feeds this back to the buttons, disabling them until the timer runs out. They also go to a function node, which converts <em>false<\/em> to <em>1<\/em> and <em>true<\/em> to <em>0<\/em>, activating the relay. I also added a relay state node which displays on the dashboard whether AES is on or off. Finally, I added a node which runs 0.1s after startup, turning off the relay and enabling the buttons in case the timer has been cancelled by a restart. Here's what it looks like in the dashboard:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"323\" height=\"62\" src=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/dashboard.png\" alt=\"Dashboard with AES on\" class=\"wp-image-370\" srcset=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/dashboard.png 323w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/dashboard-300x58.png 300w\" sizes=\"(max-width: 323px) 100vw, 323px\" \/><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/dashboard-off.png\" alt=\"Dashboard with AES off\" class=\"wp-image-371\" width=\"315\" height=\"61\" srcset=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/dashboard-off.png 316w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/dashboard-off-300x58.png 300w\" sizes=\"(max-width: 315px) 100vw, 315px\" \/><\/figure><\/div>\n\n\n<p>And that's it! As always, drop a comment if you have any questions or made anything cool out of it \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Want to do this yourself? Grab everything you need from my Github! Living off-grid means we have to be pretty careful with our electricity usage, especially in the winter when solar output can be a tenth of the summer highs. We don't have a huge number of mains appliances (fridge, laptops, coffee grinder, blender) and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,12,3],"tags":[],"_links":{"self":[{"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/posts\/360"}],"collection":[{"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/comments?post=360"}],"version-history":[{"count":6,"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/posts\/360\/revisions"}],"predecessor-version":[{"id":373,"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/posts\/360\/revisions\/373"}],"wp:attachment":[{"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/media?parent=360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/categories?post=360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/tags?post=360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}