Skip to content

Utility to monitor and export solar PV and electrical metering

License

Notifications You must be signed in to change notification settings

aamcrae/MeterMan

Repository files navigation

MeterMan

MeterMan is a utility to monitor electricity consumption and Solar Photovoltaic (PV) output, and send the results to various collectors.

The features include:

  • Using the LCD library to read electrical meter LCD screens via a webcam.
  • Monitoring using an IAMMeter Energy Meter
  • Monitoring SMA Solar inverters
  • Retrieving the current temperature via a weather provider.
  • Uploading the data to PVOutput
  • Uploading data to Home Assistant.
  • Saving 5 minute snapshots to CSV files.
  • Access to data via a JSON API

Configuration

MeterMan uses a YAML based configuration file, as well as various command line flags - running MeterMan --help will list the available flags.

The example configuration file shows how each feature can be individually enabled and configured. If a feature is required, it is enabled by adding that feature's configuration to the YAML configuration file.

The core configuration allows a checkpoint file to be defined so that state data is preserved across restarts. The core configuration is:

db:
  checkpoint: <checkpoint file>
  update: <interval for writing checkpoint file in seconds>
  freshness: <duration before data is considered stale>
  daylight: [<start hour>, <end hour>]

The default update interval is 60 seconds. The freshness parameter (in minutes) defines how long data is not updated before it is considered stale i.e not included in exports. The default is 10 minutes. The daylight parameters indicate the begin and end time (as hours) for the limit of daylight hours. The default is [5, 20].

The configuration for each the features are documented in:

Building and Running

MeterMan can be built as a docker image:

docker build --tag aamcrae/meterman:latest -f docker/Dockerfile .

A sample docker compose file can be to deploy the image.

It is recommended that a MeterMan be run under its own uid (e.g 'meter:meter').

Internals

MeterMan is written in Go and uses a YAML based configuration file.

An internal database allows input and output modules to be added independently, and multiple values to be averaged, summed and managed.

A main thread is used for most processing, and only this thread can access the internal database to avoid any concurrency issues. Modules that provide data to the database do so by sending updates via a channel. These modules should run in separate goroutines, and not as part of the main thread (otherwise there may be potential for deadlock with updates being sent to the channel without being read). To access the database elements, modules can request functions to be executed from the main thread. Timer callbacks can be registered, and these are aligned to the wall time with an optional offset e.g if a callback is requested every minute with a -5 second offset, this is invoked on 5 seconds before the minute (i.e seconds = 55). No I/O or extended processing should be performed in these callbacks (typically any I/O is dispatched via a separate goroutine).

Disclaimer

This is not an officially supported Google product.