Skip to content

Adding a dummy-ups script to examples? #2807

@sshambar

Description

@sshambar

I wrote a bash script to integrate my local Enphase's Envoy API (a simple JSON based local web API) with a dummy-ups driver's port file. I've just published it (GPLv3) at https://github.com/sshambar/enphase-monitor

The script is simple to use, and provides information on "grid" online/offline status, battery SOC, and several other details (like "load" and "runtime") from the Enphase system. I use it to integrate with current UPS + ATS (automatic transfer switch) to treat my house battery system as 2nd UPS. I didn't feel it merited writing a full driver as I'm not using it for FSD, outlet control or anything "interactive", I just didn't want my servers shutting down when my UPS failed (don't ask) and the house still had backup power. Plus it's nice to have another way to monitor the Enphase system using the NUT cgi programs...

The script is probably something others could use as an basis for integrating with similar web APIs using the dummy-ups as a hook to the NUT system, so I thought perhaps it made sense to add as an "example" script someplace in the source?

The script has nice features such as:

  • retains existing/extra values in the port file
  • gracefully handles split-phase or 3-phase input/output values
  • handles no-comms with temporary rename of the port file (indicates "stale data")
  • support portfile value customization (things like battery voltage range, or battery.charge.low for LB trigger)
  • contains logic for login and token based API authentication, with automatic token renewal
  • has it's own config for authentication and API query timing etc
  • checks permissions on files that use secrets
  • is fully self-documented (leading comment in the script)
  • GPLv3 licensed
  • minimal requirements: bash, jq, base64 and curl
  • has details on setting up a systemd service to use with dummy-ups, and SELinux config
  • includes a "TEST" mode that loops through various states and randomly expires the token
  • ... and it's pretty well tested :)

I would have rather created a pull request against NUT, but I honestly don't know where I would add the file here... perhaps someone can suggest a directory if you think it might be useful.

In any case, anyone wanting to add Enphase local API support to NUT can use it as is.

PS. yes I know there's a "external" Enphase API, but it's request limits are severely restricted without paying a high fee...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions