Skip to content

A flexible and easy to configure service to collect and forward readings from smart meters and other sensors. It supports the Volkszaehler middleware and can be used as a replacement of vzlogger.

License

Schwaneberg/pymeterreader

Repository files navigation

pymeterreader

Summary

A flexible and easy to configure service to collect and forward readings from smart meters and other sensors. It supports the Volkszaehler middleware and can be used as a replacement of vzlogger. Alternatively it supports exposing measurements in the OpenMetrics format for usage with monitoring tools like Prometheus. Since version 0.3.0, it also supports MQTT, allowing many applications such as Home Assistant.

Supported Devices

  • Meters with SML protocol, tested with EMH electricity meters
  • Meters with plain serial protocols such as Landis+Gyr ULTRAHEAT T550 (UH50…)
  • Bosch BME280 sensor for air humidity, temperature and pressure

Installation

Install using pip on Raspberry Pi:

sudo python3 -m pip install pymeterreader
sudo pymeterreader-wizard

Use the wizard to test the connection to the Volkszähler middleware and map meters to channels, if the wizard is able to detect them. The wizard uses default baudrates and interfaces nodes only. Please try to manually configure your meters according to the example yaml file, if the wizard fails to detect them. Be sure to call the menu items 'Save current mapping' and 'Register PyMeterReader as systemd service' before you close the wizard.

sudo systemctl enable pymeterreader

Check the generated configuration file at /etc/pymeterreader.yaml. Note that all channels are configured with a default interval of 30m. The interval can be modified individually for all channels.

sudo systemctl start pymeterreader

You can follow the log using

journalctl -f

Metrics

To enable the metrics webserver the metrics section has to be present in the configuration. Metrics are generated by retrieving and parsing a Sample from a meter for every http request. Grafana can be used to easily create Dashboards to visualize the Metrics stored in Prometheus.

Reccommendations

  • To prevent queuing of multiple reads configure sample caching with the cache_interval option.
  • If a meter supplies an energy consumption counter and a power measurement, the power measurement can be discarded. The power measurement average can instead be calculated from the difference between energy consumption datapoints.

Pymeterreader Configuration Example

scrape_configs:
  - job_name: 'pymeterreader'
    scrape_interval: 15s
    scrape_timeout: 5s
    static_configs:
      - targets: ['localhost:8080']
    relabel_configs:
      - source_labels: [ __name__ ]
        regex: pymeterreader_power_consumption_watts
        action: drop

MQTT

The uuid field will be used to define a topic, when the gateway type is MQTT. Channels can be extended by defining "device_class" and "unit_of_measurement". Note that the wizard does not yet support MQTT configuration.

Example configuration:

devices:
  '12345678':
    channels:
      '6.8':
        interval: 12h
        uuid: meter/heat/total_absorbed
        unit_of_measurement: kWh
    meter_address: hwgrep://0403:6015
    meter_id: '12345678'
    protocol: PLAIN
  1 HLYxx:
    channels:
      1-0:1.8.0*255:
        interval: 5m
        uuid: meter/electric/total_absorbed
      1-0:2.8.0*255:
        interval: 5m
        uuid: meter/electric/total_yield
    meter_address: hwgrep://10c4:ea60
    protocol: SML
  BME280-078fc53ee157b535d787a94e8ac2f05ed6083c8d21ef77389021ae97961d7d0a:
    channels:
      HUMIDITY:
        interval: 1h
        uuid: basement/sensor/humidity
        unit_of_measurement: "%"
        device_class: humidity
      PRESSURE:
        factor: 0.01
        interval: 1h
        uuid: basement/sensor/pressure
        unit_of_measurement: hPa
        device_class: atmospheric_pressure
      TEMPERATURE:
        interval: 1h
        uuid: basement/sensor/temperature
        device_class: temperature
        unit_of_measurement: °C
    meter_address: 0x76@I2C(1)
    meter_id: BME280-078fc53ee157b535d787a94e8ac2f05ed6083c8d21ef77389021ae97961d7d0a
    protocol: BME280
middleware:
  type: mqtt
  middleware_url: localhost
  user: username
  password: password
  port: 1883

About

A flexible and easy to configure service to collect and forward readings from smart meters and other sensors. It supports the Volkszaehler middleware and can be used as a replacement of vzlogger.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published