Skip to content

API Documentation

Interface to the PVOutput API

PVOutput

Bases: PVOutputBase

This class provides an interface to the pvoutput.org API

Source code in pvoutput/__init__.py
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
class PVOutput(PVOutputBase):
    """This class provides an interface to the pvoutput.org API"""

    # pylint: disable=too-many-arguments
    def __init__(
        self,
        apikey: str,
        systemid: int,
        donation_made: bool = False,
        stats_period: int = 5,
        session: Optional[requests.Session] = None,
    ):
        """Setup code
        :param apikey: API key (read or write)
        :type apikey: str
        :param systemid: system ID
        :type systemid: int
        :param donation_made: Whether to use the donation-required fields
        :type donation_made: bool
        """
        super().__init__(
            apikey=apikey,
            systemid=systemid,
            donation_made=donation_made,
            stats_period=stats_period,
        )
        self.session = session
        if session is None:
            self.session = requests.Session()

    def _call(
        self,
        endpoint: str,
        method: str = "POST",
        **kwargs: Dict[str, Any],
    ) -> requests.Response:
        """Makes a call to a URL endpoint with the data/headers/method you require.

        :param endpoint: The URL to call
        :type endpoint: str

        :param data: Data to send
        :type data: dict

        :param headers: Additional headers, if unset it'll use self._headers() which is the standard API key / systemid set (eg, self.check_rate_limit)
        :type headers: dict

        :param method: specify a method if you want to use something other than POST
        :type method: str

        :returns: The response object
        :rtype: requests.Response

        :raises TypeError: if the data you pass is of the wrong format.
        :raises ValueError: if the call throws a HTTP 400 error.
        :raises requests.exception: if method throws an exception.
        """

        self.validate_data(kwargs, CALL_PARAMETERS)

        if method == "GET":
            response = requests.get(
                endpoint,
                data=kwargs.get("data"),
                headers=kwargs.get("headers", self._headers()),
                params=kwargs.get("params"),
                timeout=DEFAULT_REQUEST_TIMEOUT,
            )
        elif method == "POST":
            response = requests.post(
                endpoint,
                data=kwargs.get("data"),
                headers=kwargs.get("headers", self._headers()),
                timeout=DEFAULT_REQUEST_TIMEOUT,
            )
        else:
            raise UnknownMethodError(f"unknown method {kwargs['method']}")

        if response.status_code == 400:
            # TODO: work out how to get the specific response and provide useful answers
            raise ValueError(f"HTTP400: {response.text.strip()}")
        # likely errors - https://pvoutput.org/help/api_specification.html#error-messages
        response.raise_for_status()
        return response

    def check_rate_limit(self) -> Dict[str, str]:
        """Makes a call to the site, checking if you have hit the rate limit.

        API spec: https://pvoutput.org/help/api_specification.html#rate-limits

        :returns: the headers relating to the rate limit.
        :rtype: dict
        """
        headers = self._headers()
        headers["X-Rate-Limit"] = "1"

        url, method = utils.URLS["getsystem"]

        response = self._call(endpoint=url, params={}, headers=headers, method=method)
        retval = utils.get_rate_limit_header(response)
        return retval

    def addbatchstatus(
        self, data: str, c1: bool = False, n: bool = False
    ) -> requests.Response:
        """
        # Add Batch Status Service

        The Add Batch Status service adds up to 30 statuses in a single request.
        See the documentation on the page for what it means, and what it responds with.
        This hasn't been tested.
        <https://pvoutput.org/help/api_specification.html#add-batch-status-service>

        ## Data Structure

        The data parameter consists of up to 30 statuses, each status contains multiple fields.

        Field Delimiter - ,
        Output Delimiter - ;

        ## Example data

        Send three statuses from 10:00AM to 10:10AM in a single batch request

        `data="20110112,10:00,705,1029;20110112,10:05,775,1320;20110112,10:10,800,800"`

        ## Donation features

        * The d date parameter must be not be older than 90 days from the current date.
        * Extended parameters v7, v8, v9, v10, v11 and v12
        * Maximum energy consumption v3 value increased to 9,999,999Wh
        * Maximum power consumption v4 value increased to 2,000,000W
        * Increased batch status size to 100 from 30
        """
        payload = {
            "data": data,
        }
        if c1:
            payload["c1"] = "1"
        if n:
            payload["n"] = "1"

        url, method = utils.URLS["addbatchstatus"]
        self.validate_data(payload, ADDBATCHSTATUS_PARAMETERS)
        url, method = utils.URLS["addstatus"]
        return self._call(endpoint=url, data=payload, method=method)

    def addstatus(
        self,
        data: Dict[str, Any],
    ) -> requests.Response:
        """The Add Status service accepts live output data
        at the Status Interval (5 to 15 minutes) configured for the system.

        API Spec: https://pvoutput.org/help/api_specification.html#add-status-service

        :param data: The status data
        :type data: dict

        :returns: The response object
        :rtype: requests.Response
        """
        # if you don't set a time, set it to now
        # can't push this through the validator as it relies on the class config
        if "t" not in data:
            data["t"] = self.get_time_by_base()
        self.validate_data(data, ADDSTATUS_PARAMETERS)

        url, method = utils.URLS["addstatus"]

        return self._call(endpoint=url, data=data, method=method)

    def addoutput(
        self,
        data: Dict[str, Any],
    ) -> requests.Response:
        """The Add Output service uploads end of day output information.
        It allows all of the information provided on the Add Output page to be uploaded.

        API Spec: https://pvoutput.org/help/api_specification.html#add-output-service

        :param data: The output data to upload
        :type data: dict

        :returns: The response object
        :rtype: requests.Response
        """
        self.validate_data(data, ADDOUTPUT_PARAMETERS)
        url, method = utils.URLS["addoutput"]
        return self._call(endpoint=url, data=data, method=method)

    def delete_status(
        self, date_val: datetime.date, time_val: Optional[datetime.time] = None
    ) -> requests.Response:
        """
        Deletes a given status, based on the provided parameters
        needs a datetime() object
        set the hours/minutes to non-zero to delete a specific time

        API spec: https://pvoutput.org/help/api_specification.html#delete-status-service

        :param date_val: The date to delete.
        :type date_val: datetime.datetime.date

        :param time_val: The time entry to delete.
        :type time_val: datetime.datetime.time

        :returns: The response object
        :rtype: requests.Response
        """
        self.validate_data(
            {
                "date_val": date_val,
                "time_val": time_val,
            },
            DELETESTATUS_PARAMETERS,
        )

        data = {"d": date_val.strftime("%Y%m%d")}
        if time_val is not None:
            data["t"] = time_val.strftime("%H:%M")

        url, method = utils.URLS["deletestatus"]

        return self._call(endpoint=url, data=data, method=method)

    def getstatus(self) -> Dict[str, Any]:
        """The Get Status service retrieves system status information and live output data.

        API spec: https://pvoutput.org/help/api_specification.html#get-status-service

        :returns: the last updated data
        :rtype: dict
        """
        # TODO: extend this, you can do history searches and all sorts with this endpoint

        params = {}
        if self.donation_made:
            params["ext"] = 1
            params["sid"] = self.systemid
        url, method = utils.URLS["getstatus"]
        response = self._call(endpoint=url, params=params, method=method)
        response.raise_for_status()
        # grab all the things
        responsedata, extras = utils.responsedata_to_response(response.text.split(","))

        # if we're fancy, we get more data
        if extras:
            for i in range(1, 7):
                responsedata[f"v{i+6}"] = (
                    None if extras[i - 1] == "NaN" else float(extras[i - 1])
                )
        return responsedata

    def register_notification(
        self, appid: str, url: str, alerttype: int
    ) -> requests.Response:
        """The Register Notification Service allows a third party application
        to receive PVOutput alert callbacks via a HTTP end point.

        API spec: https://pvoutput.org/help/api_specification.html#register-notification-service

        All parameters are mandatory

        :param appid: Application ID (eg: example.app.id)
        :type appid: str (maxlen: 100)

        :param url: Callback URL (eg: http://example.com/api/)
        :type url: str (maxlen: 150)

        :param alerttype: Alert Type (See list below)
        :type alerttype: int

        :return: The response object
        :rtype: requests.Response

        Alert Type list:

        =====   ====
        Value   Type
        =====   ====
        0       All Notifications
        1       Private Message
        3       Joined Team
        4       Added Favourite
        5       High Consumption Alert
        6       System Idle Alert
        8       Low Generation Alert
        11      Performance Alert
        14      Standby Cost Alert
        15      Extended Data V7 Alert
        16      Extended Data V8 Alert
        17      Extended Data V9 Alert
        18      Extended Data V10 Alert
        19      Extended Data V11 Alert
        20      Extended Data V12 Alert
        23      High Net Power Alert
        24      Low Net Power Alert
        =====   ====
        """

        self.validate_data(
            {
                "appid": appid,
                "url": url,
                "alerttype": alerttype,
            },
            REGISTER_NOTIFICATION_PARAMETERS,
        )

        call_url, method = utils.URLS["registernotification"]
        params = {"appid": appid, "type": alerttype, "url": url}
        return self._call(endpoint=call_url, params=params, method=method)

    def deregister_notification(self, appid: str, alerttype: int) -> requests.Response:
        """The Deregister Notification Service removes registered notifications under an application id for a system.

        API spec: https://pvoutput.org/help/api_specification.html#deregister-notification-service

        All parameters are mandatory

        :param appid: Application ID (eg: example.app.id)
        :type appid: str (maxlen: 100)

        :param alerttype: Alert Type (See list below)
        :type alerttype: int

        :return: The response object
        :rtype: requests.Response

        Alert Type list:

        =====   ====
        Value   Type
        =====   ====
        0       All Notifications
        1       Private Message
        3       Joined Team
        4       Added Favourite
        5       High Consumption Alert
        6       System Idle Alert
        8       Low Generation Alert
        11      Performance Alert
        14      Standby Cost Alert
        15      Extended Data V7 Alert
        16      Extended Data V8 Alert
        17      Extended Data V9 Alert
        18      Extended Data V10 Alert
        19      Extended Data V11 Alert
        20      Extended Data V12 Alert
        23      High Net Power Alert
        24      Low Net Power Alert
        =====   ====
        """

        self.validate_data(
            {
                "appid": appid,
                "alerttype": alerttype,
            },
            DELETE_NOTIFICATION_PARAMETERS,
        )

        url, method = utils.URLS["deregisternotification"]
        params = {"appid": appid, "type": alerttype}
        return self._call(endpoint=url, params=params, method=method)

__init__(apikey, systemid, donation_made=False, stats_period=5, session=None)

Setup code :param apikey: API key (read or write) :type apikey: str :param systemid: system ID :type systemid: int :param donation_made: Whether to use the donation-required fields :type donation_made: bool

Source code in pvoutput/__init__.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def __init__(
    self,
    apikey: str,
    systemid: int,
    donation_made: bool = False,
    stats_period: int = 5,
    session: Optional[requests.Session] = None,
):
    """Setup code
    :param apikey: API key (read or write)
    :type apikey: str
    :param systemid: system ID
    :type systemid: int
    :param donation_made: Whether to use the donation-required fields
    :type donation_made: bool
    """
    super().__init__(
        apikey=apikey,
        systemid=systemid,
        donation_made=donation_made,
        stats_period=stats_period,
    )
    self.session = session
    if session is None:
        self.session = requests.Session()

addbatchstatus(data, c1=False, n=False)

Add Batch Status Service

The Add Batch Status service adds up to 30 statuses in a single request. See the documentation on the page for what it means, and what it responds with. This hasn't been tested. https://pvoutput.org/help/api_specification.html#add-batch-status-service

Data Structure

The data parameter consists of up to 30 statuses, each status contains multiple fields.

Field Delimiter - , Output Delimiter - ;

Example data

Send three statuses from 10:00AM to 10:10AM in a single batch request

data="20110112,10:00,705,1029;20110112,10:05,775,1320;20110112,10:10,800,800"

Donation features
  • The d date parameter must be not be older than 90 days from the current date.
  • Extended parameters v7, v8, v9, v10, v11 and v12
  • Maximum energy consumption v3 value increased to 9,999,999Wh
  • Maximum power consumption v4 value increased to 2,000,000W
  • Increased batch status size to 100 from 30
Source code in pvoutput/__init__.py
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
def addbatchstatus(
    self, data: str, c1: bool = False, n: bool = False
) -> requests.Response:
    """
    # Add Batch Status Service

    The Add Batch Status service adds up to 30 statuses in a single request.
    See the documentation on the page for what it means, and what it responds with.
    This hasn't been tested.
    <https://pvoutput.org/help/api_specification.html#add-batch-status-service>

    ## Data Structure

    The data parameter consists of up to 30 statuses, each status contains multiple fields.

    Field Delimiter - ,
    Output Delimiter - ;

    ## Example data

    Send three statuses from 10:00AM to 10:10AM in a single batch request

    `data="20110112,10:00,705,1029;20110112,10:05,775,1320;20110112,10:10,800,800"`

    ## Donation features

    * The d date parameter must be not be older than 90 days from the current date.
    * Extended parameters v7, v8, v9, v10, v11 and v12
    * Maximum energy consumption v3 value increased to 9,999,999Wh
    * Maximum power consumption v4 value increased to 2,000,000W
    * Increased batch status size to 100 from 30
    """
    payload = {
        "data": data,
    }
    if c1:
        payload["c1"] = "1"
    if n:
        payload["n"] = "1"

    url, method = utils.URLS["addbatchstatus"]
    self.validate_data(payload, ADDBATCHSTATUS_PARAMETERS)
    url, method = utils.URLS["addstatus"]
    return self._call(endpoint=url, data=payload, method=method)

addoutput(data)

The Add Output service uploads end of day output information. It allows all of the information provided on the Add Output page to be uploaded.

API Spec: https://pvoutput.org/help/api_specification.html#add-output-service

:param data: The output data to upload :type data: dict

:returns: The response object :rtype: requests.Response

Source code in pvoutput/__init__.py
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
def addoutput(
    self,
    data: Dict[str, Any],
) -> requests.Response:
    """The Add Output service uploads end of day output information.
    It allows all of the information provided on the Add Output page to be uploaded.

    API Spec: https://pvoutput.org/help/api_specification.html#add-output-service

    :param data: The output data to upload
    :type data: dict

    :returns: The response object
    :rtype: requests.Response
    """
    self.validate_data(data, ADDOUTPUT_PARAMETERS)
    url, method = utils.URLS["addoutput"]
    return self._call(endpoint=url, data=data, method=method)

addstatus(data)

The Add Status service accepts live output data at the Status Interval (5 to 15 minutes) configured for the system.

API Spec: https://pvoutput.org/help/api_specification.html#add-status-service

:param data: The status data :type data: dict

:returns: The response object :rtype: requests.Response

Source code in pvoutput/__init__.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
def addstatus(
    self,
    data: Dict[str, Any],
) -> requests.Response:
    """The Add Status service accepts live output data
    at the Status Interval (5 to 15 minutes) configured for the system.

    API Spec: https://pvoutput.org/help/api_specification.html#add-status-service

    :param data: The status data
    :type data: dict

    :returns: The response object
    :rtype: requests.Response
    """
    # if you don't set a time, set it to now
    # can't push this through the validator as it relies on the class config
    if "t" not in data:
        data["t"] = self.get_time_by_base()
    self.validate_data(data, ADDSTATUS_PARAMETERS)

    url, method = utils.URLS["addstatus"]

    return self._call(endpoint=url, data=data, method=method)

check_rate_limit()

Makes a call to the site, checking if you have hit the rate limit.

API spec: https://pvoutput.org/help/api_specification.html#rate-limits

:returns: the headers relating to the rate limit. :rtype: dict

Source code in pvoutput/__init__.py
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
def check_rate_limit(self) -> Dict[str, str]:
    """Makes a call to the site, checking if you have hit the rate limit.

    API spec: https://pvoutput.org/help/api_specification.html#rate-limits

    :returns: the headers relating to the rate limit.
    :rtype: dict
    """
    headers = self._headers()
    headers["X-Rate-Limit"] = "1"

    url, method = utils.URLS["getsystem"]

    response = self._call(endpoint=url, params={}, headers=headers, method=method)
    retval = utils.get_rate_limit_header(response)
    return retval

delete_status(date_val, time_val=None)

Deletes a given status, based on the provided parameters needs a datetime() object set the hours/minutes to non-zero to delete a specific time

API spec: https://pvoutput.org/help/api_specification.html#delete-status-service

:param date_val: The date to delete. :type date_val: datetime.datetime.date

:param time_val: The time entry to delete. :type time_val: datetime.datetime.time

:returns: The response object :rtype: requests.Response

Source code in pvoutput/__init__.py
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
def delete_status(
    self, date_val: datetime.date, time_val: Optional[datetime.time] = None
) -> requests.Response:
    """
    Deletes a given status, based on the provided parameters
    needs a datetime() object
    set the hours/minutes to non-zero to delete a specific time

    API spec: https://pvoutput.org/help/api_specification.html#delete-status-service

    :param date_val: The date to delete.
    :type date_val: datetime.datetime.date

    :param time_val: The time entry to delete.
    :type time_val: datetime.datetime.time

    :returns: The response object
    :rtype: requests.Response
    """
    self.validate_data(
        {
            "date_val": date_val,
            "time_val": time_val,
        },
        DELETESTATUS_PARAMETERS,
    )

    data = {"d": date_val.strftime("%Y%m%d")}
    if time_val is not None:
        data["t"] = time_val.strftime("%H:%M")

    url, method = utils.URLS["deletestatus"]

    return self._call(endpoint=url, data=data, method=method)

deregister_notification(appid, alerttype)

The Deregister Notification Service removes registered notifications under an application id for a system.

API spec: https://pvoutput.org/help/api_specification.html#deregister-notification-service

All parameters are mandatory

:param appid: Application ID (eg: example.app.id) :type appid: str (maxlen: 100)

:param alerttype: Alert Type (See list below) :type alerttype: int

:return: The response object :rtype: requests.Response

Alert Type list:

===== ==== Value Type ===== ==== 0 All Notifications 1 Private Message 3 Joined Team 4 Added Favourite 5 High Consumption Alert 6 System Idle Alert 8 Low Generation Alert 11 Performance Alert 14 Standby Cost Alert 15 Extended Data V7 Alert 16 Extended Data V8 Alert 17 Extended Data V9 Alert 18 Extended Data V10 Alert 19 Extended Data V11 Alert 20 Extended Data V12 Alert 23 High Net Power Alert 24 Low Net Power Alert ===== ====

Source code in pvoutput/__init__.py
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
def deregister_notification(self, appid: str, alerttype: int) -> requests.Response:
    """The Deregister Notification Service removes registered notifications under an application id for a system.

    API spec: https://pvoutput.org/help/api_specification.html#deregister-notification-service

    All parameters are mandatory

    :param appid: Application ID (eg: example.app.id)
    :type appid: str (maxlen: 100)

    :param alerttype: Alert Type (See list below)
    :type alerttype: int

    :return: The response object
    :rtype: requests.Response

    Alert Type list:

    =====   ====
    Value   Type
    =====   ====
    0       All Notifications
    1       Private Message
    3       Joined Team
    4       Added Favourite
    5       High Consumption Alert
    6       System Idle Alert
    8       Low Generation Alert
    11      Performance Alert
    14      Standby Cost Alert
    15      Extended Data V7 Alert
    16      Extended Data V8 Alert
    17      Extended Data V9 Alert
    18      Extended Data V10 Alert
    19      Extended Data V11 Alert
    20      Extended Data V12 Alert
    23      High Net Power Alert
    24      Low Net Power Alert
    =====   ====
    """

    self.validate_data(
        {
            "appid": appid,
            "alerttype": alerttype,
        },
        DELETE_NOTIFICATION_PARAMETERS,
    )

    url, method = utils.URLS["deregisternotification"]
    params = {"appid": appid, "type": alerttype}
    return self._call(endpoint=url, params=params, method=method)

getstatus()

The Get Status service retrieves system status information and live output data.

API spec: https://pvoutput.org/help/api_specification.html#get-status-service

:returns: the last updated data :rtype: dict

Source code in pvoutput/__init__.py
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
def getstatus(self) -> Dict[str, Any]:
    """The Get Status service retrieves system status information and live output data.

    API spec: https://pvoutput.org/help/api_specification.html#get-status-service

    :returns: the last updated data
    :rtype: dict
    """
    # TODO: extend this, you can do history searches and all sorts with this endpoint

    params = {}
    if self.donation_made:
        params["ext"] = 1
        params["sid"] = self.systemid
    url, method = utils.URLS["getstatus"]
    response = self._call(endpoint=url, params=params, method=method)
    response.raise_for_status()
    # grab all the things
    responsedata, extras = utils.responsedata_to_response(response.text.split(","))

    # if we're fancy, we get more data
    if extras:
        for i in range(1, 7):
            responsedata[f"v{i+6}"] = (
                None if extras[i - 1] == "NaN" else float(extras[i - 1])
            )
    return responsedata

register_notification(appid, url, alerttype)

The Register Notification Service allows a third party application to receive PVOutput alert callbacks via a HTTP end point.

API spec: https://pvoutput.org/help/api_specification.html#register-notification-service

All parameters are mandatory

:param appid: Application ID (eg: example.app.id) :type appid: str (maxlen: 100)

:param url: Callback URL (eg: http://example.com/api/) :type url: str (maxlen: 150)

:param alerttype: Alert Type (See list below) :type alerttype: int

:return: The response object :rtype: requests.Response

Alert Type list:

===== ==== Value Type ===== ==== 0 All Notifications 1 Private Message 3 Joined Team 4 Added Favourite 5 High Consumption Alert 6 System Idle Alert 8 Low Generation Alert 11 Performance Alert 14 Standby Cost Alert 15 Extended Data V7 Alert 16 Extended Data V8 Alert 17 Extended Data V9 Alert 18 Extended Data V10 Alert 19 Extended Data V11 Alert 20 Extended Data V12 Alert 23 High Net Power Alert 24 Low Net Power Alert ===== ====

Source code in pvoutput/__init__.py
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
def register_notification(
    self, appid: str, url: str, alerttype: int
) -> requests.Response:
    """The Register Notification Service allows a third party application
    to receive PVOutput alert callbacks via a HTTP end point.

    API spec: https://pvoutput.org/help/api_specification.html#register-notification-service

    All parameters are mandatory

    :param appid: Application ID (eg: example.app.id)
    :type appid: str (maxlen: 100)

    :param url: Callback URL (eg: http://example.com/api/)
    :type url: str (maxlen: 150)

    :param alerttype: Alert Type (See list below)
    :type alerttype: int

    :return: The response object
    :rtype: requests.Response

    Alert Type list:

    =====   ====
    Value   Type
    =====   ====
    0       All Notifications
    1       Private Message
    3       Joined Team
    4       Added Favourite
    5       High Consumption Alert
    6       System Idle Alert
    8       Low Generation Alert
    11      Performance Alert
    14      Standby Cost Alert
    15      Extended Data V7 Alert
    16      Extended Data V8 Alert
    17      Extended Data V9 Alert
    18      Extended Data V10 Alert
    19      Extended Data V11 Alert
    20      Extended Data V12 Alert
    23      High Net Power Alert
    24      Low Net Power Alert
    =====   ====
    """

    self.validate_data(
        {
            "appid": appid,
            "url": url,
            "alerttype": alerttype,
        },
        REGISTER_NOTIFICATION_PARAMETERS,
    )

    call_url, method = utils.URLS["registernotification"]
    params = {"appid": appid, "type": alerttype, "url": url}
    return self._call(endpoint=call_url, params=params, method=method)