Overview
Discover what makes FHEM powerful
FHEM is a GPL‑licensed, Perl‑based home‑automation server that runs continuously on any 24/7 host—be it a NAS, Raspberry Pi, or small‑form‑factor PC. It exposes a rich set of interfaces (plain TCP/IP, SSL/TCP, HTTP) and speaks dozens of protocols out‑of‑the‑box: CUL, EnOcean, Z‑Wave, ZigBee, MQTT, X10, and many more. The core concept is a *device registry* that is automatically populated when new hardware reports its data; once a device is known, FHEM can log, schedule, and trigger actions on it. This dynamic discovery eliminates manual configuration for most IoT peripherals.
Language
Runtime
Database
Modularity
Overview
FHEM is a GPL‑licensed, Perl‑based home‑automation server that runs continuously on any 24/7 host—be it a NAS, Raspberry Pi, or small‑form‑factor PC. It exposes a rich set of interfaces (plain TCP/IP, SSL/TCP, HTTP) and speaks dozens of protocols out‑of‑the‑box: CUL, EnOcean, Z‑Wave, ZigBee, MQTT, X10, and many more. The core concept is a device registry that is automatically populated when new hardware reports its data; once a device is known, FHEM can log, schedule, and trigger actions on it. This dynamic discovery eliminates manual configuration for most IoT peripherals.
Architecture & Technical Stack
- Language: Perl 5, leveraging CPAN modules for networking, JSON/XML parsing, and database access.
- Runtime: Requires a standard Perl interpreter; the codebase is fully POSIX‑compatible, making it deployable on Linux, macOS, Windows (via Cygwin), and embedded ARM devices.
- Database: Optional persistence layers include plain text log files, SQLite, MySQL/MariaDB, and PostgreSQL. The schema is lightweight—primarily time‑series tables per device type—and can be swapped at runtime.
- Modularity: The framework loads modules (
*.pmfiles) that implement protocol handlers, device abstractions, and UI components. Over 430 modules exist, each following a simpleuse/subconvention, making custom extensions straightforward. - Event Loop: A single‑threaded event loop (
FHEM::MainLoop) dispatches I/O events, timers, and inter‑module messages. It is highly efficient for thousands of simultaneous device connections, as the loop merely watches file descriptors and invokes callbacks.
Core Capabilities
- Multi‑protocol Support: Native drivers for Z‑Wave (via
zwave.pm), EnOcean, CUL, and many radio protocols. - APIs: Exposes three text‑based command interfaces (telnet, TCP, HTTP) and higher‑level JSON/XML REST endpoints. These can be consumed by external scripts or web dashboards.
- Event Handling: Users define rules (
rule X { ... }) that react to device state changes, time conditions, or external triggers. Rules are evaluated in the same event loop, guaranteeing deterministic timing. - Logging & Persistence: All device events can be written to files or a database, with optional regex filtering. Historical data is automatically plotted in the built‑in web UI or exported via CSV/JSON.
- Scheduling: The
scheduleandtimedcommands enable cron‑style automation (e.g., “turn on lamp at sunset until midnight”). - Extensibility: New modules can be added by placing a Perl file in the
modules/directory; the system reloads them on the fly. Webhooks and custom HTTP endpoints can be defined in modules to integrate with third‑party services.
Deployment & Infrastructure
- Self‑Hosting: Runs on any machine with Perl and a network interface. Recommended hosts include Raspberry Pi 4, Intel NUCs, or NAS units.
- Scalability: The single‑threaded event loop scales linearly with I/O; a typical deployment can handle hundreds of Z‑Wave devices and thousands of sensor readings without additional threads. For high‑throughput scenarios, multiple FHEM instances can be clustered behind a reverse proxy (NGINX) and share the same database.
- Containerization: Official Docker images exist, simplifying CI/CD pipelines. The container exposes the standard ports (80/443 for HTTP, 4711 for telnet/TCP) and mounts a persistent volume for configuration and logs.
- High Availability: Because the state is persisted in a database, multiple instances can run concurrently; only one instance should accept write traffic to avoid race conditions.
Integration & Extensibility
- Plugin Ecosystem: The module system allows developers to write custom device drivers or UI widgets. Popular community modules include weather APIs, calendar integrations, and media‑control protocols (e.g., UPnP/DLNA).
- Webhooks & Scripts: Rules can trigger external programs via
system,exec, or HTTP POST requests, enabling integration with Home Assistant, Node‑RED, or custom microservices. - Custom Frontends: The built‑in web UI can be overridden by custom HTML/CSS/JS dashboards that consume the JSON API.
- API Hooks: Advanced users can tap into the event dispatcher (
FHEM::Event) to create real‑time websockets or push notifications.
Developer Experience
- Configuration: The
fhem.cfgfile is a plain text script that defines devices, rules, and modules. Perl’s expressive syntax makes it easy to embed logic directly in configuration. - Documentation: The official Wiki and module documentation are comprehensive, with example snippets for each protocol. Community forums provide rapid support for edge cases.
- Community & Licensing: GPLv2 licensing ensures that any derivative work remains open source. The active mailing list and IRC channel (
#fhemon irc.libera.chat) foster rapid knowledge sharing.
Use Cases
- Home Automation Hub – Central control of Z‑Wave, EnOcean, and MQTT devices with automated scheduling.
- Energy Monitoring – Log power consumption from smart plugs and feed data into a time‑series database
Open SourceReady to get started?
Join the community and start self-hosting FHEM today
Related Apps in cloud-platforms
Home Assistant
Open-source smart home hub for automation and integration
Caddy
Secure, auto‑TLS web server for every site
Traefik
Dynamic reverse proxy and load balancer for microservices
Pi‑hole
Network‑wide ad blocking with your own DNS server
CasaOS
Your Personal Cloud OS for Docker-based home servers
AdGuard Home
Network‑wide ad and tracker blocker
Weekly Views
Repository Health
Information
Explore More Apps
Prosody IM
Fast, lightweight XMPP server for secure messaging
SeedDMS
Secure Document Management with Workflow & Notifications
Revive Adserver
Open‑source ad serving for publishers and networks
Filestash
Universal web‑based file manager for any storage
Kutt
Self‑hosted URL shortener with custom domains
CouchCMS
Turn static HTML into a dynamic CMS in minutes