This events framework is deprecated and will be removed prior to the 1.0 release. Please use the signals framework.

By default, ouimeaux subscribes to property change events on discovered
devices (this can be disabled by passing with_subscribers=False to the
Environment constructor). You can register callbacks that will be called
when switches and motions change state (on/off, or motion detected):

A simple signals framework (using pysignals) is included to replace the
rudimentary events in earlier releases. These are found in the
ouimeaux.signals module. Signal handlers may be registered using the
receiver decorator and must have the signature sender,**kwargs:

Example: Registering a handler for when a Light Switch switches on or off:

fromouimeaux.signalsimportstatechange,receiverenv=Environment();env.start()env.discover(5)switch=env.get_switch('Porch Light')@receiver(statechange,sender=switch)defswitch_toggle(device,**kwargs):printdevice,kwargs['state']env.wait()# Pass control to the event loop

Switches have three shortcut methods defined: get_state, on and
off. Switches also have a blink method, which accepts a number of
seconds. This will toggle the device, wait the number of seconds, then toggle
it again. Remember to call env.wait() to give control to the event loop.

By default, device results are cached on the filesystem for quicker
initialization. This can be disabled by passing with_cache=False to the
Environment constructor. On a related note, if you want to use the cache
exclusively, you can pass with_discovery=False to the Environment
constructor to disable M-SEARCH requests.

You can clear the device cache either by deleting the file ~/.wemo/cache
or by using the wemoclear command.