How to use the pysma.SMA function in pysma

To help you get started, we’ve selected a few pysma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github home-assistant / home-assistant / homeassistant / components / sensor / sma.py View on Github external
sub_sensors = [sensor_def[s] for s in attr]
        hass_sensors.append(SMAsensor(sensor_def[name], sub_sensors))
        used_sensors.append(name)
        used_sensors.extend(attr)

    async_add_entities(hass_sensors)
    used_sensors = [sensor_def[s] for s in set(used_sensors)]

    # Init the SMA interface
    session = async_get_clientsession(hass, verify_ssl=config[CONF_VERIFY_SSL])
    grp = config[CONF_GROUP]

    url = "http{}://{}".format(
        "s" if config[CONF_SSL] else "", config[CONF_HOST])

    sma = pysma.SMA(session, url, config[CONF_PASSWORD], group=grp)

    # Ensure we logout on shutdown
    async def async_close_session(event):
        """Close the session."""
        await sma.close_session()

    hass.bus.async_listen(EVENT_HOMEASSISTANT_STOP, async_close_session)

    backoff = 0
    backoff_step = 0

    async def async_sma(event):
        """Update all the SMA sensors."""
        nonlocal backoff, backoff_step
        if backoff > 1:
            backoff -= 1
github home-assistant / home-assistant / homeassistant / components / sma / sensor.py View on Github external
if not config_sensors:  # Use all sensors by default
            config_sensors = [s.name for s in sensor_def]
        used_sensors = list(set(config_sensors + list(config[CONF_CUSTOM].keys())))
        for sensor in used_sensors:
            hass_sensors.append(SMAsensor(sensor_def[sensor], []))

    used_sensors = [sensor_def[s] for s in set(used_sensors)]
    async_add_entities(hass_sensors)

    # Init the SMA interface
    session = async_get_clientsession(hass, verify_ssl=config[CONF_VERIFY_SSL])
    grp = config[CONF_GROUP]

    url = "http{}://{}".format("s" if config[CONF_SSL] else "", config[CONF_HOST])

    sma = pysma.SMA(session, url, config[CONF_PASSWORD], group=grp)

    # Ensure we logout on shutdown
    async def async_close_session(event):
        """Close the session."""
        await sma.close_session()

    hass.bus.async_listen(EVENT_HOMEASSISTANT_STOP, async_close_session)

    backoff = 0
    backoff_step = 0

    async def async_sma(event):
        """Update all the SMA sensors."""
        nonlocal backoff, backoff_step
        if backoff > 1:
            backoff -= 1

pysma

Library to interface an SMA Solar WebConnect module

MIT
Latest version published 1 year ago

Package Health Score

53 / 100
Full package analysis

Popular pysma functions