# 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: ClientSession, url: str, password: str | None = None, group: str = 'user', uid: str | None = None, lang: str = 'en-US')

  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.

    - lang (str, optional) – Language code of file to retrieve. Defaults to “en-US”.

  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_sensors() → Sensors

    Get the sensors that are present on the device.

    Returns:

      Sensors object containing Sensor objects

    Return type:

      Sensors

  async new_session() → bool

    Establish a new session.

    Raises:

      SmaAuthenticationException – Authentication failed

    Returns:

      authentication successful

    Return type:

      bool

  async read(sensors: 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