redbacktechpy 0.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ from .constants import (
2
+ TIMEOUT,
3
+ DEVICEINFOREFRESH,
4
+ AUTH_ERROR_CODES,
5
+ BaseUrl,
6
+ Endpoint,
7
+ InverterOperationType,
8
+ InverterModeControl,
9
+ Header,
10
+ DeviceTypes,
11
+ DeviceInfo,
12
+ )
13
+ from .redbacktech_client import (RedbackTechClient, LOGGER)
14
+ from .exceptions import (RedbackTechClientError, AuthError)
15
+ from .model import (Inverters, Batterys, DeviceInfo)
16
+ from .str_enum import StrEnum
17
+
18
+
19
+ __all__ = ['TIMEOUT','DEVICEINFOREFRESH','AUTH_ERROR_CODES','BaseUrl','Endpoint','InverterOperationType','InverterModeControl','Header','DeviceTypes','DeviceInfo']
@@ -0,0 +1,62 @@
1
+ from str_enum import StrEnum
2
+
3
+ TIMEOUT = 5 * 60
4
+ DEVICEINFOREFRESH = 30 * 60 #Number of seconds to wait before refreshing device info as it doesn't change very often
5
+
6
+ AUTH_ERROR_CODES = [
7
+ 'unauthorized_client',
8
+ 'Login session expired.',
9
+ ]
10
+
11
+ class BaseUrl(StrEnum):
12
+ API = 'https://api.redbacktech.com/'
13
+ PORTAL = 'https://portal.redbacktech.com/'
14
+
15
+ class Endpoint(StrEnum):
16
+
17
+ API_AUTH = 'Api/v2/Auth/token'
18
+ API_SITES = 'Api/v2/EnergyData'
19
+ API_NODES = 'Api/v2/EnergyData/With/Nodes'
20
+ API_STATIC = 'Api/v2/EnergyData/{self.siteId}/Static'
21
+ API_STATIC_MULTIPLE_BY_SERIAL = 'Api/v2/Configuration/Multiple/BySerialNumber/Configuration'
22
+ API_CONFIG_BY_SERIAL = 'Api/v2/Configuration/Configuration/BySerialNumber/'
23
+ API_STATIC_BY_SERIAL = 'Api/v2/EnergyData/Static/BySerialNumber/'
24
+ API_ENERGY_DYNAMIC_MULTIPLE_BY_SERIAL = 'Api/v2.21/EnergyData/Multiple/BySerialNumber/Dynamic'
25
+ API_ENERGY_DYNAMIC_BY_SERIAL = 'Api/v2.21/EnergyData/Dynamic/BySerialNumber/'
26
+ API_ENERGY_DYNAMIC_BY_SITE = 'Api/v2.21/EnergyData/{self.siteId}/Dynamic'
27
+ PORTAL_LOGIN = 'Account/Login'
28
+ PORTAL_CONFIGURE = 'productcontrol/Configure?serialNumber='
29
+ PORTAL_INVERTER_SET = 'productcontrol/Index'
30
+ PORTAL_LOGOFF = 'Account/LogOff/'
31
+ PORTAL_DETAILS = 'productcontrol/Details?serialNumber='
32
+
33
+
34
+ class InverterOperationType(StrEnum):
35
+ SET = 'Set'
36
+
37
+ class InverterModeControl(StrEnum):
38
+ AUTO = 'Auto'
39
+ CHARGE_BATTERY = 'ChargeBattery'
40
+ DISCHARGE_BATTERY = 'DischargeBattery'
41
+ IMPORT_POWER = 'ImportPower'
42
+ EXPORT_POWER = 'ExportPower'
43
+ CONSERVE = 'Conserve'
44
+
45
+ class Header(StrEnum):
46
+ ACCEPT = '*/*'
47
+ ENCODING = 'gzip, deflate'
48
+ CONTENT_TYPE = 'application/x-www-form-urlencoded; charset=UTF-8'
49
+ X_REQUESTED_WITH = 'XMLHttpRequest'
50
+ REFERER_UI = 'https://portal.redbacktech.com/ui/'
51
+
52
+ class DeviceTypes(StrEnum):
53
+ INVERTER = 'Inverter'
54
+ BATTERY = 'Battery'
55
+ METER = 'Meter'
56
+ LOAD = 'Load'
57
+
58
+ class DeviceInfo(StrEnum):
59
+ MODEL = 'model'
60
+ SW_VERSION = 'sw_version'
61
+ HW_VERSION = 'hw_version'
62
+ SERIAL_NUMBER = 'serial_number'
@@ -0,0 +1,17 @@
1
+ """Exceptions for RedbackTech"""
2
+
3
+ from typing import Any
4
+
5
+ class AuthError(Exception):
6
+ """Authentication issue from Redback api."""
7
+
8
+ def __init__(self, *args: Any) -> None:
9
+ """Initialize the exception."""
10
+ Exception.__init__(self, *args)
11
+
12
+ class RedbackTechClientError(Exception):
13
+ """Error from Redback api."""
14
+
15
+ def __init__(self, *args: Any) -> None:
16
+ """Initialize the exception."""
17
+ Exception.__init__(self, *args)
redbacktechpy/model.py ADDED
@@ -0,0 +1,42 @@
1
+ """ Data classes for Redback Tech API """
2
+ from __future__ import annotations
3
+
4
+ from dataclasses import dataclass
5
+ import datetime
6
+ from typing import Any, Optional
7
+
8
+
9
+ @dataclass
10
+ class Site:
11
+ """Dataclass for Redback Sites."""
12
+
13
+ id: str
14
+ data: dict[str, Any]
15
+ type: str
16
+
17
+ @dataclass
18
+ class Inverters:
19
+ """Dataclass for Redback Inverters."""
20
+
21
+ id: str
22
+ device_serial_number: str
23
+ data: dict[str, Any]
24
+ type: str
25
+
26
+ @dataclass
27
+ class Batterys:
28
+ """Dataclass for RedBack Batteries."""
29
+
30
+ id: str
31
+ device_serial_number: str
32
+ data: dict[str, Any]
33
+ type: str
34
+
35
+ @dataclass
36
+ class DeviceInfo:
37
+ """Dataclass for Device Info."""
38
+
39
+ id: str
40
+ device_serial_number: str
41
+ data: dict[str, Any]
42
+ type: str