Skip to content

sdeigm/uni-meter

Repository files navigation

uni-meter

uni-meter is a small tool that emulates an electrical meter like a Shelly Pro3EM or an EcoTracker based on the input data from a variety of input devices with the main purpose to control a storage system like the Hoymiles MS-A2 or the Marstek Venus. The uni-meter is not a full implementation of the emulated devices. Only the parts that are needed by the storage systems are implemented. Especially the update of the data in the Shelly or Everhome cloud is not possible due to undocumented proprietary APIs. As a consequence, storage devices which are dependent on information from the Shelly or Everhome cloud are not supported.

The idea is to further enhance the tool in the future by adding more input and output devices to get a universal converter between different electrical meters, inverters and storage systems.

Currently, the following output devices are supported:

  • Shelly Pro 3EM
  • Everhome EcoTracker

The real electrical meter data can be gathered from the following input devices:

  • Emlog smart meter
  • Fronius smart meter
  • Generic HTTP (configurable HTTP interface, usable for many devices)
  • Home Assistant sensors
  • ioBroker datapoints (via simple API adapter)
  • MQTT
  • Shelly 3EM
  • Shelly Pro 3EM
  • SHRDZM smartmeter interface module (UDP)
  • SMA energy meter / Sunny Home Manager (UDP protocol)
  • SMD120 modbus energy meter (via Protos PE11) (SMD630 could be added, I have no test device)
  • Solaredge
  • Tasmota IR read head (via HTTP)
  • Tibber Pulse (local API)
  • VzLogger webserver

Storages known to be supported are

  • Hoymiles MS-A2
  • Marstek Venus

The tool is built in Java and needs at least a Java 17 Runtime. If you want to use an ESP32 or a similar system which does not support Java 17, there is another project called Energy2Shelly which is written in C++ and can be used as an alternative on such systems.

Installation

There are different installation options available. You can choose to

Configuration

The configuration is done using a configuration file in the HOCON format.

The basic structure of that configuration file is common in all setups. You have to choose which input device to use and which output device to use. Based on that choice, you have a configuration section for your input and your output device. These sections contain the parameters specific to that device type:

uni-meter {
  output = "uni-meter.output-devices.<output-device-type>"
  
  input = "uni-meter.input-devices.<input-device-type>"
  
  output-devices {
    <output-device-type> {
      # ...
    }
  }

  input-devices {
    <input-device-type> {
      # ...
    }
  }
}

Output device configuration

To configure the output device, follow the instructions in these sections:

Input device configuration

To configure the input device, follow the instructions in these sections:

External API

Starting with version 1.1.7, the uni-meter provides a REST API which can be used to externally control or change the behavior. Currently, the API only consists of two methods which can be used to switch on/off the uni-meter for instance while loading your BEV. The idea is to enhance that in the future.

Troubleshooting

uni-meter use the Java logback logging system. In the default setup only info, warning and error messages are written to the logfile/standard output. For debugging purposes you can set the log level to DEBUG or even TRACE within the logback configuration file. The location of that configuration file differs on your setup type.

  • For a physical server this is typically /opt/uni-meter/config/logback.xml
  • For a docker setup it is/can be provided as a parameter to your startup command
  • For a home assistant setup it can be placed in /addon_configs/663b81ce_uni_meter
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{yy-MM-dd HH:mm:ss.SSS} %-5level %-24logger - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="INFO">
        <appender-ref ref="STDOUT" />
    </root>

    <logger name="uni-meter"  level="TRACE" additivity="false">
        <appender-ref ref="STDOUT" />
    </logger>
</Configuration>

A restart is necessary for these changes to take effect.