Introduction
Although optional, having a central coordinator (ActoSenso Server) in an automation environment can open up new possibilities. Advantages of having an ActoSenso Server include more processing power, more mass storage (for historical data), easier to develop business logic, etc.
Options for an ActoSenso Server
Almost any computer can be converted to work as an ActoSenso Server: even an old PC or laptop waiting in the attic for a comeback is sufficient for serving many-many ActoSenso Nodes. If power consumption is priority, a Raspberry Pi or any other similar credit card size computer will do. I happen to use a Raspberry Pi Model B because I am currently interested to find out its limits – both hardware and software. However, a PC running Windows or Linux will do the job just the same way, probably a lot faster. For my purposes, at least for the time being, I am sticking with a RPi. Many months in the development I changed for a RPi 3, just to see the performance difference.
Software stack
On the RPi I use the latest Raspbian as the operating system. See a previous article about how I set it up for development.
Once the OS is ready and fully updated, I installed the following software packages that now form the server side components of the ActoSenso Platform;
- Apache web server: Open source software. It serves the pages I developed for administering and managing ActoSenso Nodes as well as the the ActoSenso Server itself. link
- PHP support for the web server: I developed all the web pages running on the ActoSenso Server in PHP. link
- MySql database: Open source database. All automation configuration data, historical data and other related data are stored in a database. ActoSenso Nodes do not directly “talk” to the database. Only the ActoSenso Server has access to the database. link
- Mosquitto: Open source MQTT broker. MQTT is the communication protocol ActoSenso Nodes use to communicate with the ActoSenso Server. I have previously blogged about how to set Mosquitto up on the RPi. link
- Node-RED: Built on NodeJS Node-RED allows to create visual rules for controlling the data flow between ActoSenso Nodes and the ActoSenso Server. It’s very simple to use (or at least to get started with it) and very powerful. link
That’s it! As you can see, the minimal ActoSenso Server is not very complex. Of course, if further components are required for business logic they can add to the complexity, but overall, it is a very simple concept and easy to expand.
Installation/Migration
The server I built for the first time was not built overnight. I started from a simple Raspbian install, then I added the required components one by one as needed. This approach worked well because I could gradually learn all the new stuff (remember, I am a Linux beginner), and when something went wrong, I knew exactly what/where/when broke down.
However, when I wanted to migrate the whole setup to another RPi (now I am running the whole lot on a Rpi 3), I was faced the question: what exactly do I need to do on a new system to get to the point where the new system is on par with the original one? All components/updates installed, configured, started? Although the software stack is relatively small (but can grow in the future), there are many tiny tweaks in their configurations that needed to be done after installation. Some are needed because of some bug quirk in the component, some because of my specific needs. Also, in the future when I may want to build it for someone else, I don’t want to spend hours on installing/configuring a new system the same way every time. This screams for automation!
To address the above I put together a script that must be run in a clean install of Raspbian. The script installs, updates and upgrades all necessary components and asks for user input for some configuration details. On a new system the script takes about 2-2.5 hours to run. I guess it could be even faster if we had a faster internet access at home… Anyway, as long as I don’t have to sit in front of it during installation, I don’t really care if it’s one hour or ten. This only needs to be done once on each ActoSenso server. At a later time I will write a separate article about the installation and the script itself.
ActoSenso Dash
I also started to build a web based management console for the ActoSenso Platform. I call it (you guessed it right!) ActoSenso Dash. It is entirely written in PHP and javascript, backed by MySql.
On its homepage it provides an overview of all of the components participating in the automation system: ActoSenso Server and ActoSenso Nodes in the form of widgets. Clicking on a widget opens a more detailed page about the particular subsystem. This layout is very flexible, making it easy to create a unique experience for each automation system in a short amount of time.
There is a separate page for configuring system parameters, setting up schedules for a ActoSenso Node, if needed, and also an event viewer where all the logs from all the ActoSenso Nodes can be viewed.
This management console, at the moment, is very simple, and demonstrates what can be achieved by it. Further pages and functions can be added to it as the need arises.
In an upcoming article I will discuss some possible configurations and example nodes.