diy solar

diy solar

UPS like functionality for supported AIO inverters

JoseMR

New Member
Joined
Nov 22, 2023
Messages
7
Location
Puerto Rico
"UPS like functionality for inverters supporting Solar-Assistant or similar."

Hi, so long story short, well sorta.;)

I've recently switched from expensive/weak computer oriented UPS devices to a little AIO inverter(posted here) since my homelab grown a bit, while I'm completely satisfied with my choice I've quickly started missing the UPS functionality(NUT) to properly shutdown my ZFS storage/jails server and some other networked machines during battery/battery_low etc. state conditions.

So I've paired my EASun/SRNE AIO with Solar-Assistant and found that nice MQTT broker feature I can use for such purpose, so after some thinkering I've opted to develop a simple shell script to perform said basic UPS functions by using the popular `mosquitto_sub` MQTT broker.

Now I'm happy again that my servers can be auto-shutdown properly and I get an email alert on such event, so I can left them unattended now.
I hope the script may be useful for some, it is hosted on GitHub under the name of `mqtt_ups_sched` for sharing, the script is on beta/test stage.

Hopefully will have some time after new year to improve the little script its functionality.

Sample output:
Code:
root@mserver: ~# mqtt_ups_sched help
Usage: mqtt_ups_sched [option]
Options:
      start       Start mqtt_ups_sched script.
      stop        Stop mqtt_ups_sched sctipt.
      stats       Display raw device states.
      stats_json  Display device states in JSON format.
      version     Display mqtt_ups_sched version.
      help        Display this help message.
root@nas-mserver: ~# mqtt_ups_sched version
mqtt_ups_sched 1.5.02
root@mserver: ~# mqtt_ups_sched stats
[iSolar-MLV-3KW-U] 2024-01-21 11:26:36 DEVICE STATUS:
solar_assistant/inverter_1/pv_voltage/state 0.0
solar_assistant/inverter_1/grid_frequency/state 60.02
solar_assistant/inverter_1/pv_power/state 0
solar_assistant/inverter_1/battery_voltage/state 27.6
solar_assistant/inverter_1/load_apparent_power/state 331
solar_assistant/inverter_1/temperature/state 50.6
solar_assistant/inverter_1/load_percentage/state 11
solar_assistant/inverter_1/battery_current/state 0.2
solar_assistant/inverter_1/grid_power/state 331
solar_assistant/inverter_1/device_mode/state Grid
solar_assistant/inverter_1/grid_voltage/state 118.2
solar_assistant/inverter_1/ac_output_frequency/state 60.02
solar_assistant/inverter_1/pv_current/state 0.0
solar_assistant/inverter_1/ac_output_voltage/state 118.6
solar_assistant/inverter_1/load_power/state 277
solar_assistant/total/battery_power/state 6
solar_assistant/total/battery_state_of_charge/state 100
solar_assistant/total/bus_voltage/state 333.5

Regards!
 
Last edited:
"UPS like functionality for inverters supporting Solar-Assistant or similar."

Hi, so long story short, well sorta.;)

I've recently switched from expensive/weak computer oriented UPS devices to a little AIO inverter(posted here) since my homelab grown a bit, while I'm completely satisfied with my choice I've quickly started missing the UPS functionality(NUT) to properly shutdown my ZFS storage/jails server and some other networked machines during battery/battery_low etc. state conditions.

So I've paired my EASun/SRNE AIO with Solar-Assistant and found that nice MQTT broker feature I can use for such purpose, so after some tinkering I've opted to develop a simple shell script to perform said basic UPS functions by using the popular `mosquitto_sub` MQTT broker.

Now I'm happy again that my servers can be auto-shutdown properly and I get an email alert on such event, so I can left them unattended now.
I hope the script may be useful for some, it is hosted on GitHub under the name of `mqtt_ups_sched` for sharing, the script is on beta/test stage.

Hopefully will have some time after new year to improve the little script its functionality.

Sample output:
Code:
root@mserver: ~# mqtt_ups_sched help
Usage: mqtt_ups_sched [option]
Options:
      start    Start mqtt_ups_sched script.
      stop     Stop mqtt_ups_sched sctipt.
      stats    Display raw device states.
      version  Display mqtt_ups_sched version.
      help     Display this help message.
root@mserver: ~# mqtt_ups_sched version
mqtt_ups_sched 1.4.0
root@nas-mserver: ~# mqtt_ups_sched stats
[SRNE V2] 2023-12-30 18:49:30 DEVICE STATUS:
solar_assistant/inverter_1/pv_voltage/state 0.0
solar_assistant/inverter_1/grid_frequency/state 59.92
solar_assistant/inverter_1/pv_power/state 0
solar_assistant/inverter_1/battery_voltage/state 27.6
solar_assistant/inverter_1/load_apparent_power/state 473
solar_assistant/inverter_1/temperature/state 44.9
solar_assistant/inverter_1/load_percentage/state 15
solar_assistant/inverter_1/battery_current/state 0.2
solar_assistant/inverter_1/grid_power/state 473
solar_assistant/inverter_1/device_mode/state Grid
solar_assistant/inverter_1/grid_voltage/state 115.4
solar_assistant/inverter_1/ac_output_frequency/state 59.92
solar_assistant/inverter_1/pv_current/state 0.0
solar_assistant/inverter_1/ac_output_voltage/state 115.9
solar_assistant/inverter_1/load_power/state 382
solar_assistant/total/battery_power/state 6
solar_assistant/total/battery_state_of_charge/state 100
solar_assistant/total/bus_voltage/state 333.5

Regards!
Brilliant... I wish my brain was more advanced to understand this.. I think people like yourself are amazing...
 
@JoseMR I also recently hacked together a "big UPS" and I was missing the "notify something else so it can shut down" functionality. I solved this with an Arduino running this library: https://github.com/abratchik/HIDPowerDevice and my own code. I needed some extra hardware to do AC on/of detection and DC voltage sensing, but as off this weekend, it is all reporting to NUT so that my NAS or other devices can take action when status changes.
 
Hi @krby I've used to hack some UPS/Inverters in past as well since they were not fully supported or not supported at all by NUT.

In my case I've used some of those AC refrigerator/appliance protectors those who had 3/4 LED states providing "Power-OK, Power-Low/High and Wait-Time", so modified the Wait-Time to my like and used the needed LED's power to drive some Optos coupled to a tinny USB game controller module(those used in DIY Arcade/Gamepads etc), then used a script to let the server perform a timed action based on the specific key press/release configured, however it lacked battery state monitoring es expected but worked fine as a quick temp solution.

However the Arduino and the library link you've posted is far interesting for thinkering, as I've always wanted something similar to the "Newmar SPM-200" to monitor AC/DC voltages etc but a unit more oriented to the consumer/DIY community, now thinking to find some time to play with Arduino since there are many libraries and project to start from and learning.

Regards!
 
Last edited:
If you have a BMS couldn't you set the shutdown to trigger off SoC? You'd have to tap into the battery comms but it doesn't seem that that would be an issue with the skill set you've already shown.
 
This is cool. Years ago, there was a utility called "apcupsd" in the linux world. It wouldn't work on BSD systems though. I worked witht he maintainers and ported it over to BSD/OS, FreeBSD, and NetBSD. I maintained that port for many years. even long after BSDi went out of business. It's nice to see people still doing the same kinds of things 2 decades later.
 
@teal95
Definitely BMS is another thing I will explore out when I need to swap my AGM/GEL batteries and start playing with such protocols too yeah.

@n2aws
Nice to hear FreeBSD enthusiasts here, yeah I know that old UPS utility and I think is still avail/maintained as "apcupsd-3" to control select APC devices only, though I mostly used NUT wen support avail on my devices since is more of an universal utility thus simplifying scripting for multiple dissimilar devices.

Between since I mostly worked with small home/SOHO setups it seems that the AIO and Solar-Assistant/MQTT broker feature paired with a small host monitor script(s) covers most assuming the inverter is supported by SA/MQTT on reading its states, otherwise it may requires for RSXXX to ETH hardware and some coding hand work/complexity but also fun.

Regards!
 
Hello, had some time in the weekend and made a very simple MQTT monitor module for users running Webmin on their servers, I tested only on FreeBSD but I think the module may work on Linux distros supporting `mosquitto_sub` and `timeout` commands as well.;)

I'm personally using it for a quick status view of my inverter whiting Webmin which is paired with Solar-Assistant but not limited to, as for now the module can quick monitor a single device/broker but maybe I could either add config/ip selector dropdown menu to monitor multiple devices on-demand or generating extra tabs.

Screenshot:
dashboard.pngdashboard-sample2.png

Releases can be found on SourceForge: MQTT Monitor Webmin Module
Source code hosted on: GitHub
Regards!
 
Last edited:
Back
Top