How to use the pywemo.ouimeaux_device.switch.Switch function in pywemo

To help you get started, we’ve selected a few pywemo 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 pavoni / pywemo / pywemo / ouimeaux_device / dimmer.py View on Github external
"""Representation of a WeMo Dimmer device."""
from .switch import Switch


class Dimmer(Switch):
    """Representation of a WeMo Dimmer device."""

    def __init__(self, *args, **kwargs):
        """Create a WeMo Dimmer device."""
        Switch.__init__(self, *args, **kwargs)
        self._brightness = None

    def get_brightness(self, force_update=False):
        """Get brightness from device."""
        if force_update or self._brightness is None:
            try:
                # pylint: disable=maybe-no-member
                brightness = self.basicevent.GetBinaryState().get('brightness')
            except ValueError:
                brightness = 0
            self._brightness = brightness
github pavoni / pywemo / pywemo / ouimeaux_device / maker.py View on Github external
"""Representation of a WeMo Maker device."""
from xml.etree import cElementTree as et
from .switch import Switch


class Maker(Switch):
    """Representation of a WeMo Maker device."""

    def __repr__(self):
        """Return a string representation of the device."""
        return ''.format(name=self.name)

    @property
    def maker_params(self):
        """Get and parse the device attributes."""
        # pylint: disable=maybe-no-member
        makerresp = self.deviceevent.GetAttributes().get('attributeList')
        makerresp = "" + makerresp + ""
        makerresp = makerresp.replace(">", ">")
        makerresp = makerresp.replace("<", "<")
        attributes = et.fromstring(makerresp)
        for attribute in attributes:
github pavoni / pywemo / pywemo / upnp.py View on Github external
def device_from_uuid_and_location(uuid, location):
    """ Tries to determine which device it is based on the uuid. """
    if uuid.startswith('uuid:Socket'):
        return Switch(location)
    elif uuid.startswith('uuid:Lightswitch'):
        return LightSwitch(location)
    elif uuid.startswith('uuid:Insight'):
        return Insight(location)
    elif uuid.startswith('uuid:Sensor'):
        return Motion(location)
    else:
        return None
github pavoni / pywemo / pywemo / discovery.py View on Github external
def device_from_uuid_and_location(uuid, mac, location,
                                  rediscovery_enabled=True):
    """Determine device class based on the device uuid."""
    if uuid is None:
        return None
    if uuid.startswith('uuid:Socket'):
        return Switch(url=location, mac=mac,
                      rediscovery_enabled=rediscovery_enabled)
    if uuid.startswith('uuid:Lightswitch'):
        return LightSwitch(url=location, mac=mac,
                           rediscovery_enabled=rediscovery_enabled)
    if uuid.startswith('uuid:Dimmer'):
        return Dimmer(url=location, mac=mac,
                      rediscovery_enabled=rediscovery_enabled)
    if uuid.startswith('uuid:Insight'):
        return Insight(url=location, mac=mac,
                       rediscovery_enabled=rediscovery_enabled)
    if uuid.startswith('uuid:Sensor'):
        return Motion(url=location, mac=mac,
                      rediscovery_enabled=rediscovery_enabled)
    if uuid.startswith('uuid:Maker'):
        return Maker(url=location, mac=mac,
                     rediscovery_enabled=rediscovery_enabled)
github pavoni / pywemo / pywemo / ouimeaux_device / insight.py View on Github external
"""Representation of a WeMo Insight device."""
import logging
from datetime import datetime
from .switch import Switch

LOG = logging.getLogger(__name__)


class Insight(Switch):
    """Representation of a WeMo Insight device."""

    def __init__(self, *args, **kwargs):
        """Create a WeMo Switch device."""
        Switch.__init__(self, *args, **kwargs)
        self.insight_params = {}

        self.update_insight_params()

    def __repr__(self):
        """Return a string representation of the device."""
        return ''.format(name=self.name)

    def update_insight_params(self):
        """Get and parse the device attributes."""
        # pylint: disable=maybe-no-member