Emulated Belkin WeMo devices that work with the Amazon Echo
Python 3 module that emulates Belkin WeMo devices for use with the Amazon Echo.
Originally forked from https://github.com/makermusings/fauxmo, unforked to enable GitHub code search (which currently doesn’t work in a fork), and because the libraries have diverged substantially.
The Amazon Echo is able to control certain types of home automation devices by voice. Fauxmo provides emulated Belkin Wemo devices that the Echo can turn on and off by voice, locally, and with minimal lag time. Currently these Fauxmo devices can be configured to make requests to an HTTP server or to a Home Assistant instance via its Python API and only require a JSON config file for setup.
As of version v0.4.0, Fauxmo uses several API features and f-strings that require Python 3.6+. I highly recommend looking into pyenv if you’re currently on an older Python version and willing to upgrade. Otherwise, check out the FAQ section at the bottom for tips on installing an older Fauxmo version (though note that I will not be continuing development or support for older versions).
faux (\ˈfō\): imitation
WeMo: Belkin home automation product with which the Amazon Echo can interface
Fauxmo (\ˈfō-mō\): Python 3 module that emulates Belkin WeMo devices for use with the Amazon Echo.
Fauxmo has a server component that helps register “devices” with the Echo (which may be referred to as the Fauxmo server or Fauxmo core). These devices are then exposed individually, each requiring its own port, and may be referred to as a Fauxmo device or a Fauxmo instance. The Echo interacts with each Fauxmo device as if it were a separate WeMo device.
Installation into a venv is highly recommended, especially since it’s baked into the recent Python versions that Fauxmo requires.
This is a good strategy for testing features in development – for actually contributing to development, clone the repo as per below)
NB: As discussed in #20, the example files in extras/ are not included when you install from PyPI* (using pip). If you want to use them, you either need to clone the repo or you can download them individually using tools like wget or curl by navigating to the file in your web browser, clicking the Raw button, and using the resulting URL in your address bar.
* As of Fauxmo v0.4.0 extras/ has been added to MANIFEST.in and may be included somewhere depending on installation from the .tar.gz vs whl format – if you can’t find them, you should probably just get the files manually as described above.
Plugins are small user-extendible classes that allow users to easily make their own actions for Fauxmo to run by way of Alexa commands. They were previously called Handlers and may be referred to as such in places in the code and documentation.
Fauxmo v0.4.0 implements a new and breaking change in the way Handlers were implemented in previous versions, which requires modification of the config.json file (as described below).
A few plugins and the ABC from which the plugins are required to inherit are included and installed by default in the fauxmo.plugins package. The pre-installed plugins, like the rest of the core Fauxmo code, have no third party dependencies.
The pre-installed plugins include
SimpleHTTPPlugin responds to Alexa’s on and off commands by making requests to URL endpoints by way of `urllib <https://docs.python.org/3/library/urllib.html>`__. Example uses cases relevant to the IOT community might be a Flask server served from localhost that provides a nice web interface for toggling switches, whose endpoints could be added as the on_cmd and off_cmd args to a SimpleHTTPPlugin instance to allow activation by way of Alexa -> Fauxmo.
Please see details regarding SimpleHTTPPlugin configuration in the class’s docstring, which I intend to continue as a convention for Fauxmo plugins. Users hoping to make more complicated requests may be interested in looking at RESTAPIPlugin in the `fauxmo-plugins repository <https://github.com/n8henrie/fauxmo-plugins>`__, which uses Requests for a much friendlier API.
Users can easily create their own plugins, which is the motivation behind most of the changes in Fauxmo v0.4.0.
To get started:
In addition to the above, if you intend to share your plugin with others, I strongly recommend that you:
NB: You may need to manually install additional dependencies for these to work – look for the dependencies in the module level docstring.
I recommend that you copy and modify `config-sample.json <https://github.com/n8henrie/fauxmo/blob/master/config-sample.json>`__. Fauxmo will use whatever config file you specify with -c or will search for config.json in the current directory, ~/.fauxmo/, and /etc/fauxmo/ (in that order). The minimal configuration settings are:
Each user plugin should describe its required configuration in its module-level docstring. The only required config variables for all plugins is DEVICES, which is a List[dict] of configuration variables for each device of that plugin type. Under DEVICES it is a good idea to set a fixed, high, free port for each device, but if you don’t set one, Fauxmo will try to pick a reasonable port automatically (though it will change for each run).
Please see `config-sample <https://github.com/n8henrie/fauxmo/blob/master/config-sample.json>`__ for a more concrete idea of the structure of the config file, using the built-in SimpleHTTPPlugin for demonstration purposes. Below is a description of the kwargs that SimpleHTTPPlugin accepts.
Because Fauxmo v0.4.0+ loads any user plugin specified in their config, it will run untested and potentially unsafe code. If an intruder were to have write access to your config.json, they could cause you all kinds of trouble. Then again, if they already have write access to your computer, you probably have bigger problems. Consider making your config.json 0600 for your user, or perhaps 0644 root:YourFauxmoUser. Use Fauxmo at your own risk, with or without user plugins.
sudo install -o $(whoami) -g $(whoami) -d /opt/pyenv git clone https://github.com/yyuu/pyenv /opt/pyenv echo 'export PYENV_ROOT="/opt/pyenv"' >> ~/.bashrc echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init -)"' >> ~/.bashrc source ~/.bashrc pyenv install 3.6.1
You can then install Fauxmo into Python 3.6 in a few ways, including:
# Install with pip "$(pyenv root)"/versions/3.6.1/bin/python3.6 -m pip install fauxmo # Show full path to fauxmo console script pyenv which fauxmo # Run with included console script fauxmo -c /path/to/config.json -vvv # I recommend using the full path for use in start scripts (e.g. systemd, cron) "$(pyenv root)"/versions/3.6.1/bin/fauxmo -c /path/to/config.json -vvv # Alternatively, this also works (after `pip install`) "$(pyenv root)"/versions/3.6.1/bin/python3.6 -m fauxmo.cli -c config.json -vvv
Will not contain minor changes – feel free to look through git log for more detail.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|fauxmo-0.4.2-py3-none-any.whl (28.3 kB) Copy SHA256 Checksum SHA256||py3||Wheel||Jun 2, 2017|
|fauxmo-0.4.2.tar.gz (36.7 kB) Copy SHA256 Checksum SHA256||–||Source||Jun 2, 2017|