How to use the pywemo.SubscriptionRegistry 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 tomwilkie / awesomation / src / pi / wemo.py View on Github external
def __init__(self, refresh_period, callback):
    super(Wemo, self).__init__(refresh_period)

    self._callback = callback
    self._devices = {}
    self._state_cache = {}
    self._subscriptions = pywemo.SubscriptionRegistry()
    self._subscriptions.start()
github home-assistant / home-assistant / homeassistant / components / wemo.py View on Github external
def setup(hass, config):
    """Set up for WeMo devices."""
    import pywemo

    # Keep track of WeMo devices
    devices = []

    # Keep track of WeMo device subscriptions for push updates
    global SUBSCRIPTION_REGISTRY
    SUBSCRIPTION_REGISTRY = pywemo.SubscriptionRegistry()
    SUBSCRIPTION_REGISTRY.start()

    def stop_wemo(event):
        """Shutdown Wemo subscriptions and subscription thread on exit."""
        _LOGGER.debug("Shutting down WeMo event subscriptions")
        SUBSCRIPTION_REGISTRY.stop()

    hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_wemo)

    def setup_url_for_device(device):
        """Determine setup.xml url for given device."""
        return 'http://{}:{}/setup.xml'.format(device.host, device.port)

    def setup_url_for_address(host, port):
        """Determine setup.xml url for given host and port pair."""
        if not port:
github home-assistant / home-assistant / homeassistant / components / wemo / __init__.py View on Github external
async def async_setup_entry(hass, entry):
    """Set up a wemo config entry."""

    config = hass.data[DOMAIN]

    # Keep track of WeMo devices
    devices = []

    # Keep track of WeMo device subscriptions for push updates
    global SUBSCRIPTION_REGISTRY
    SUBSCRIPTION_REGISTRY = pywemo.SubscriptionRegistry()
    await hass.async_add_executor_job(SUBSCRIPTION_REGISTRY.start)

    def stop_wemo(event):
        """Shutdown Wemo subscriptions and subscription thread on exit."""
        _LOGGER.debug("Shutting down WeMo event subscriptions")
        SUBSCRIPTION_REGISTRY.stop()

    hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_wemo)

    def setup_url_for_device(device):
        """Determine setup.xml url for given device."""
        return f"http://{device.host}:{device.port}/setup.xml"

    def setup_url_for_address(host, port):
        """Determine setup.xml url for given host and port pair."""
        if not port: