PySMA Main Class¶
SMA WebConnect library for Python.
See: http://www.sma.de/en/products/monitoring-control/webconnect.html
Source: http://www.github.com/kellerza/pysma
- class pysma.SMA(session: aiohttp.client.ClientSession, url: str, password: Optional[str] = None, group: str = 'user', uid: Optional[str] = None)¶
Bases:
object
Class to connect to the SMA webconnect module and read parameters.
Init SMA connection.
- Parameters
session (ClientSession) – aiohttp client session
url (str) – Url or IP address of device
password (str, optional) – Password to use during login. Defaults to None.
group (str, optional) – Username to use during login. Defaults to “user”.
uid (str, optional) – uid used for data extraction. Defaults to None.
- Raises
KeyError – User was not in USERS
- async close_session() → None¶
Close the session login.
- async device_info() → dict¶
Read device info and return the results.
- Returns
dict containing serial, name, type, manufacturer and sw_version
- Return type
dict
- async get_devclass(result_body: Optional[dict] = None) → Optional[str]¶
Get the device class.
- Parameters
result_body (dict, optional) – result body to extract device class from. Defaults to None.
- Raises
KeyError – More than 1 device class key is not supported
- Returns
The device class identifier, or None if no identifier was found
- Return type
str
- async get_sensors() → pysma.sensor.Sensors¶
Get the sensors based on the device class.
- Returns
Sensors object containing Sensor objects
- Return type
- async new_session() → bool¶
Establish a new session.
- Raises
SmaAuthenticationException – Authentication failed
- Returns
authentication successful
- Return type
bool
- async read(sensors: pysma.sensor.Sensors) → bool¶
Read a set of keys.
- Parameters
sensors (Sensors) – Sensors object containing Sensor objects to read
- Returns
reading was successful
- Return type
bool
- async read_dash_logger() → dict¶
Read the dash loggers.
- Returns
Dictionary containing loggers returned by device.
- Return type
dict
- async read_logger(log_id: int, start: int, end: int) → list¶
Read a logging key and return the results.
- Parameters
log_id (int) – The ID of the log to read. totWhOut5min: 28672 totWhOutDaily: 28704 GridMsTotWhOutDaily: 28752 GridMsTotWhInDaily: 28768 ObjLogBatCha: 28816 totWhIn5min: 28736 totWhInDaily: 28768 ObjLogBatChrg: 29344 ObjLogBatDsch: 29360
start (int) – Start timestamp in seconds.
end (int) – End timestamp in seconds.
- Returns
The log entries returned by the device
- Return type
list