nrgpy.cloud_api.export module#

class nrgpy.cloud_api.export.cloud_export(out_dir='', site_id='', site_number='', logger_sn='', start_date='2014-01-01', end_date='2030-12-31', file_format='txt', client_id='', client_secret='', nec_file='', export_type='measurements', interval='', unzip=True, **kwargs)[source]#

Bases: nrgpy.cloud_api.auth.cloud_api

Uses NRG hosted web-based API to download data in text format To sign up for the service, go to https://cloud.nrgsystems.com

Note that the site must exist in the NRG Cloud platform, and you must have Contributor or Administrator level access to the site to use these features.

Use the Site Number or NRG Cloud Site ID to choose the site.

Parameters
out_dirstr

path to save exported data

site_idint

NRG Cloud site identifier (NOT the site number)

site_numberint

site number

logger_snstr or int

serial number of data logger (like, 820612345)

start_datestr

“YYYY-MM-DD HH:MM:SS” format, if just date it will return the whole day times are in logger local time

end_datestr

“YYYY-MM-DD HH:MM:SS” format, if just date it will return the whole day times are in logger local time

file_formatstr

[‘txt’], ‘rld’ - whether tab-delimited text or binary output

client_idstr

available in the NRG Cloud portal

client_secretstr

available in the NRG Cloud portal

nec_filestr, optional

path to NEC file for custom export formatting

export_typestr

[‘measurements’], ‘diagnostic’, ‘events’, ‘communication’

intervalstr, optional

‘oneMinute’, ‘twoMinute’, ‘fiveMinute’, ‘tenMinute’, ‘fifteenMinute’, ‘thirtyMinute’, ‘Hour’, ‘Day’ must be a multiple of the logger’s statistical interval

unzipbool

(True) whether to extract the .txt data file from the .zip file

Returns
object

export object, including API response

Examples

Download 15 days of data with an NEC file applied, and read data

>>> import nrgpy
>>>
>>> client_id = "go to https://cloud.nrgsystems.com for access"
>>> client_secret = "go to https://cloud.nrgsystems.com for access"
>>> save_dir = '/path/to/exported/data'
>>>
>>> exporter = nrgpy.cloud_export(
        client_id=client_id,
        client_secret=client_secret,
        out_dir=save_dir,
        nec_file='12vbat.nec',
        site_id=245,
        start_date="2021-05-01",
        end_date="2021-05-15",
    )
>>> exporter.export()
>>> # read result
>>> reader = nrgpy.sympro_txt_read(exporter.export_filepath)
>>> reader.format_site_data()
>>> if reader:
>>>     print(f"Site number               : {reader.site_number}")
>>>     print(f"Site description          : {reader.site_description}")
>>>     reader.interval_check = nrgpy.check_intervals(reader.data)
>>> else:
>>>     print("unable to get reader")
export()[source]#