GithubHelp home page GithubHelp logo

j-vizcaino / goteleinfo Goto Github PK

View Code? Open in Web Editor NEW
12.0 4.0 7.0 67 KB

Go library to decode Teleinfo frames sent by an electrical meter

License: GNU General Public License v3.0

Go 100.00%
teleinfo golang

goteleinfo's Introduction

goteleinfo: monitor your house electrical current

Build badge Go Reference GoReport badge

goteleinfo is a small library capable of decoding Teleinfo frames sent by an electrical meter.

Teleinfo is the protocol used by ERDF (Electricité Réseau Distribution France) electrical meters. Using this protocol, the electrical meter sends status frames periodically (~2 per second) that gives information about your electrical current consumption and status.

The Teleinfo protocol is described in this document

In order to convert read the frames, the Micro Teleinfo or PiTinfo is needed.

Requirements

This library requires Go >= 1.16

Metrics

The library provides counters to track frame reading and decoding errors. Those are stored internally as Prometheus metrics.

  • teleinfo_frames_read_total: total number of raw Teleinfo frames read successfully.
  • teleinfo_frames_read_errors_total: total number of read errors. This metric is tagged by error_type.
  • teleinfo_frames_decoded_total: total number of decoded Teleinfo frames.
  • teleinfo_frames_decode_errors_total: total number of frame decoding errors. This is metric is tagged by error_type

Difference between reading and decoding

Bytes coming from the serial port are accumulated by the reader, looking for frame start and frame end markers to extract raw Teleinfo frames. This is called "reading".

Decoding refers to verifying checksum and extracting fields from frame (eg. OPTARIF, HPHC fields, etc...).

Example: serving Teleinfo as JSON frames

A simple HTTP server example is provided in cmd/teleinfo-json that serves the last n frames, JSON encoded. Frames are served in /frames, while Prometheus metrics can be read from /metrics URL.

goteleinfo's People

Contributors

ferllings avatar j-vizcaino avatar yocarbo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

goteleinfo's Issues

Add version to software

One way to do this without hardcoding the version in any go file is through ldflags:

$ go build -ldflags "-X main.version=$(VERSION)" ...

Version should be determined according the git short sha or tag, if it exists.

Buffer points when exporter is not ready

In order to not loose any point, points should be buffered when exporter is not ready.
The amount of memorized points should be set by user with sensible defaults.
Given that we get 2 frames/sec and that frames do not consume much memory, a default value of 256 should be memory friendly and tolerate about 2 minutes of downtime.

Export data to Telegraf

The application should export points to Telegraf in order to benefit from the multiple exporters and aggregators available with this program.

Add a README

Things to document:

  • how to install and build
  • how to deploy and use
  • how to contribute

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.