nrgpy.api.export module#

class nrgpy.api.export.nrg_api_export(out_dir='', serial_number='', out_file='', start_date='2014-01-01', end_date='2023-12-31', client_id='', client_secret='', nec_file='', export_type='meas', text_timestamps=False, save_file=True, **kwargs)[source]#

Bases: nrg_api

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

Parameters:
out_dirstr (path-like)

path to save exported data

out_filestr

(optional) filename to save

serial_numberstr 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

client_idstr

provided by NRG Systems

client_secretstr

provided by NRG Systems

save_filebool

(True) whether to save the result to file

nec_filestr, optional

path to NEC file for custom export formatting

text_timestampsbool

get export data with text timestamps instead of datetime

export_typestr

[meas], samples, diag, comm

Returns:
object

export object that includes an nrgpy reader object

Examples

Download 3 days of data with an NEC file applied

>>> import nrgpy
>>> client_id = "contact support@nrgsystems.com for access"
>>> client_secret = "contact support@nrgsystems.com for access"
>>> exporter = nrgpy.nrg_api_export(
        client_id=client_id,
        client_secret=client_secret,
        out_dir=txt_dir,
        nec_file='12vbat.nec',
        serial_number=820600019,
        start_date="2020-05-01",
        end_date="2020-05-03",
        text_timestamps=False,
        save_file=False
    )
>>> reader = exporter.reader
>>> 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]#