|
| 1 | +# API Documentation |
| 2 | + |
| 3 | +For example usage and installation instructions see |
| 4 | +[README.rst](https://github.com/pywemo/pywemo/blob/main/README.rst) |
| 5 | + |
| 6 | +## General structure of the pyWeMo API |
| 7 | + |
| 8 | +### Discovery |
| 9 | + |
| 10 | +The `pywemo.discovery` module contains methods to locate WeMo devices on a |
| 11 | +network. For example, use the following to discover all devices on the |
| 12 | +network: |
| 13 | + |
| 14 | +```python |
| 15 | +>>> import pywemo |
| 16 | +>>> devices = pywemo.discover_devices() |
| 17 | +>>> print(devices) |
| 18 | +[<WeMo Insight "AC Insight">] |
| 19 | +``` |
| 20 | + |
| 21 | +Or, if you know the IP address of the device, use this example. |
| 22 | + |
| 23 | +```python |
| 24 | +>>> import pywemo |
| 25 | +>>> url = pywemo.setup_url_for_address("192.168.1.192") |
| 26 | +>>> print(url) |
| 27 | +http://192.168.1.192:49153/setup.xml |
| 28 | +>>> device = pywemo.device_from_description(url) |
| 29 | +>>> print(device) |
| 30 | +[<WeMo Insight "AC Insight">] |
| 31 | +``` |
| 32 | + |
| 33 | +### Devices |
| 34 | + |
| 35 | +The device(s) returned by the discovery methods above will be instances of one |
| 36 | +of the classes below. These classes, used for communicating with the various, |
| 37 | +WeMo devices are in submodules under the `pywemo.ouimeaux_device` module. They |
| 38 | +can also be accessed as top-level members of the pywemo module. |
| 39 | + |
| 40 | +WeMo Model|Alias / Class |
| 41 | +----------|------------- |
| 42 | + F7C031 |`pywemo.Bridge` / `pywemo.ouimeaux_device.bridge.Bridge` |
| 43 | + F7C050 |`pywemo.CoffeeMaker` / `pywemo.ouimeaux_device.coffeemaker.CoffeeMaker` |
| 44 | + F7C045 |`pywemo.CrockPot` / `pywemo.ouimeaux_device.crockpot.CrockPot` |
| 45 | + F7C059 |`pywemo.DimmerLongPress` / `pywemo.ouimeaux_device.dimmer.DimmerLongPress` |
| 46 | + WDS060 |`pywemo.DimmerV2` / `pywemo.ouimeaux_device.dimmer.DimmerV2` |
| 47 | + F7C046 |`pywemo.Humidifier` / `pywemo.ouimeaux_device.humidifier.Humidifier` |
| 48 | + F7C029 |`pywemo.Insight` / `pywemo.ouimeaux_device.insight.Insight` |
| 49 | + F7C030 |`pywemo.LightSwitchLongPress` / `pywemo.ouimeaux_device.lightswitch.LightSwitchLongPress` |
| 50 | + WLS040 |`pywemo.LightSwitchLongPress` / `pywemo.ouimeaux_device.lightswitch.LightSwitchLongPress` |
| 51 | + WLS0403 |`pywemo.LightSwitchLongPress` / `pywemo.ouimeaux_device.lightswitch.LightSwitchLongPress` |
| 52 | + F7C043 |`pywemo.Maker` / `pywemo.ouimeaux_device.maker.Maker` |
| 53 | + F7C028 |`pywemo.Motion` / `pywemo.ouimeaux_device.motion.Motion` |
| 54 | + WSP090 |`pywemo.OutdoorPlug` / `pywemo.ouimeaux_device.outdoor_plug.OutdoorPlug` |
| 55 | + F7C027 |`pywemo.Switch` / `pywemo.ouimeaux_device.switch.Switch` |
| 56 | + F7C063 |`pywemo.Switch` / `pywemo.ouimeaux_device.switch.Switch` |
| 57 | + WSP080 |`pywemo.Switch` / `pywemo.ouimeaux_device.switch.Switch` |
| 58 | + |
| 59 | +The following are base classes of all of the above device classes. |
| 60 | + |
| 61 | +* pywemo.ouimeaux_device.Device: Provides common methods for getting/setting |
| 62 | + device state. |
| 63 | +* pywemo.ouimeaux_device.api.xsd_types.DeviceDescription: Provides information |
| 64 | + about the device name, mac address, firmware version, serial number, etc. |
| 65 | + |
| 66 | +### Subscriptions |
| 67 | + |
| 68 | +Most WeMo devices support a push/callback model for reporting state changes. |
| 69 | +The `pywemo.subscribe` module provides a way to subscribe to push events. |
0 commit comments