How to use the pysma.Sensor 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 / sma / sensor.py View on Github external
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
    """Set up SMA WebConnect sensor."""

    # Check config again during load - dependency available
    config = _check_sensor_schema(config)

    # Init all default sensors
    sensor_def = pysma.Sensors()

    # Sensor from the custom config
    sensor_def.add(
        [
            pysma.Sensor(o[CONF_KEY], n, o[CONF_UNIT], o[CONF_FACTOR], o.get(CONF_PATH))
            for n, o in config[CONF_CUSTOM].items()
        ]
    )

    # Use all sensors by default
    config_sensors = config[CONF_SENSORS]
    hass_sensors = []
    used_sensors = []

    if isinstance(config_sensors, dict):  # will be remove from 0.99
        if not config_sensors:  # Use all sensors by default
            config_sensors = {s.name: [] for s in sensor_def}

        # Prepare all HASS sensor entities
        for name, attr in config_sensors.items():
            sub_sensors = [sensor_def[s] for s in attr]
github home-assistant / home-assistant / homeassistant / components / sensor / sma.py View on Github external
async def async_setup_platform(
        hass, config, async_add_entities, discovery_info=None):
    """Set up SMA WebConnect sensor."""
    import pysma

    # Check config again during load - dependency available
    config = _check_sensor_schema(config)

    # Init all default sensors
    sensor_def = pysma.Sensors()

    # Sensor from the custom config
    sensor_def.add([pysma.Sensor(o[CONF_KEY], n, o[CONF_UNIT], o[CONF_FACTOR])
                    for n, o in config[CONF_CUSTOM].items()])

    # Use all sensors by default
    config_sensors = config[CONF_SENSORS]
    if not config_sensors:
        config_sensors = {s.name: [] for s in sensor_def}

    # Prepare all HASS sensor entities
    hass_sensors = []
    used_sensors = []
    for name, attr in config_sensors.items():
        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)

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