Melrok / energistream-py

A Python client for interacting with EnergiStream API, from MelRok.
http://melrok.github.io/energistream-py/
MIT License
0 stars 1 forks source link

get_energy sensor issue #15

Open LauraNovoa opened 9 years ago

LauraNovoa commented 9 years ago

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.

LauraNovoa commented 9 years ago

I downloaded the new version Resolution to energistream-py issue #15... that you posted and installed it :

unnamed

But again, when I try to use get_energy command for sensor 610

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

it still shows me the error:

Traceback (most recent call last):
  File "C:\Users\ldn\Desktop\EnergiStream Python Laura\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().

I'm sure I am doing something wrong here.... could you please help?

hwfross commented 9 years ago

1) From your local energistream-py directory make sure you are on the master branch :

$ git checkout master $ git pull origin

2) Verify that the merge has been completed successfully :

$ git log

Look for the following commit ID : commit d27c10ff946fbb93e713072db8a876b8e2d53f57

3) Run a pip install for the current directory. As we are operating on unix we are unable to verify the installation process in windows.

4) Please terminate and restart your ipython session from the terminal.

At this point you should have our updated changes, hopefully our command will work at this point.

When you run energistream-py and instantiate the stream you would previously have done so with a command such as :

energiscore.EnergiStreamClient(‘USER’,'PASS')

Replace this with :

energiscore.EnergiStreamClient(‘USER’,’PASS’, include_sensors=True)

Reply :

1) should I input the command line in the Python Shell or on the Windows cmd window? I tried both and it didn’t work (screenshots below)…. I tried different combinations of the command, like not inputting the ‘$’ ... I am sorry this is probably something very obvious that I just don’t have any background of...

image

image1

Inline image 2 2) Same as 1) : where do I input this command?

3) When you say: run a pip install you mean just entering the command line ‘pip install’ ?

4) When you say restart your ipython session from the terminal, again should I use the Python Shell or Windows cmd window? What are the commands lines to do so?

Lastly, on the full command I am running I just notice I already have the ‘include_sensors = True’ Here is copy of it all: *NOTE: I didn't write that. It was one of our former grad students.

import csv import pandas as pd import energistream as es # Imports the Energiscore Library import datetime as dt # Imports the datetime Library for timeseries handling import numpy as np # Imports the Numpy Library for series handling

pd.set_option('display.height', 100000) pd.set_option('display.max_rows', 50000) pd.set_option('display.max_columns', 500000) pd.set_option('display.width', 100000) import energistream as es stream = es.EnergiStreamClient(‘USER’, ‘pass', include_sensors=True)

boardID = 139

data = stream.get_demand(boardID, start = '4/13/2015', end = '4/14/2015', resolution='15T')

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

Again I apologize for asking such basic things. I really appreciate all the help thus far. I really appreciate the level of detail on your step by step! Unfortunately I could not even get pass the first step... Here are my questions:

1) should I input the command line in the Python Shell or on the Windows cmd window? I tried both and it didn’t work (screenshots below)…. I tried different combinations of the command, like not inputting the ‘$’ ... I am sorry this is probably something very obvious that I just don’t have any background of... Inline image 1

Inline image 2 2) Same as 1) : where do I input this command?

3) When you say: run a pip install you mean just entering the command line ‘pip install’ ?

4) When you say restart your ipython session from the terminal, again should I use the Python Shell or Windows cmd window? What are the commands lines to do so?

Lastly, on the full command I am running I just notice I already have the ‘include_sensors = True’ Here is copy of it all: *NOTE: I didn't write that. It was one of our former grad students.

import csv import pandas as pd import energistream as es # Imports the Energiscore Library import datetime as dt # Imports the datetime Library for timeseries handling import numpy as np # Imports the Numpy Library for series handling

pd.set_option('display.height', 100000) pd.set_option('display.max_rows', 50000) pd.set_option('display.max_columns', 500000) pd.set_option('display.width', 100000) import energistream as es stream = es.EnergiStreamClient(‘USER’, ‘pass', include_sensors=True)

boardID = 139

data = stream.get_demand(boardID, start = '4/13/2015', end = '4/14/2015', resolution='15T')

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

Again I apologize for asking such basic things. I really appreciate all the help thus far.

hwfross commented 9 years ago

Laura, could you describe how you originally copied the energistream-py repository?

LauraNovoa commented 9 years ago

Harry, I downloaded the ZIP of the repo and I unzipped it on my C: drive. I manually downloaded the requisites: pandas, requests, and testfixtures and I followed the online procedures to install them. After I had pip installed I could run the commands on my windows cmd:

cd C:\energistream-py-master\energistream
pip install stream

To make sure I went to C:\energistream-py-master and clicked on setup.py ....

Also, I typed on my windows cmd

pip install stream --upgrade

And I got the following:

1

hwfross commented 9 years ago

Thank you, Laura.

At this time the shortest path to get running again would be to completely delete your local energistream-py repository, re-download the energistream-py repository which we have updated on GitHub, and reinstall using the procedure you described above.

Here is the zip URL :

https://github.com/Melrok/energistream-py/archive/master.zip

From the command line navigate into the new unzipped energistream-py repo and run :

$ sudo pip install -e .

You should only need to do this for energistream-py, the rest of the dependencies should be fine as is.

You should then be able to execute your shell commands as you were doing previously. Just remember when instantiating the stream client inside of the shell to replace the line :

 energiscore.EnergiStreamClient(‘USER’,'PASS')

With :

 energiscore.EnergiStreamClient(‘USER’,’PASS’, include_sensors=True)

For future reference the repository 'stream' is not related to our product and its name is coincidental. Our product is currently not available from the python package library. I am sorry for any confusion this similarity may have caused you.