Giter VIP home page Giter VIP logo

energistream-py's Introduction

EnergiStream

EnergiStream is an open source Python client for interacting with EnergiStream API, from MelRok.

https://codecov.io/github/Melrok/energistream-py/coverage.svg?branch=master

Installation

To install EnergiStream from source, clone the git repository to your local machine

$ git clone [email protected]:melrok/energistream-py.git

In the energistream root directory (same one where you found this file after cloning the git repo), execute

$ sudo pip install -e .

Dependencies

EnergiStream has a few key dependancies:

All requirements are specified in the requirements.txt. One can attempt to install these alongside the EnergiStream installation via

$ sudo pip install -r requirements.txt -e .

EnergiStream Guide

A quick guide to some of the core EnergiStream functionality. Examples and additional documentation are available at GitHub Pages.

Note : Always refer to the doctrings for all methods for a detailed summary of functionality.

Importing

To import the energistream library :

import energistream as es

Client Instantiation and Authentication

EnergiStreamClient takes a valid username and password and establishes a unique session with temporary credentials.

stream = es.EnergiStreamClient('USER', 'PASS', include_sensors=True)

authenticate uses the user credentials to authenticate the instantiated client in the event that authentication was not previously established or has lapsed.

stream.authenticate

The is_authenticated method returns a simple boolean true or false when asked if the client authentication is still valid.

stream.is_authenticated

External Data

The get_weather method returns a dataframe of hourly temperature and relative humidity data for the instantiated client's associated physical location.

Note: This data is collected from third party sources. Weather ID is an energistream unique key and not associated to any third party ID schema.

stream.get_weather(weather_id = 102, start = '12/29/2014', end = '1/29/2015')

Energistream Data and Metadata

The get_energy method accepts a sensor ID and returns a dataframe relating active and reactive energy, current and voltage RMS, and total Energy.

stream.get_energy(3505, start = '12/29/2014', end = '1/29/2015', tz = 'local')

The search_group_tree method accepts a keyword and searches the instantiated client for matching sensor groups returning group names, sensor group ID, and assigned sensors.

stream.search_group_tree('Engineering', case = False)

The base_group_level column designates the grouping hierarchy by levels, with 0 being root groups.

stream.groups[stream.groups.base_group_level == 0]

The sensors method returns a dataframe describing the individual sensors associated with the instantiated energistream client ID. This includes the sensor ID, the associated group ID, time zone, and a multiplier based on the method of measurement i.e. one, two, or three channel.

stream.sensors

The get_boards method returns a dataframe describing the boards associated with the instantiated energistream client ID. This includes the boards serial number, version, display name, and model.

stream.get_boards

The get_demand method returns power data for a given sensor group(demand or generation) at multiple resolutions (1, 5, 10, 15, and 30 minutes, daily, weekly, monthly, and yearly). Start and end date may be specified as well as the timezone and desired resolution.

Note: Defaults to the last thirty days and fifteen minute resolution.

stream.get_demand(157)

energistream-py's People

Contributors

nehalecky avatar hwfross avatar davidgaray avatar

Watchers

Avi Flax avatar James Cloos avatar  avatar Nam Nguyen avatar Shad Nygren avatar  avatar Huy Vo avatar  avatar  avatar Tony S. Semaan avatar  avatar  avatar  avatar

Forkers

douglasgoodwin

energistream-py's Issues

get_energy sensor issue

Hello Melrok staff:

For some reason, I seem not to be able to get values from some meters/sensors that I want, in other words, I am using the get_energy command, because I want Reactive Power and Power Factor as well, so I go ahead and do the stream.sensors command: The sensors I am interested in are the ones below:

sensorId                     description          iconId     multiplier                                   name                      properties                  sensorFunctionTypeId  sensorGroupId  sourceTypeId     time_zone
610                          A30006000055-10      21           1                                    AIRB ATS-2 Main  [{u'name': u'Phase', u'value': u'A'}]                     1            141             1  America/Los_Angeles
611                          A30006000055-11      21           1                                    AIRB ATS-2 Main  [{u'name': u'Phase', u'value': u'B'}]                     1            141             1  America/Los_Angeles
612                          A30006000055-12      21           1                                    AIRB ATS-2 Main  [{u'name': u'Phase', u'value': u'C'}]                     1            141             1  America/Los_Angeles
607                          A30006000055-07      21           1                                    AIRB ATS-1 Main  [{u'name': u'Phase', u'value': u'A'}]                     1            140             1  America/Los_Angeles
608                          A30006000055-08      21           1                                    AIRB ATS-1 Main  [{u'name': u'Phase', u'value': u'B'}]                     1            140             1  America/Los_Angeles
609                          A30006000055-09      21           1                                    AIRB ATS-1 Main  [{u'name': u'Phase', u'value': u'C'}]                     1            140             1  America/Los_Angeles
604                          A30006000055-04      21           1                                  AIRB Panel HDP-4A  [{u'name': u'Phase', u'value': u'A'}]                     1            143             1  America/Los_Angeles
605                          A30006000055-05      21           1                                  AIRB Panel HDP-4A  [{u'name': u'Phase', u'value': u'B'}]                     1            143             1  America/Los_Angeles
606                          A30006000055-06      21           1                                  AIRB Panel HDP-4A  [{u'name': u'Phase', u'value': u'C'}]                     1            143             1  America/Los_Angeles
601                          A30006000055-01      21           1                                  AIRB Panel HDP-1A  [{u'name': u'Phase', u'value': u'A'}]                     1            142             1  America/Los_Angeles
602                          A30006000055-02      21           1                                  AIRB Panel HDP-1A  [{u'name': u'Phase', u'value': u'B'}]                     1            142             1  America/Los_Angeles
603                          A30006000055-03      21           1                                  AIRB Panel HDP-1A  [{u'name': u'Phase', u'value': u'C'}]                     1            224             1  America/Los_Angeles

But when I try to run my code for, lets say sensor 610:

data = stream.get_energy(610, start = '05/19/2015', end = '05/20/2015', tz = 'local').head(2)
print(data)

I get the following error in my Python Shell:

Traceback (most recent call last):
  File "C:/Users/ldn/Desktop/energistreamAPITest2.py", line 20, in <module>
    data = stream.get_energy(610, start = '05/19/2015', end = '05/20/2015', tz = 'local').head(2)
  File "build\bdist.win32\egg\energistream\stream.py", line 265, in get_energy
    start, end = _sanitize_dates(start, end, tz=tz)
  File "build\bdist.win32\egg\energistream\stream.py", line 647, in _sanitize_dates
    if tz:
  File "C:\Python27\lib\site-packages\pandas\core\generic.py", line 714, in __nonzero__
    .format(self.__class__.__name__))
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or     a.all().

It seems weird because When I use a 4-digit (or more) sensor number, like 8812 or 9000000151, it works and I get the data:

                             activeEnergy  currentRMS      powerFactor  reactiveEnergy       sensorId    totalEnergy    voltageRMS
2015-05-19 00:01:00-07:00             0       117.9         0.80               0            9000000151            0       276.0
2015-05-19 00:02:00-07:00             0       116.6         0.79               0            9000000151            0       276.1

I really appreciate any help you might be able to give me in the matter.

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.