Giter VIP home page Giter VIP logo

pyhan's Introduction

pyHan

Simple Python library to decode data from the HAN port on Norwegian electricity meters.

This library is based on the C library found here: https://drive.google.com/drive/folders/0B3ZvFI0Dg1TDbDBzMU02cnU0Y28

The library tries to make is realy easy to decode data on the HAN port.

Simple serial HAN decoder:

from HAN import readHan
import serial

with serial.Serial('/dev/ttyUSB0', 2400, timeout=5) as ser:
    while True:
        han = readHan(ser)
        print("{} Watt".format(han.data["act_pow_pos"]))

Decode messages from file:

from HAN import readHan
with open(file, "rb") as ser
    while True:
        try:
            han = readHan(ser)
            print("{} Watt".format(han.data["act_pow_pos"]))
        except EOFError as e:
            # End Of File
            break
        except Exception as e:
            # Unable to decode message
            continue

For a more complete example se serialHan.py and influxUploader.py

InfluxUploader.py

Sample script to upload Usage data to influxDB

usage: python3 pyinfluxUploader.py --influxserver server.ip.address --username user --password pass --database database

Tested

For now extensive testing is not completed, and the library is only tested on the Kaifa MA304H4 meter. Also only messagetype 1 and 2 is tested for now

pyhan's People

Contributors

runborg avatar

Watchers

James Cloos avatar

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.