Smart Home is a modular and extensible open-source platform for home automation. It provides an intuitive and user-friendly web interface to control and monitor various smart devices in your home.
- Intuitive Dashboard: A clean and modern web interface for managing your smart home devices.
- Modular and Extensible: Easily add new devices, protocols, and UI components (Tiles and Items).
- User Management: A robust user management system with roles and permissions.
- Real-time Communication: Uses Flask-SocketIO for real-time updates between the server and clients.
- Persistence: Everything is immediately persisted (currently opened modal, changes in configuration, ...)
- Customizable UI:
- Themes: Light, Dark, and Smart (auto-switches based on sunrise/sunset) themes.
- Backgrounds: Choose from a variety of light, dark, or random backgrounds, or set a static one. The application automatically compresses and blurs background images for a better user experience.
- Layout: Organize your devices into "Slides" (pages) and "Tiles" (widgets).
- Protocols: Supports various protocols for device communication:
- MQTT: For lightweight IoT device communication.
- Magic Packet: To wake up devices on your network.
- RTSP: For streaming video from cameras.
- Prusa: To monitor Prusa 3D printers.
- Alarm: For time-based automation.
- Security:
- Authentication: Secure login and registration system.
- Blacklist/Whitelist: Restrict access to the dashboard based on MAC addresses.
- Input Validation: Protects against common web vulnerabilities like XSS, Path Traversal, and SQL Injection.
- Android App: A native Android application for a seamless mobile experience, with the ability to control phone features like the flashlight and volume via MQTT.
- Pre-loader: A loading screen is displayed while the application is loading to prevent a jarring user experience.
- Terminal UI: A graphical terminal UI for debugging purposes.
The application defines the following user roles, each with a specific set of permissions:
- Visitor: The most basic role. Visitors can view the dashboard and control devices, but they cannot edit anything.
- Manager: Managers can do everything a Visitor can, plus they can edit the layout of the dashboard, including adding, removing, and reordering slides and tiles.
- Administrator: Administrators have all the permissions of a Manager, and they can also access the client list and blacklist/whitelist settings.
- Owner: The highest level of permission. Owners have full control over the application, including all Administrator permissions, plus the ability to manage users (add, remove, and change roles).
- Python: The core programming language.
- Flask: A lightweight web framework for the backend.
- Flask-SocketIO: For real-time communication.
- Flask-Login: For user authentication.
- SQLAlchemy: For database interactions.
- Jinja2: A templating engine for rendering dynamic HTML.
- HTML5, CSS3, JavaScript: The building blocks of the web interface.
- jQuery: For simplifying DOM manipulation and event handling.
- Bootstrap: For responsive design and UI components.
- Swiper.js: For creating swipeable "Slides".
- Sortable.js: For drag-and-drop functionality.
- Chart.js: For creating interactive charts.
- Python 3.9+
pipfor installing Python packages.
-
Clone the repository:
git clone https://github.com/TadeasFrycak/smart-home.git cd smart-home -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Run the script to install dependencies and run the app
python3 run.py
To start the application, simply run the run.py script:
python3 run.pyThe application will be accessible at http://0.0.0.0:5000 by default.
After running the script, you will see a terminal output like this:

The application is pre-configured with a default user for testing purposes.
- Username:
admin - Password:
Testamen-01
The project is organized into the following directories:
config/: Contains all configuration files for the application, items, protocols and tiles.data/: Contains the application's data, such as the database and device information.docs/: Contains documentation and images for the project.library/: Contains custom Python modules used throughout the application.static/: Contains static assets such as CSS, JavaScript, and images.templates/: Contains HTML templates for the web interface.translations/: Contains translation files for supporting multiple languages.
The application's configuration is located in the config/ directory.
Main application settings, such as database configuration, API keys, and other global settings.
[default]
registrations = true
[position]
latitude = 49.70
longitude = 17.08
[logs]
auth_priority = 1
terminal_priority = 1
changes_priority = 1
changes_edit_priority = 1
log_only = false- registrations: (true/false) Enable or disable user registrations.
- latitude/longitude: Your location for accurate sunrise/sunset times (used for the "Smart" theme).
- auth_priority, terminal_priority, changes_priority, changes_edit_priority: Logging levels for different parts of the application.
- log_only: (true/false) If true, the terminal UI will not be displayed, and all output will be directed to log files.
This file contains Flask-specific configuration. For example:
class DevelopmentConfig(Config):
DEBUG = True
SECRET_KEY = "123"
HOST = "0.0.0.0"
PORT = 5000- DEBUG: (True/False) Enables or disables debug mode.
- SECRET_KEY: A secret key for signing session cookies.
- HOST: The host interface to bind to.
- PORT: The port to listen on.
These files are used to control access to the application based on MAC addresses.
blacklist.ini
[blacklist]
aa:bb:cc:dd:ee:ffwhitelist.ini
[whitelist]
11:22:33:44:55:66These directories contain configuration files for each type of item, protocol, and tile. More on that later.
The application supports multiple languages using Flask-Babel. The supported languages are automatically detected from the user's browser settings.
Currently supported languages:
- English
- Czech
-
Mark strings for translation:
In Python files, use
gettext()or_():from flask_babel import gettext as _ my_string = _("This is a translatable string.")
In Jinja2 templates, use
_():<p>{{ _("This is a translatable string.") }}</p>
-
Extract strings:
Run the following command to extract all marked strings into a
.potfile:pybabel extract -F config/babel.ini -o messages.pot . -
Create or update translation files:
To add a new language, run:
pybabel init -i messages.pot -d translations -l <language_code>
(e.g.,
pybabel init -i messages.pot -d translations -l esfor Spanish)To update existing translations, run:
pybabel update -i messages.pot -d translations
-
Translate the strings:
Edit the
.pofile for the desired language in thetranslationsdirectory (e.g.,translations/es/LC_MESSAGES/messages.po). -
Compile the translations:
pybabel compile -d translations
This section provides a detailed overview of all available Tiles, Items, and Protocols.
Tiles are the main widgets on the dashboard.
Items are the controls and information displayed within a tile's modal.
Protocols define how the Smart Home application communicates with devices.
| Image | Name | Description |
|---|---|---|
![]() |
MQTT | For lightweight IoT device communication. |
![]() |
Magic Packet | To wake up devices on your network. |
![]() |
RTSP | For streaming video from cameras. |
![]() |
Alarm | For time-based automation. |
The Smart Home platform is designed to be modular and extensible. You can add new tiles, items, and protocols to support new devices and functionalities.
Here is a quick-start for adding new tiles. For more implementation details look into the code of already existing ones.
-
Create the Tile Class (
config/tiles/my_tile.py):from flask_babel import gettext from config.tiles.default import Tile class MyTile(Tile): TYPE = "my_tile" VISIBLE = True NAME = gettext("My Tile") PROTOCOLS_ABLE = ["mqtt"] VALUE = "Initial Value" @property def config(self): return { self._ICON: "default_icon.png" } @property def edit_config(self): from config.items.icon_picker import IconPicker return { self._ICON: IconPicker().make_object(value=self.config[self._ICON], label=gettext("Tile Icon")) }
-
Create the HTML Template (
templates/tiles/my_tile.html):<div class="tile" data-id="{{ id }}" data-type="{{ type }}"> <div class="name">{{ config.name }}</div> <div class="value">{{ value }}</div> </div>
-
Create the JavaScript File (
static/js/tiles/my_tile.js):function my_tile(tile) { // This function is called when the tile is loaded or updated. // 'tile' is a jQuery object representing the tile's div. console.log("MyTile loaded:", tile.data("id")); }
-
Register the Tile (
config/tiles/general.py):from config.tiles.my_tile import MyTile # ... other imports class Tiles: INSTANCES = [ MyTile(), # ... other tiles ] # ...
Here is a quick-start for adding new items. For more implementation details look into the code of already existing ones.
-
Create the Item Class (
config/items/my_item.py):from flask_babel import gettext from config.items.default import Item class MyItem(Item): TYPE = "my_item" VISIBLE = True NAME = gettext("My Item") PROTOCOLS_ABLE = ["mqtt"] VALUE = "Initial Item Value" @property def config(self): return { self._LABEL: self.NAME } @property def edit_config(self): from config.items.input import Input return { self._LABEL: Input().make_object(value=self.config[self._LABEL], label=gettext("Label")) }
-
Create the HTML Template (
templates/items/my_item.html):<div class="item" data-id="{{ id }}" data-type="{{ type }}"> <div class="label">{{ config.label }}</div> <div class="value">{{ value }}</div> </div>
-
Create the JavaScript File (
static/js/items/my_item.js):function my_item(item) { // This function is called when the item is loaded or updated. // 'item' is a jQuery object representing the item's div. console.log("MyItem loaded:", item.data("id")); }
-
Register the Item (
config/items/general.py):from config.items.my_item import MyItem # ... other imports class Items: INSTANCES = [ MyItem(), # ... other items ] # ...
Here is a quick-start for adding new protocols. For more implementation details look into the code of already existing ones.
-
Create the Protocol Class (
config/protocols/my_protocol.py):from config.protocols.default import Protocol from flask_babel import gettext class MyProtocol(Protocol): TYPE = "my_protocol" VISIBLE = True NAME = gettext("My Protocol") def __init__(self, terminal, update): super().__init__(terminal, update) def config(self): return { "host": "localhost" } def edit_config(self): from config.items.input import Input return { "host": Input().make_object(value=self.config()["host"], label=gettext("Host")) } def publish(self, config, value): self._terminal.protocol(self.TYPE, f"Publishing '{value}' to {config['host']}") def add_listener_inner(self, config): self._terminal.protocol(self.TYPE, f"Listening on {config['host']}")
-
Register the Protocol (
config/protocols/general.py):from config.protocols.my_protocol import MyProtocol # ... other imports class Protocols: def __init__(self, terminal, updater, fmng, tmng_r): # ... self.__instances = [ MyProtocol(terminal, self), # ... other protocols ] # ...
Login |
Register |
The main dashboard consists of "Slides" which are pages that can be swiped through. Each slide contains "Tiles" which represent devices.
Modal (Light) |
Modal (Dark) |
The edit mode allows you to add, remove, and reorder slides and tiles.
Long-pressing a tile opens a modal with more detailed information and controls, which are called "Items".
Modal Edit (Light) |
Modal Edit (Dark) |
The settings modal allows you to customize the theme, background, and other user-specific settings.
The application provides lists of registered users and active clients.
The application can integrate with Hikvision cameras for live streaming and motion detection.
The application can integrate with Doorbird video doorbells for live view, opening doors, and motion detection.
Contributions are welcome! Please feel free to submit a pull request or open an issue.
The authors' code is licensed under the MIT License.
































