fauxmo package

Submodules

fauxmo.cli module

cli.py Argparse based CLI for fauxmo. Helps provide console_script via argparse. Also initializes logging.

fauxmo.cli.cli()[source]

Parse command line options, provide entry point for console scripts

fauxmo.fauxmo module

fauxmo.py

Emulates a Belkin Wemo for interaction with an Amazon Echo. See README.md at <https://github.com/n8henrie/fauxmo>.

fauxmo.fauxmo.main(config_path=None, verbosity=20)[source]

Runs the main fauxmo process

Spawns a UDP server to handle the Echo’s UPnP / SSDP device discovery process as well as multiple TCP servers to respond to the Echo’s device setup requests and handle its process for turning devices on and off.

Kwargs:
config_path (str): Path to config file. If not given will search for
config.json in cwd, ~/.fauxmo/, and /etc/fauxmo/.

verbosity (int): Logging verbosity, defaults to 20

fauxmo.protocols module

protocols.py

Holds asyncio protocols required classes for the Echo’s UPnP / SSDP device discovery.

class fauxmo.protocols.Fauxmo(name, action_handler)[source]

Bases: asyncio.protocols.Protocol

Mimics a WeMo switch on the network.

Aysncio protocol intended for use with BaseEventLoop.create_server.

connection_made(transport)[source]
data_received(data)[source]

Decode data and determine if it is a setup or action request

handle_action(msg)[source]

Execute on or off method of action_handler

Args:
msg (str): Body of the Echo’s HTTP request to trigger an action
handle_setup()[source]

Create a response to the Echo’s setup request

class fauxmo.protocols.SSDPServer(devices=None)[source]

Bases: asyncio.protocols.DatagramProtocol

Responds to the Echo’s SSDP / UPnP requests

add_device(name, ip_address, port)[source]
connection_lost(exc)[source]
connection_made(transport)[source]
datagram_received(data, addr)[source]

Check incoming UDP data for requests for Wemo devices

Build and send an appropriate response to an SSDP search request.

fauxmo.utils module

utils.py

Utility functions for Fauxmo.

fauxmo.utils.get_local_ip(ip_address)[source]

Attempt to get the local network-connected IP address

fauxmo.utils.make_serial(name)[source]

Create a persistent UUID from the device name

Returns a suitable UUID derived from name. Should remain static for a given name.

Args:
name (str): Friendly device name (e.g. “living room light”)

Module contents