--port
Add a device to a WeMo bridge
bridge
List the friendly name, IP address and port of all WeMo devices on
a WeMo Bridge or home network
connect --ip --port --ssid --password
Connect a WeMo device to the home Wi-Fi network
get --ip --port
List devices on WeMo bridge
remove --ip --port
Remove devices from a WeMo bridge
reset --ip --port
Reset WeMos (remove and add all devices from WeMo bridge
The following WeMo general purpose commands are available. A bridge is not
required. All options listed for a command are required:
data --ip --port
Lists all of the data for a WeMo's IP Address and Port found through
discover command
discover
List the friendly name, IP address and port of all WeMo devices on
home network
ifttt --ip --port --imei
Pair with IFTTT (will ask to follow a web link and then execute
JavaScript from DevTools console), imei may be an arbitrary number
toggle --ip --port
Turn WeMo on or off
The options above are defined as:
--ip IP Address of device
--password Password for home Wi-Fi
--port Port WeMo device listens on. Usually, in the range
49151..49156. 49152 and 49153 are most common
--ssid SSID used by 802.11n home Wi-Fi
''')
else:
common = argparse.ArgumentParser(add_help = False)
common.add_argument('--ip', required = True, dest = 'host')
common.add_argument('--port', required = True, type = int)
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
# network commands
subparsers.add_parser('bridge').set_defaults(func = discover)
subparsers.add_parser('data', parents = [common]).set_defaults(func = data)
subparsers.add_parser('discover').set_defaults(func = discover)
subparsers.add_parser('toggle', parents = [common]).set_defaults(func = toggle)
# bridge commands
subparsers.add_parser('get', parents = [common]).set_defaults(func = getenddevices)
subparsers.add_parser('add', parents = [common]).set_defaults(func = addenddevices)
subparsers.add_parser('remove', parents = [common]).set_defaults(func = removeenddevices)
subparsers.add_parser('reset', parents = [common]).set_defaults(func = resetenddevices)
cmd = subparsers.add_parser('connect', parents = [common])
cmd.add_argument('--ssid', required = True)
cmd.add_argument('--password', required = True)
cmd.set_defaults(func = connecthomenetwork)
cmd = subparsers.add_parser('ifttt', parents = [common])
cmd.add_argument('--imei', required = True, type = int, dest = 'device_id')
cmd.set_defaults(func = ifttt)
args = vars(parser.parse_args())
cmd = args.pop('func')
cmd(**args)