Lightweight Python module to discover and control WeMo devices
Project description
Python 3 module to setup, discover and control WeMo devices.
How to use
>>> import pywemo
>>> devices = pywemo.discover_devices()
>>> print(devices)
[<WeMo Insight "AC Insight">]
>>> devices[0].toggle()
For advanced usage, the device.explain() method will print all known actions that the device reports to PyWeMo.
If discovery doesn’t work on your network
Automatic discovery may not work reliably on some networks. In that case, you can use the device with an IP or hostname:
>>> import pywemo
>>> url = pywemo.setup_url_for_address("192.168.1.192")
>>> print(url)
http://192.168.1.192:49153/setup.xml
>>> device = pywemo.discovery.device_from_description(url)
>>> print(device)
<WeMo Maker "Hi Fi Systemline Sensor">
Please note that discovery.device_from_description requires a url with an IP address, rather than a hostname. This is needed for the subscription update logic to work properly. In addition, recent versions of the WeMo firmware may not accept connections from hostnames and will return a 500 error.
The setup_url_for_address function will lookup a hostname and provide a suitable url with an IP address.
If the WeMo device is not on your network, you can also connect to it directly. After connecting, if the pywemo.discover_devices() doesn’t work, you can get the IP Address by running an arp -a and use that in pywemo.setup_url_for_address:
$ arp -a
_gateway (10.22.22.1) at [MAC ADDRESS REMOVED] [ether]
>>> import pywemo
>>> url = pywemo.setup_url_for_address("10.22.22.1")
>>> device = pywemo.discovery.device_from_description(url)
>>> print(device)
<WeMo Switch "Wemo Mini">
>>> device.setup(ssid='MY SSID', password='MY NETWORK PASSWORD')
('1', 'success')
Unknown Products
If both methods above are not successful, then pywemo may not support your WeMo product yet. To test this, you can use a debug flag, pywemo.discover_devices(debug=True) or pywemo.discovery.device_from_description(url, debug=True). If an UnsupportedDevice is found, then it is highly likely that the product can be added to pywemo. This UnsupportedDevice will allow manual interaction, but please open an issue to get first class support for the device.
Device Reset and Setup
PyWeMo includes the ability to reset and setup devices, without using the Belkin app or needing to create a Belkin account. This can be particularly useful if the intended use is fully local control, such as using Home Assistant. PyWeMo does not connect nor use the Belkin cloud for any functionality.
Reset
Reset can be performed with the reset method, which has 2 boolean input arguments, data and wifi. WeMo devices contain a hardware reset procedure as well, so use of pywemo is for convenience or if physical access is not available. This reset method may not work on all devices.
Method in pywemo |
Clears |
Name in WeMo App |
|---|---|---|
device.reset(data=True, wifi=False) |
name, icon, rules |
Clear Personalized Info |
device.reset(data=False, wifi=True) |
wifi information |
Change Wi-Fi |
device.reset(data=True, wifi=True) |
everything |
Factory Restore |
Setup
Device setup is through the setup method, which has two required arguments: ssid and password. The user must first connect to the devices locally broadcast access point, which typically starts with “WeMo.”, and then discover the device there. Once done, pass the desired SSID and password (WPA2/AES encryption only) to the setup method to connect it to your Wi-Fi network.
device.setup(ssid='wifi', password='secret')
A few important notes:
If connecting to an open network, the password argument is ignored and you can provide anything, e.g. password=None.
For a WeMo without internet access, see this guide to stop any blinking lights.
Setup Troubleshooting
If you have issues connecting, here are several things worth trying:
Try again! WeMo devices sometimes just fail to connect and repeating the exact same steps may subsequently work.
Bring the WeMo as close to the access point as possible. Some devices seem to require a very strong signal for setup, even if they will work normally with a weaker one.
WeMo devices can only connect to 2.4GHz Wi-Fi and sometimes have trouble connecting if the 2.4Ghz and 5Ghz SSID are the same.
If issues persist, consider performing a full factory reset and power cycle on the device before trying again.
Enabled firewall rules may block the WeMo from connecting to the intended AP.
One user indicated that switching the 2.4Ghz channel bandwidth from 40Mhz to 20Mhz (not verified, and this was regarding the Belkin app, not pywemo).
Based on various differences in models and firmware, pywemo contains 3 different methods for encrypting the Wi-Fi password when sending it to the WeMo device. In addition to the encryption, WeMo devices sometimes expect the get password lengths appended to the end of the password. There is logic in pywemo that attempts to select the appropriate options for each device, but it maybe not be correct for all devices and firmware. Thus, you may want to try forcing each of the 6 possible combinations as shown below. If one of these other methods work, but not the automatic detection, then be sure to add a comment to this pywemo issue.
device.setup(ssid='wifi', password='secret', _encrypt_method=1, _add_password_lengths=True)
device.setup(ssid='wifi', password='secret', _encrypt_method=2, _add_password_lengths=False)
device.setup(ssid='wifi', password='secret', _encrypt_method=3, _add_password_lengths=True)
# bottom three may not be valid, but try them too
device.setup(ssid='wifi', password='secret', _encrypt_method=1, _add_password_lengths=False)
device.setup(ssid='wifi', password='secret', _encrypt_method=2, _add_password_lengths=True)
device.setup(ssid='wifi', password='secret', _encrypt_method=3, _add_password_lengths=False)
Belkin Ends Support for WeMo
Belkin is officially ending WeMo support on January 31, 2026. After this date, the Belkin app will no longer work, including the required cloud access to use the current products. This likely means that you cannot use the Belkin app to connect a device to your network after this date either. See this link for more details from Belkin.
The good news is that this change will not affect pywemo, which will continue to work as it currently does; pywemo does not rely on the cloud connection for anything, including setup (connecting to a new AP). Many products can be setup and reset with pywemo, as discussed above.
Product Status
This pywemo wiki page includes a table of all known WeMo products and the status within pywemo, including whether setup (connecting to a new network) works or not.
Developing
Setup and builds are fully automated. You can run the build pipeline locally via:
# setup, install, format, lint, test and build:
./scripts/build.sh
Note that this will install a git pre-commit hook. For this hook to work correctly, poetry needs to be globally accessible on your PATH or the local virtual environment must be activated. This virtual environment can be activated with:
. .venv/bin/activate
History
This started as a stripped down version of ouimeaux, copyright Ian McCracken, but has since taken its own path.
License
All contents of the pywemo/ouimeaux_device directory are licensed under a BSD 3-Clause license. The full text of that license is maintained within the pywemo/ouimeaux_device/LICENSE file. The rest of pyWeMo is released under the MIT license. See the top-level LICENSE file for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pywemo-2.1.1.tar.gz.
File metadata
- Download URL: pywemo-2.1.1.tar.gz
- Upload date:
- Size: 91.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6621386156e99531b358e75d8fd0c60c7d02dbd54f68b3276a7031ffa41d83b
|
|
| MD5 |
899a1c091c58727a82d7edb60dc6df01
|
|
| BLAKE2b-256 |
415761e84f7b3551542450529e839166ce49e3d1736d9f9f837cd77c5bfdc9bd
|
Provenance
The following attestation bundles were made for pywemo-2.1.1.tar.gz:
Publisher:
publish.yml on pywemo/pywemo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywemo-2.1.1.tar.gz -
Subject digest:
a6621386156e99531b358e75d8fd0c60c7d02dbd54f68b3276a7031ffa41d83b - Sigstore transparency entry: 908614518
- Sigstore integration time:
-
Permalink:
pywemo/pywemo@cf6b5f213649cd412158f6670d2570c255f575f9 -
Branch / Tag:
refs/tags/2.1.1 - Owner: https://github.com/pywemo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cf6b5f213649cd412158f6670d2570c255f575f9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pywemo-2.1.1-py3-none-any.whl.
File metadata
- Download URL: pywemo-2.1.1-py3-none-any.whl
- Upload date:
- Size: 103.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7964b0144b583f9c791f18d04ce6306c6ae6a115a5b26c3894467ce064bccef
|
|
| MD5 |
fa839b18807ffa1891036eba80d25c6a
|
|
| BLAKE2b-256 |
33bdb4a9f76083f834a644ff29629e92c6cf15d069176c1093724ed9d929c352
|
Provenance
The following attestation bundles were made for pywemo-2.1.1-py3-none-any.whl:
Publisher:
publish.yml on pywemo/pywemo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywemo-2.1.1-py3-none-any.whl -
Subject digest:
e7964b0144b583f9c791f18d04ce6306c6ae6a115a5b26c3894467ce064bccef - Sigstore transparency entry: 908614543
- Sigstore integration time:
-
Permalink:
pywemo/pywemo@cf6b5f213649cd412158f6670d2570c255f575f9 -
Branch / Tag:
refs/tags/2.1.1 - Owner: https://github.com/pywemo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cf6b5f213649cd412158f6670d2570c255f575f9 -
Trigger Event:
release
-
Statement type: