GithubHelp home page GithubHelp logo

jordyv / prometheus-p1-exporter Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 11.0 47 KB

Prometheus exporter for metrics fetched from a smart meter with a P1 cable.

Makefile 4.05% Go 93.59% Dockerfile 2.36%

prometheus-p1-exporter's Introduction

Prometheus P1 exporter

Prometheus exporter for smart meter statistics fetched with a P1 cable.

Installation

From source

With Go get:

$ go get github.com/jordyv/prometheus-p1-exporter

With Go install (recommended):

$ go install github.com/jordyv/prometheus-p1-exporter@latest

Make:

$ git clone https://github.com/jordyv/prometheus-p1-exporter.git
$ cd prometheus-p1-exporter
$ make
$ sudo make install

Usage

Usage of ./prometheus-p1-exporter:
  -apiEndpoint string
        Use API endpoint to read the telegram (use for HomeWizard)
  -interval duration
        Interval between metric reads (default 10s)
  -listen string
        Listen address for HTTP metrics (default "127.0.0.1:8888")
  -mock
        Use dummy source instead of ttyUSB0 socket
  -usbserial string
    	USB serial device (default "/dev/ttyUSB0")
  -verbose
        Verbose output logging

By default the exporter will collect metrics from /dev/ttyUSB0 every 10 seconds and export the metrics to an HTTP endpoint at http://127.0.0.1:8888/metrics. This endpoint can be added to your Prometheus configuration.

Example metrics page:

# HELP p1_active_tariff Active tariff
# TYPE p1_active_tariff gauge
p1_active_tariff 2
# HELP p1_current_usage_electricity_high Electricity currently used high tariff
# TYPE p1_current_usage_electricity_high gauge
p1_current_usage_electricity_high 0
# HELP p1_current_usage_electricity_low Electricity currently used low tariff
# TYPE p1_current_usage_electricity_low gauge
p1_current_usage_electricity_low 0.2
# HELP p1_power_failures_long Power failures long
# TYPE p1_power_failures_long gauge
p1_power_failures_long 2
# HELP p1_power_failures_short Power failures short
# TYPE p1_power_failures_short gauge
p1_power_failures_short 57
# HELP p1_returned_electricity_high Electricity returned high tariff
# TYPE p1_returned_electricity_high gauge
p1_returned_electricity_high 0
# HELP p1_returned_electricity_low Electricity returned low tariff
# TYPE p1_returned_electricity_low gauge
p1_returned_electricity_low 0.016
# HELP p1_usage_electricity_high Electricity usage high tariff
# TYPE p1_usage_electricity_high gauge
p1_usage_electricity_high 1225.59
# HELP p1_usage_electricity_low Electricity usage low tariff
# TYPE p1_usage_electricity_low gauge
p1_usage_electricity_low 1179.186
# HELP p1_usage_gas Gas usage
# TYPE p1_usage_gas gauge
p1_usage_gas 1019.003

Development

Currently only the ESMR 5.0 format is supported and the parser is default configured to parse the telegram message with the keys the Sagemcom XS210 is using. If you have to support a different ESMR 5.0 message, feel free to create your own implementation of the TelegramFormat struct. To support a different format then ESMR 5.0 you can implement your own implementation of the TelegramReaderOptions struct.

prometheus-p1-exporter's People

Contributors

dependabot[bot] avatar jordyv avatar kidk avatar sqjor avatar vic-basroovers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

prometheus-p1-exporter's Issues

Exported data is often 0

I just started to use this exporter (thanks!) on a RPI 3B with Raspbian. After successful compilation all runs fine as a systemd service but I noticed that after the first "poll" all values are zero and exported as such, except for the gas reading, snippet of the verbose output (truncated):

Start listening at 127.0.0.1:8888
Line to parse map[0-0:1.0.0:221013213043S 0-0:96.1.1:XXXXXXXXXXXXXXXXXXXX 0-0:96
{Timestamp:221013213043 ElectricityUsageLow:2697.465 ElectricityUsageHigh:2967.323 Electricity
Line to parse map[0-0:96.13.0: 0-0:96.14.0:0002 0-0:96.7.21:00008 0-0:96.7.9:00002 0-1:24.1.0:
{Timestamp:0 ElectricityUsageLow:0 ElectricityUsageHigh:0 ElectricityReturnedLow:0 Electricity
Line to parse map[0-0:96.13.0: 0-0:96.7.21:00008 0-0:96.7.9:00002 0-1:24.1.0:003 0-1:24.2.1:01
{Timestamp:0 ElectricityUsageLow:0 ElectricityUsageHigh:0 ElectricityReturnedLow:0 Electricity
Line to parse map[0-0:96.13.0: 0-0:96.14.0:0002 0-0:96.7.21:00008 0-0:96.7.9:00002 0-1:24.1.0:
{Timestamp:0 ElectricityUsageLow:0 ElectricityUsageHigh:0 ElectricityReturnedLow:0 Electricity

The first "Timestamp" lines is correct but all the others are 0...
Before I try to troubleshoot myself (kinda new to go) I wonder if that rings a bell that can point me in the right direction (otherwise I'll fork the code and try to fix/understand it).

PS: after a reboot and serve restart (just for the sake of completeness) I'm now getting correct values everytime...

make usb serial port configurable

Hello!

First of all, thank you for this very nice piece of free software.

You owe me absolutely nothing, but I'd very much appreciate if you could make the usb serial device configurable. It's not always /dev/ttyUSB0...

Here's an anecdote. I tested your software on two laptops; same make, same model, same software stack. prometheus-p1-exporter worked on the first one but not on the second. Five seconds of head scratching. Turns out the second one had a modem on board. That made the usb serial device identify not as /dev/ttyUSB0, but as /dev/ttyUSB3 !

Thanks again for your work on free software. Much appreciated!

Mark

P.S. A more common scenario might be the device collecting the metrics reading logs from two usb serial ports...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.