Switchboard: Distributed Automation made Easy

A small Python framework for the tinkerer to make distributed automation as simple as possible

Similar projects worth following
IoT automation is conceptually simple: when (a) happens do (b) and wait 3 seconds before also doing (c). But what if (a) comes from a Raspberry Pi, (b) is a desktop computer and (c) an ESP8266 WiFi module? Who should be in charge of controlling this functionality? What should we do if WiFi becomes temporarily unavailable?

These are a few of the many hard questions I had to ask myself when deciding how to connect my devices together in a meaningful way. To this end I've been slowly piecing together a Python framework called Switchboard which takes care of device connectivity, availability, is easy to write logic for and is dynamically configurable through a command line interface.


With existing offerings such as openHAB, Home Assistant and Vera, do we need yet another automation hub/framework/solution? Depends on your needs. Switchboard has a combination of features that make it unique and very powerful if all you want to do is to automate and not just remote control your devices on a local network:

  • Low-key solution that is small, simple and extremely easy to setup and configure
  • Fine-grain control over devices
  • All the data stays on your local network (unless you serve it to the outside world)
  • No reliance on a stable internet connection (I live in Australia)
  • Perfect for the tinkerer: easy to create and debug your devices
  • No complex rules that are hard to configure. Just inputs, outputs, and the full power of the Python programming language to do whatever you want
  • Automate pretty much anything, not just your home

Downsides: at this early stage there aren't 1000 libraries to connect to a 1000 commercially available devices, a mobile app etc. (yet), A certain amount of programming skill is required.

Technical Details

Switchboard functionality and features:

  • the Switchboard framework runs on a base station (x86 computer or Raspberry Pi)
  • polls Switchboard clients via a simple HTTP REST Api
  • input and output devices can be directly read from and written to by a Switchboard module, which is effectively a function with a decorator
  • writing a Switchboard module is DEAD EASY: 1) specify a decorator with the desired inputs and outputs, 2) specify arguments to match the inputs and the outputs and 3) write your logic, knowing that all the connectivity is taken care of
  • Python and C++ ESP8266 Switchboard client libraries (maybe also Arduino with an Ethershield if I get round to it)
  • resilient to network outage (outputs are set to given 'error state' value)
  • easy to use command line prompt for dynamic Switchboard configuration: adding, updating or removing a piece of functionality is performed without affecting unrelated devices and modules

Switchboard Modules

Switchboard modules are evaluated/executed at every cycle (set by the polling period) unless one of the module IOs reports an error. In case of error, all the outputs are set to their error state as specified in the module decorator. An output signal can only be driven by one single module. In order to keep the modules self-contained decorators can specify static variables.

Or, in FPGA jargon: a Switchboard module is much like a synchronous HW entity on an FPGA, where the clock is defined by the polling period and the static variables act as the registers.

  • We have an example!

    josefschneider3 days ago 0 comments

    I managed to fix a bunch of bugs to do with functionality I hadn't run in a while, and have also added a simple example showing the absolute minimum required to get a Switchboard setup working. The example files consist of an input client, an output client, a test module that simply multiplies the input, and a settings file so that everything is ready to go.

    The one things missing here is a list of commands (which I shall be adding to the readme shortly), but the command line interface comes with '-help' functionality and tab-completion and is rather simple.

    Next steps:

    • creating a functional HTML dashboard
    • creating a video of the whole thing in action
    • adding features and unit tests

  • Publishing the Code

    josefschneider6 days ago 0 comments

    I finally got round to uploading the source files to Github. I ran the Switchboard application using python3 on a Linux machine and everything worked as expected. Not fully tested at this stage, so I wouldn't be surprised if some of the more fancy features (e.g., on-the-fly module update) would cause the application to crash.

    So far we have the main repository which contains the framework complete with command line interface, and a switchboard client module to easily instantiate switchboard hosts.

    The repository contains a C++ library that turns an ESP8266 into a Switchboard client using the ESP8266WebServer and ArduinoJson libraries.

    Next steps:

    • adding example code to the repository
    • adding a short tutorial to the readme files
    • creating a video of the whole thing in action
    • adding features and unit tests

View all 2 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates