-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Command-center is an application written in Python3, developed to support micro-automation of my apartment. It's designed to run on Raspberry Pi, but core application is platform agnostic, so with some changes to motors, and sensors it will work everywhere, where you can run python3. There are three terms that are crucial to application architecture, and use all over this wiki so they need to be well understood (plugins are described in detail in Architecture section):
- Sensors - plugins that feed application with details about environment. Those might be used by motors to make proper decisions. By definition, sensors actions should not have any side effects.
- Motors - plugins that execute some actions, basing on state coming from various sensors. For example, if temperature from thermometer sensor remains too high for too long, motor may turn air-conditioner on to lower it.
- Core application - main application that user launches and that takes care of orchestrating communication between sensors and motors. It provides some basic information (called virtual sensors) about runtime conditions (such as unhandled exceptions, average loop duration, total loops counter)
To run application without any plugins, necessary prerequisites are:
- Python3
- YAPSY
- PyHamcrest - it's necessary to run tests
Each plugin may introduce it's own dependencies, so please consult it's documentation about deployment and runtime dependencies.
To start using Command Center you need to complete following steps:
- Clone repository to /etc/command_center (or choose other, arbitrary path)
- Ensure all application's requirements are met
- Remove or add any plugins you want and ensure plugins dependencies and configuration is fully performed
- If you want to start Command Center via
supervisordthen copycommand_center.conffrom./supervisor/to/etc/supervisor/conf.d/ - Start application either by running
sudo python3 command_center.pyin app's directory, or by reloading supervisorsudo supervisorctl rereadsudo supervisorctl update
As mentioned above, main components of application are: sensors and motors.
Sensor - is basically anything that collects some information from environment. For instance it might be code that reads temperature from 1-wire thermometer or humidity from hygrometer. There are two types of sensors: custom and virtual. Custom sensors are pluggable via Yapsy library, and should be put in plugins/sensors directory. For details on developing your own sensor take a look at [Development](Developing custom plugins) page.
Below you will find list of all virtual sensors:
-
errors- value is list of all exceptions that occurred during current run. It's cleared every iteration. It contains tuples (plugin key, exception object) for every exception thrown. -
now- contains date time of current loop start. It's identical for every motor. -
disabled_plugins- list containing keys of all plugins that were disabled because of exceeded number of failures. -
termination- if value is notNone, means that system is about to shut down, and contains tuple in following format:If termination is user-initiated (i.e. user pressed Ctrl+C) then reason is set to: "User interruption", and terminator is set to(terminator's key, terminator's type name, reason string)None. -
runtime- is a dictionary containing technical information about application. Following keys are available:-
start_time- datetime object when application was launched -
loop_counter- counter incremented with every loop of service -
last_loop_time- duration of last iteration in seconds -
average_loop_time- average loop duration in seconds -
errors- dictionary where keys are plugin keys, and values are lists of thrown exceptions by those plugins
-
Motor - motor is a plugin, that basing on current sensors' state and own internal state, should perform some actions.
For example when temperature remains too high, air conditioner might be turned on to drop it. Motors are loaded similarly to sensors - using Yapsy, and reside in plugins/motors directory. Unlikely to sensors, there are no virtual motors.
- Home
- [Writing own plugins](Developing custom plugins)
- Built-in sensors
- Built-in motors