smeterd


Namesmeterd JSON
Version 2.9.2 PyPI version JSON
download
home_pagehttps://github.com/nrocco/smeterd
SummaryRead smart meter P1 packets
upload_time2023-01-03 09:53:50
maintainer
docs_urlNone
authorNico Di Rocco
requires_python>=3.7
licenseGPLv3
keywords smartmeter kwh gas p1
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            smeterd
=======

![Continious Integration](https://github.com/nrocco/smeterd/workflows/Continious%20Integration/badge.svg?branch=master)

Read P1 smart meter packets in Python


installation
------------

`smeterd` is fully python 3.6+ compatible.

It is highly recommended to use virtualenv for this.
After having your virtualenv installed and activated run the following command to install
the `smeterd` package directly from pypi (using pip):

    $ pip install smeterd


Alternatively you can manually clone `smeterd` and run setupttools `setup.py`:

    $ git clone https://github.com/nrocco/smeterd.git
    $ cd smeterd
    $ python setup.py install


This will install the needed python libraries (in this case only pyserial)
which are needed to start reading P1 packets.

If you don't want to install `smeterd` as a package you can run it directly
from the root directory of the git repository using the following command but
you are responsible for manually installing dependencies:

    $ python -m smeterd



usage as a cli application
--------------------------

To get an idea of the available functionality see the `help` output:

    $ smeterd -h


To make `smeterd` output more verbose use the `-v` option on any of the
following commands. You can repeat the option to increase verbosity:

    $ smeterd -vvv


To get help for a specific subcommand use the `-h` or `--help` after
having typed the subcommand:

    $ smeterd {subcommand} -h


Read one packet from your meter using the following command:

    $ smeterd read-meter
    Time                      2013-08-25 10:10:45.337563
    Total kWh High consumed   651038
    Total kWh Low consumed    546115
    Total gas consumed        963498
    Current kWh tariff        1
    Gas Measured At           1516562094


By default the `read-meter` commands spits out the current date, total kwh1,
total kwh2, total gas amounts and current kWh tariff on multiple lines.

You can make it print the same values as a tab seperated list:

    $ smeterd read-meter --tsv
    2013-05-04 22:22:32.224929	331557	199339	749169	1	1516562094


By piping the output of the `read-meter --tsv` command to a bash script you can fully
customize what you want to do with the data:

    IFS='{tab}'
    while read date kwh1 kwh2 gas tariff gas_measured_at; do
      mysql my_database -e "INSERT INTO data VALUES ('$date', $kwh1, $kwh2, $gas, $tariff, $gas_measured_at);"
    done < /dev/stdin


Typically you run this command from `cron` every x minutes (e.g. 5 minutes):

    */5 * * * * /path/to/venv/bin/smeterd read-meter | save_to_mysql_script.sh


If you need to use another serial port then the default `/dev/ttyUSB0` you can
use the above command with the `--serial-port` option:

    $ smeterd read-meter --serial-port /dev/ttyS0


Currently only kwh1, kwh2 and gas usage are read. If you specify the `--raw`
command line option you will see the raw packet from the smart meter:

    $ smeterd read-meter --raw
    /ISk5\2ME382-1004

    0-0:96.1.1(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
    1-0:1.8.1(00331.476*kWh)
    1-0:1.8.2(00199.339*kWh)
    1-0:2.8.1(00000.000*kWh)
    1-0:2.8.2(00000.000*kWh)
    0-0:96.14.0(0001)
    1-0:1.7.0(0000.13*kW)
    1-0:2.7.0(0000.00*kW)
    0-0:17.0.0(0999.00*kW)
    0-0:96.3.10(1)
    0-0:96.13.1()
    0-0:96.13.0()
    0-1:24.1.0(3)
    0-1:96.1.0(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
    0-1:24.3.0(130504210000)(00)(60)(1)(0-1:24.2.1)(m3)
    (00749.123)
    0-1:24.4.0(1)
    !




usage as a python module
------------------------

If using `smeterd` as a cli application you will find that its functionality
is quite limited. You can use the `smeterd` package as a regular python module
so you can integrate the reading of P1 packets into your own solutions.

First initiate a new SmartMeter object:

    >>> from smeterd.meter import SmartMeter
    >>> meter = SmartMeter('/dev/ttyS0')


Now to read one packet from the meter:

    >>> packet = meter.read_one_packet()
    >>> print packet

Do not forget to close the connection to the serial port:

    >>> meter.disconnect()


The `SmartMeter.meter.read_one_packet()` function will return an instance of
the `smeterd.meter.P1Packet` class.


contribute
----------

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Make sure that tests pass (`make test`)
5. Push to the branch (`git push origin my-new-feature`)
6. Create new Pull Request

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nrocco/smeterd",
    "name": "smeterd",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "smartmeter,kwh,gas,p1",
    "author": "Nico Di Rocco",
    "author_email": "dirocco.nico@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/59/02/8331cfc0295c0f423c6dd8ff9774fd22f660acefb8e74d72b12fa6419c8c/smeterd-2.9.2.tar.gz",
    "platform": "any",
    "description": "smeterd\n=======\n\n![Continious Integration](https://github.com/nrocco/smeterd/workflows/Continious%20Integration/badge.svg?branch=master)\n\nRead P1 smart meter packets in Python\n\n\ninstallation\n------------\n\n`smeterd` is fully python 3.6+ compatible.\n\nIt is highly recommended to use virtualenv for this.\nAfter having your virtualenv installed and activated run the following command to install\nthe `smeterd` package directly from pypi (using pip):\n\n    $ pip install smeterd\n\n\nAlternatively you can manually clone `smeterd` and run setupttools `setup.py`:\n\n    $ git clone https://github.com/nrocco/smeterd.git\n    $ cd smeterd\n    $ python setup.py install\n\n\nThis will install the needed python libraries (in this case only pyserial)\nwhich are needed to start reading P1 packets.\n\nIf you don't want to install `smeterd` as a package you can run it directly\nfrom the root directory of the git repository using the following command but\nyou are responsible for manually installing dependencies:\n\n    $ python -m smeterd\n\n\n\nusage as a cli application\n--------------------------\n\nTo get an idea of the available functionality see the `help` output:\n\n    $ smeterd -h\n\n\nTo make `smeterd` output more verbose use the `-v` option on any of the\nfollowing commands. You can repeat the option to increase verbosity:\n\n    $ smeterd -vvv\n\n\nTo get help for a specific subcommand use the `-h` or `--help` after\nhaving typed the subcommand:\n\n    $ smeterd {subcommand} -h\n\n\nRead one packet from your meter using the following command:\n\n    $ smeterd read-meter\n    Time                      2013-08-25 10:10:45.337563\n    Total kWh High consumed   651038\n    Total kWh Low consumed    546115\n    Total gas consumed        963498\n    Current kWh tariff        1\n    Gas Measured At           1516562094\n\n\nBy default the `read-meter` commands spits out the current date, total kwh1,\ntotal kwh2, total gas amounts and current kWh tariff on multiple lines.\n\nYou can make it print the same values as a tab seperated list:\n\n    $ smeterd read-meter --tsv\n    2013-05-04 22:22:32.224929\t331557\t199339\t749169\t1\t1516562094\n\n\nBy piping the output of the `read-meter --tsv` command to a bash script you can fully\ncustomize what you want to do with the data:\n\n    IFS='{tab}'\n    while read date kwh1 kwh2 gas tariff gas_measured_at; do\n      mysql my_database -e \"INSERT INTO data VALUES ('$date', $kwh1, $kwh2, $gas, $tariff, $gas_measured_at);\"\n    done < /dev/stdin\n\n\nTypically you run this command from `cron` every x minutes (e.g. 5 minutes):\n\n    */5 * * * * /path/to/venv/bin/smeterd read-meter | save_to_mysql_script.sh\n\n\nIf you need to use another serial port then the default `/dev/ttyUSB0` you can\nuse the above command with the `--serial-port` option:\n\n    $ smeterd read-meter --serial-port /dev/ttyS0\n\n\nCurrently only kwh1, kwh2 and gas usage are read. If you specify the `--raw`\ncommand line option you will see the raw packet from the smart meter:\n\n    $ smeterd read-meter --raw\n    /ISk5\\2ME382-1004\n\n    0-0:96.1.1(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)\n    1-0:1.8.1(00331.476*kWh)\n    1-0:1.8.2(00199.339*kWh)\n    1-0:2.8.1(00000.000*kWh)\n    1-0:2.8.2(00000.000*kWh)\n    0-0:96.14.0(0001)\n    1-0:1.7.0(0000.13*kW)\n    1-0:2.7.0(0000.00*kW)\n    0-0:17.0.0(0999.00*kW)\n    0-0:96.3.10(1)\n    0-0:96.13.1()\n    0-0:96.13.0()\n    0-1:24.1.0(3)\n    0-1:96.1.0(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)\n    0-1:24.3.0(130504210000)(00)(60)(1)(0-1:24.2.1)(m3)\n    (00749.123)\n    0-1:24.4.0(1)\n    !\n\n\n\n\nusage as a python module\n------------------------\n\nIf using `smeterd` as a cli application you will find that its functionality\nis quite limited. You can use the `smeterd` package as a regular python module\nso you can integrate the reading of P1 packets into your own solutions.\n\nFirst initiate a new SmartMeter object:\n\n    >>> from smeterd.meter import SmartMeter\n    >>> meter = SmartMeter('/dev/ttyS0')\n\n\nNow to read one packet from the meter:\n\n    >>> packet = meter.read_one_packet()\n    >>> print packet\n\nDo not forget to close the connection to the serial port:\n\n    >>> meter.disconnect()\n\n\nThe `SmartMeter.meter.read_one_packet()` function will return an instance of\nthe `smeterd.meter.P1Packet` class.\n\n\ncontribute\n----------\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Make sure that tests pass (`make test`)\n5. Push to the branch (`git push origin my-new-feature`)\n6. Create new Pull Request\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "Read smart meter P1 packets",
    "version": "2.9.2",
    "split_keywords": [
        "smartmeter",
        "kwh",
        "gas",
        "p1"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4cd15086250bfe7e2a7b94de301b88ce50fde71e412ff225fc5583648abdf3ec",
                "md5": "b824687e2503dec69e410523b7762071",
                "sha256": "4b1aa201ad74f4f9f2befda087323a4ccf974e9554229af5c69943ae5fd4ffb0"
            },
            "downloads": -1,
            "filename": "smeterd-2.9.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b824687e2503dec69e410523b7762071",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 9330,
            "upload_time": "2023-01-03T09:53:48",
            "upload_time_iso_8601": "2023-01-03T09:53:48.014346Z",
            "url": "https://files.pythonhosted.org/packages/4c/d1/5086250bfe7e2a7b94de301b88ce50fde71e412ff225fc5583648abdf3ec/smeterd-2.9.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "59028331cfc0295c0f423c6dd8ff9774fd22f660acefb8e74d72b12fa6419c8c",
                "md5": "cdfe5cc2e10975415551100409ec60cf",
                "sha256": "834eed583f3b967fe51b4daacba74786e721485aeff3260add96f540ed5a702f"
            },
            "downloads": -1,
            "filename": "smeterd-2.9.2.tar.gz",
            "has_sig": false,
            "md5_digest": "cdfe5cc2e10975415551100409ec60cf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 10620,
            "upload_time": "2023-01-03T09:53:50",
            "upload_time_iso_8601": "2023-01-03T09:53:50.016345Z",
            "url": "https://files.pythonhosted.org/packages/59/02/8331cfc0295c0f423c6dd8ff9774fd22f660acefb8e74d72b12fa6419c8c/smeterd-2.9.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-03 09:53:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "nrocco",
    "github_project": "smeterd",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "smeterd"
}
        
Elapsed time: 0.04588s