{"id":18257945,"url":"https://github.com/linkdd/phase-currentcost","last_synced_at":"2025-04-08T22:46:53.779Z","repository":{"id":17780354,"uuid":"20651136","full_name":"linkdd/phase-currentcost","owner":"linkdd","description":"CurrentCost data collector script for phase project.","archived":false,"fork":false,"pushed_at":"2014-06-10T07:50:28.000Z","size":1249,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T17:57:49.360Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://phase-currentcost.readthedocs.org/en/latest/index.html","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linkdd.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE.rst","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-09T15:17:13.000Z","updated_at":"2015-06-06T19:10:12.000Z","dependencies_parsed_at":"2022-09-10T12:20:14.251Z","dependency_job_id":null,"html_url":"https://github.com/linkdd/phase-currentcost","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdd%2Fphase-currentcost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdd%2Fphase-currentcost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdd%2Fphase-currentcost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdd%2Fphase-currentcost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linkdd","download_url":"https://codeload.github.com/linkdd/phase-currentcost/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247941719,"owners_count":21022037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T10:28:19.050Z","updated_at":"2025-04-08T22:46:53.751Z","avatar_url":"https://github.com/linkdd.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=================\nphase-currentcost\n=================\n\n.. image:: http://img.shields.io/travis/liogen/phase-currentcost.png?branch=master\n    :target: https://travis-ci.org/liogen/phase-currentcost\n    :alt: Travis CI Build Status\n\n.. image:: http://img.shields.io/pypi/v/phase-currentcost.png\n    :target: https://pypi.python.org/pypi/phase-currentcost\n    :alt: Latest Version\n\n.. image:: http://img.shields.io/pypi/dm/phase-currentcost.png\n    :target: https://pypi.python.org/pypi/phase-currentcost\n    :alt: Downloads\n\n.. image:: http://img.shields.io/badge/license-MIT-red.png\n    :target: https://github.com/liogen/phase-currentcost\n    :alt: License\n\nCurrentCost data collector script for phase project.\n\n`CurrentCost EnviR 128 \u003chttp://www.currentcost.com/product-envir.html\u003e`_ is an appliance that monitor your electricity consumption and provide an `API \u003chttp://www.currentcost.com/cc128/xml.htm\u003e`_ to retrieve data from USB cable.\n\nphase-currentcost allow use to retrieve data from usb cable using `pyserial \u003chttp://pyserial.sourceforge.net/\u003e`_ and transmit information to stdout or to `RabbitMQ \u003chttps://www.rabbitmq.com/\u003e`_ using `Pika \u003chttp://pika.readthedocs.org/en/latest/\u003e`_ module. \n\nMore precisly, this script collect instantaneous and historical data from Current Cost. It also take care of usb disconnection, Current Cost bad message format, timeout and power disconnection and send an error on stdout or on RabbitMQ each time for later anlysis. Also it create an udev rule to transform /dev/ttyUSB* to /dev/currentcost for serial port connection.\n\nFor more information, full documentation is available on `readthedocs.org \u003chttp://phase-currentcost.readthedocs.org/en/latest/\u003e`_\n\nInstallation\n------------\n\nRequirements:\n\n  * Platform: Unix (only tested on Ubuntu 12.04)\n  * Python 2.7\n  * Pip (last version)\n  * RabbitMQ (last version)\n\nTo install this software, you need to install python 2.7 and pip\n\n.. code-block:: bash\n  \n  $ sudo apt-get install python python-pip\n  $ sudo pip install --upgrade pip\n\nThen, you have to install and configure RabbitMQ (change \"admin\" and \"password\" by your credential)\n\n.. code-block:: bash\n  \n  $ USERNAME=\"admin\"\n  $ PASSWORD=\"password\" \n  $ echo \"deb http://www.rabbitmq.com/debian/ testing main\" \u003e sudo /etc/apt/sources.list.d/rabbitmq.list\n  $ wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc\n  $ sudo apt-key add rabbitmq-signing-key-public.asc\n  $ sudo apt-get update\n  $ sudo apt-get install rabbitmq-server -y\n  $ sudo service rabbitmq-server start\n  # If you get a 'command not found' error for this line, use /usr/lib/rabbitmq/bin/rabbitmq-plugins instead\n  $ sudo rabbitmq-plugins enable rabbitmq_management\n  $ sudo rabbitmqctl add_user $USERNAME $PASSWORD\n  $ sudo rabbitmqctl set_user_tags $USERNAME administrator\n  $ sudo rabbitmqctl set_permissions -p / $USERNAME \".*\" \".*\" \".*\"\n  $ sudo rabbitmqctl delete_user guest\n  $ sudo service rabbitmq-server restart\n\nThen you can install phase-currentcost\n\n.. code-block:: bash\n  \n  $ sudo pip install phase-currentcost\n\nUsage\n-----\n\n.. code-block:: bash\n\n    $ sudo phase-currentcost -h\n    usage: phase-currentcost [-h] [-c /path/to/config.ini]\n\n    optional arguments:\n      -l LOG_CONF, --log-conf LOG_CONF\n                            path to log configuration\n      -v, --verbose         activate verbose mode\n\nConfiguration\n-------------\n\n.. code-block:: ini\n\n    # Configure current cost plugin\n    [currentcost]\n\n    ## Variable's name\n    # variable_name = \n\n    ## Name of the variable's location\n    # site_name =\n\n    ## TTY port to connect to current cost\n    # tty_port = \n\n\n    # Configure how data are sent to RabbitMQ\n    [rabbitmq]\n\n    enabled = true\n    url = amqp://guest:guest@127.0.0.1:5672/\n\n    # Configure Canopsis compatibility mode\n    [canopsis]\n\n    enabled = false\n\n    connector = phase\n    connector_name = currentcost\n    component = $siteID\n    resource = $variableID\n\n\nBy default:\n\n* We targetting /dev/currentcost as tty port.\n* RabbitMQ is not activated. We send message to stdout so you can collect it on file. If you want to share your message over the network using RabbitMQ, you can activate this function by enabling it in the configuration file.\n* Log configuration file is located in /opt/phase/phase-currentcost.conf and log file is in /var/logs/phase/phase-currentcost.log. You can set log configuration file using -l option with a path to your log.conf file.\n\nExamples\n--------\n\nTo see the current consumption on Current cost on stdout use this config file:\n\n.. code-block:: ini\n\n    [currentcost]\n\n    variable_name = electric_meter\n    site_name = liogen_home\n    tty_port = /dev/currentcost\n\n\n.. code-block:: bash\n    \n    $ sudo phase-currentcost -c currentcost.ini\n    {\"variableID\": \"electric_meter\", \"dstTimezone\": \"UTC\", \"siteID\": \"liogen_home\", \"date\": \"2014-04-25T12:00:17.754959\", \"message\": \"CurrentCost electric_meter in liogen_home: TTY connection problem: /dev/currentcost is unreachable. Retry connection in 5 seconds.\", \"nonDstTimezone\": \"UTC\"} \n    {\"variableID\": \"electric_meter\", \"dstTimezone\": \"UTC\", \"siteID\": \"liogen_home\", \"date\": \"2014-04-25T12:00:22.769256\", \"message\": \"CurrentCost electric_meter in liogen_home: TTY connection problem: /dev/currentcost is unreachable. Retry connection in 5 seconds.\", \"nonDstTimezone\": \"UTC\"}\n    {\"variableID\": \"electric_meter\", \"dstTimezone\": \"UTC\", \"siteID\": \"liogen_home\", \"date\": \"2014-04-25T12:00:22.769256\", \"message\": \"\u003cmsg\u003e\u003csrc\u003eCC128-v1.29\u003c/src\u003e\u003cdsb\u003e00786\u003c/dsb\u003e\u003ctime\u003e00:31:36\u003c/time\u003e\u003ctmpr\u003e19.3\u003c/tmpr\u003e\u003csensor\u003e0\u003c/sensor\u003e\u003cid\u003e00077\u003c/id\u003e\u003ctype\u003e1\u003c/type\u003e\u003cch1\u003e\u003cwatts\u003e00405\u003c/watts\u003e\u003c/ch1\u003e\u003c/msg\u003e\", \"nonDstTimezone\": \"UTC\"}\n\nWith rabbitMQ message over the network with verbose mode activated:\n\n.. code-block:: ini\n\n    [currentcost]\n\n    variable_name = electric_meter\n    site_name = liogen_home\n    tty_port = /dev/currentcost\n\n    [rabbitmq]\n\n    enabled = true\n    url = amqp://admin:password@127.0.0.1:5672/\n\n.. code-block:: bash\n\n    $ sudo phase-currentcost -c currentcost.ini -v\n    Starting current cost application\n    Current time: 2014-04-25 12:01:34.350781\n    Variable name: electric_meter\n    Site name: liogen_home\n    TTY port: /dev/currentcost\n\n    {\"variableID\": \"electric_meter\", \"dstTimezone\": \"UTC\", \"siteID\": \"liogen_home\", \"date\": \"2014-04-25T12:00:22.769256\", \"message\": \"\u003cmsg\u003e\u003csrc\u003eCC128-v1.29\u003c/src\u003e\u003cdsb\u003e00786\u003c/dsb\u003e\u003ctime\u003e00:31:36\u003c/time\u003e\u003ctmpr\u003e19.3\u003c/tmpr\u003e\u003csensor\u003e0\u003c/sensor\u003e\u003cid\u003e00077\u003c/id\u003e\u003ctype\u003e1\u003c/type\u003e\u003cch1\u003e\u003cwatts\u003e00405\u003c/watts\u003e\u003c/ch1\u003e\u003c/msg\u003e\", \"nonDstTimezone\": \"UTC\"}\n    {\"variableID\": \"electric_meter\", \"dstTimezone\": \"UTC\", \"siteID\": \"liogen_home\", \"date\": \"2014-04-25T12:00:22.769256\", \"message\": \"\u003cmsg\u003e\u003csrc\u003eCC128-v1.29\u003c/src\u003e\u003cdsb\u003e00786\u003c/dsb\u003e\u003ctime\u003e00:31:36\u003c/time\u003e\u003ctmpr\u003e19.3\u003c/tmpr\u003e\u003csensor\u003e0\u003c/sensor\u003e\u003cid\u003e00077\u003c/id\u003e\u003ctype\u003e1\u003c/type\u003e\u003cch1\u003e\u003cwatts\u003e00405\u003c/watts\u003e\u003c/ch1\u003e\u003c/msg\u003e\", \"nonDstTimezone\": \"UTC\"}\n\nMessage send through RabbitMQ\n-----------------------------\n\nA message is a JSON containing this properties:\n\n:variableID: Name of the variable\n:siteID: Name of the site\n:date: Date in UTC\n:dstTimezone: Timezone with DST\n:nonDstTimezone: Timezone without DST\n:message: Message to deliver through RabbitMQ\n\nMessages list:\n\n+-------------+---------------------------------+---------------------------------------------------+ \n| Channel     | Message                         | Description                                       |\n+=============+=================================+===================================================+ \n| error       | utils.TTY_CONNECTION_PROBLEM    | Send when TTY port is not reachable               |\n+-------------+---------------------------------+---------------------------------------------------+\n| error       | utils.CURRENTCOST_TIMEOUT       | Send when TTY port is connected but reach timeout |\n+-------------+---------------------------------+---------------------------------------------------+\n| error       | utils.CC_INCORRECT_MESSAGE      | Send when Currentcost send an invalid message     |\n+-------------+---------------------------------+---------------------------------------------------+\n| currentcost | CurrentCost XML message         | Send Currentcost XML message                      |\n+-------------+---------------------------------+---------------------------------------------------+\n\nWhen Canopsis mode is enabled, message sent through RabbitMQ respect the event specification of Canopsis.\n\nContribute\n----------\n\nI am more than happy to accept external contributions like feedback, bug reports and pull requests. \n\nDo not hesitate to post an `issue \u003chttps://github.com/liogen/phase-currentcost/issues\u003e`_ if you have any problem to install or to use this software.\n\nYou can also use this way to ask for a Feature request. I am also available to answer you on `Stack Overflow \u003chttp://stackoverflow.com/questions/tagged/phase-currentcost\u003e`_\n\nHere is the development process to test and validate your features.\n\n1. Prepare your development environment:\n\n    .. code-block:: bash\n\n        # `Socat \u003chttp://www.dest-unreach.org/socat/\u003e`_ is usefull to create socket connection between 2 files.\n        $ sudo apt-get install socat vim git-core\n        # Install virtualenv and virtualenvwrapper if it's not done.\n        $ sudo pip install virtualenvwrapper\n        $ mkdir ~/.virtualenvs\n        $ vim ~/.bashrc\n        # Modify your ~/.bashrc and add this 2 lines:\n        # export WORKON_HOME=~/.virtualenvs\n        # source /usr/local/bin/virtualenvwrapper.sh\n        $ bash\n\n2. Go on `github \u003chttps://github.com/liogen/phase-currentcost\u003e`_ and fork this project.\n\n3. Clone it on your conputer:\n\n    .. code-block:: bash\n\n        $ cd \u003cyour_workspace\u003e\n        $ git clone git@github.com:\u003cusername\u003e/phase-currentcost.git\n        $ git checkout develop\n\n4. Prepare your virtualenv\n\n    .. code-block:: bash\n\n        $ mkvirtualenv phase\n        (phase)$ pip install paver\n        (phase)$ paver prepare\n\n5. Add functional or unit tests\n\n6. Code your features\n\n7. To validate your implementation, launch:\n\n    .. code-block:: bash\n\n        (phase)$ paver validate\n\n8. Modify Todo, Changelog and update documentation\n\n9. Commit and push on github:\n\n    .. code-block:: bash\n\n        (phase)$ git add .\n        (phase)$ git commit -a -m \"\u003cyour commit message\u003e\"\n        (phase)$ git push origin develop  \n\n10. Propose a pull request on github\n\nLicense\n-------\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Pierre Leray\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkdd%2Fphase-currentcost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinkdd%2Fphase-currentcost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkdd%2Fphase-currentcost/lists"}