Client Module

Client module.

This module houses the main class used to fetch energy usage.

class srpenergy.client.SrpEnergyClient(accountid, username, password)

SrpEnergyClient(accountid, username, password).

Client used to fetch srp energy usage.

Parameters:
accountidstring

An srp account id.

username: string

An srp account username.

password: string

An srp account password

Methods

validate()

Validate user credentials.

usage(startdate, enddate)

Get the usage for a given date range.

usage(startdate, enddate, is_tou=False)

Get the energy usage for a given date range.

Parameters:
startdatedatetime

the start date

enddatedatetime

the end date

is_toubool

indicate if usage is a time of use plan

Returns:
list of tuple

In the form of (datepart, timepart, isotime, kw, cost)

Raises:
ValueError

If startdate or enddate are not datetime, or if startdate is greater than enddate, or if startdate is greater than now.

Examples

Get the hourly usage for a given day.

>>> from srpenergy.client import SrpEnergyClient
>>> accountid = 'your account id'
>>> username = 'your username'
>>> password = 'your password'
>>> client = SrpEnergyClient(accountid, username, password)
>>> start_date = datetime(2018, 9, 19, 0, 0, 0)
>>> end_date = datetime(2018, 9, 19, 23, 0, 0)
>>> usage = client.usage(start_date, end_date)
>>> print(usage)
[
('9/19/2018', '12:00 AM', '2018-09-19T00:00:00-7:00', '1.2', '0.17'),
('9/19/2018', '1:00 AM', '2018-09-19T01:00:00-7:00', '2.1', '0.30'),
('9/19/2018', '2:00 AM', '2018-09-19T02:00:00-7:00', '1.5', '0.23'),
...
('9/19/2018', '9:00 PM', '2018-09-19T21:00:00-7:00', '1.2', '0.19'),
('9/19/2018', '10:00 PM', '2018-09-19T22:00:00-7:00', '1.1', '0.18'),
('9/19/2018', '11:00 PM', '2018-09-19T23:00:00-7:00', '0.4', '0.09')
]
validate()

Validate user credentials.

Returns:
bool

Examples

Validate credentials.

>>> from srpenergy.client import SrpEnergyClient
>>>
>>> accountid = 'your account id'
>>> username = 'your username'
>>> password = 'your password'
>>> client = SrpEnergyClient(accountid, username, password)
>>>
>>> valid = client.validate()
>>> print(valid)
True
srpenergy.client.get_pretty_date(date_part)

Return a formatted date from an iso date.

srpenergy.client.get_pretty_time(date_part)

Return a formatted time from an iso date.

srpenergy.client.get_rate(str_usage_time)

Return the time of use pricing for the given time.

From the SRP website peak times: Winter Nov-Apr (5am-9am, 5pm-9pm) 9.51 peak, 6.91 offpeak Summer May-Oct (2pm-8pm) 20.94 peak, 7.27 offpeak Summer Peak Jul,Aug (2pm-8pm) 24.09, 7.3

Higher on-peak prices are in effect Monday through Friday only during the hours shown. Lower off-peak prices are in effect all other weekday hours, weekends and six observed holidays: New Year’s Day, Memorial Day, Independence Day, Labor Day, Thanksgiving Day and Christmas Day.

see https://srpnet.com/prices/pdfx/April2015/E-26.pdf