-
-
Save comiclandapp/787ba00491c66501cadff5b0c2e8a96d to your computer and use it in GitHub Desktop.
WeMo device setup script for pywemo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from getpass import getpass | |
| from pywemo import discovery | |
| from pywemo.ouimeaux_device import Device | |
| def discover() -> Device | None: | |
| for device in discovery.discover_devices(): | |
| print(device) | |
| if input("y/N? ").lower() == "y": | |
| return device | |
| return None | |
| def main() -> int: | |
| device = discover() | |
| if not device: | |
| print("No selection. Try again or pick something new.") | |
| return 1 | |
| ssid = input("SSID: ") | |
| password = getpass("Network passphrase: ") | |
| if not ssid or not password: | |
| print("Must provide SSID and passphrase") | |
| return 1 | |
| print("Setting up...") | |
| result = device.setup(ssid=ssid, password=password) | |
| if result[1] != "success": | |
| print(result) | |
| return 1 | |
| print("Success!") | |
| return 0 | |
| if __name__ == "__main__": | |
| exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment