Top Related Projects
:house_with_garden: Open source home automation that puts local control and privacy first.
Automate your life!
Open source Home Automation System
:house: My Home Assistant configuration, a bit different that others :) Be sure to :star2: this repository for updates!
Quick Overview
OpenHAB Core is the foundation of the openHAB smart home platform. It provides essential functionality and APIs for building and extending home automation systems. This repository contains the core components and libraries that power the openHAB ecosystem, enabling developers to create flexible and scalable smart home solutions.
Pros
- Highly modular and extensible architecture
- Strong community support and active development
- Platform-independent, supporting various operating systems and devices
- Integrates with a wide range of smart home protocols and devices
Cons
- Steep learning curve for beginners
- Documentation can be fragmented or outdated in some areas
- Performance can be impacted with a large number of devices or rules
- Setup and configuration can be complex for advanced scenarios
Code Examples
- Creating a simple Item:
Item lightSwitch "Living Room Light" <light> (gLivingRoom) {channel="zwave:device:controller:node2:switch_binary"}
This code defines a light switch item connected to a Z-Wave device.
- Writing a basic Rule:
rule "Turn on light at sunset"
when
Channel "astro:sun:home:set#event" triggered START
then
lightSwitch.sendCommand(ON)
end
This rule turns on the light when the sun sets.
- Defining a Sitemap:
sitemap demo label="My Home"
{
Frame label="Living Room" {
Switch item=lightSwitch label="Light"
Slider item=dimmer label="Dimmer"
}
}
This code creates a simple sitemap for controlling a light switch and dimmer.
Getting Started
To get started with openHAB Core development:
-
Clone the repository:
git clone https://github.com/openhab/openhab-core.git
-
Set up your development environment (Java 11+ and Maven required).
-
Build the project:
mvn clean install
-
Import the project into your preferred IDE.
-
Explore the codebase and start contributing to specific modules or features.
For more detailed instructions, refer to the project's Contributing Guidelines.
Competitor Comparisons
:house_with_garden: Open source home automation that puts local control and privacy first.
Pros of Home Assistant Core
- Larger and more active community, resulting in faster development and more integrations
- More user-friendly interface and easier initial setup for beginners
- Better native support for cloud services and voice assistants
Cons of Home Assistant Core
- Less flexible for advanced users who need fine-grained control
- Steeper learning curve for complex automations and custom integrations
- More resource-intensive, especially on low-power devices
Code Comparison
Home Assistant Core (Python):
class Light(ToggleEntity):
@property
def brightness(self):
"""Return the brightness of this light between 0..255."""
return self._brightness
def turn_on(self, **kwargs):
"""Turn the light on."""
self._state = True
self._brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
OpenHAB Core (Java):
public class DimmableLight extends BaseItem {
public void setBrightness(PercentType brightness) {
setState(brightness);
}
public void turnOn() {
setState(OnOffType.ON);
}
}
The code snippets show that Home Assistant uses Python with a more concise class definition, while OpenHAB uses Java with a more verbose object-oriented approach. Home Assistant's implementation includes brightness handling within the turn_on method, whereas OpenHAB separates brightness and on/off functionality.
Automate your life!
Pros of ioBroker
- More flexible and modular architecture, allowing for easier customization and extension
- Larger ecosystem of adapters and integrations, supporting a wider range of devices and services
- JavaScript-based scripting, which may be more accessible for web developers
Cons of ioBroker
- Less mature and stable compared to OpenHAB, potentially leading to more frequent updates and changes
- Documentation can be less comprehensive and sometimes only available in German
- Steeper learning curve for users without JavaScript experience
Code Comparison
OpenHAB (Java):
Thing hue:bridge:mybridge [ ipAddress="192.168.0.100" ]
Bridge hue:bridge:mybridge [ ipAddress="192.168.0.100" ] {
Thing 0210 1 [ lightId="1" ]
}
ioBroker (JavaScript):
createState('myLight', false, {
name: 'My Light',
type: 'boolean',
role: 'switch'
});
on({id: 'myLight', change: 'ne'}, function (obj) {
// Control light based on state change
});
Both OpenHAB and ioBroker are powerful home automation platforms with their own strengths. OpenHAB offers a more structured and stable environment, while ioBroker provides greater flexibility and a larger ecosystem of integrations. The choice between them often depends on the user's specific needs and technical background.
Open source Home Automation System
Pros of Domoticz
- Lightweight and efficient, suitable for low-power devices
- User-friendly web interface for easy configuration and management
- Extensive support for various hardware devices and protocols
Cons of Domoticz
- Less modular architecture compared to OpenHAB Core
- Smaller community and ecosystem of add-ons and integrations
- Limited support for advanced automation scenarios
Code Comparison
OpenHAB Core (Java):
public class MyBindingHandler extends BaseThingHandler {
public MyBindingHandler(Thing thing) {
super(thing);
}
// ...
}
Domoticz (C++):
class CMyHardware : public CDomoticzHardwareBase
{
public:
CMyHardware(const int ID);
// ...
};
Both projects use object-oriented programming, but OpenHAB Core is written in Java, while Domoticz is primarily C++. OpenHAB Core's architecture is more modular, with a focus on binding development, while Domoticz has a more monolithic structure.
OpenHAB Core offers a more flexible and extensible platform for home automation, with a larger ecosystem of add-ons and integrations. Domoticz, on the other hand, provides a more lightweight solution that can run efficiently on low-power devices and offers a user-friendly web interface for easy management.
:house: My Home Assistant configuration, a bit different that others :) Be sure to :star2: this repository for updates!
Pros of home-assistant-config
- Highly customized and well-documented Home Assistant configuration
- Extensive use of automations and scripts for advanced smart home control
- Regular updates and active community engagement
Cons of home-assistant-config
- Specific to one user's setup, may require significant adaptation for others
- Less focus on core functionality compared to openhab-core
- Limited to Home Assistant ecosystem, while openhab-core is more platform-agnostic
Code Comparison
home-assistant-config:
automation:
- alias: "Turn on lights when motion detected"
trigger:
platform: state
entity_id: binary_sensor.motion_sensor
to: 'on'
action:
service: light.turn_on
entity_id: group.living_room_lights
openhab-core:
public class MotionSensor extends BaseThingHandler {
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if (channelUID.getId().equals(CHANNEL_MOTION)) {
// Handle motion detection
}
}
}
The home-assistant-config example shows a YAML-based automation for motion-activated lighting, while the openhab-core snippet demonstrates a Java-based approach to handling sensor events. Home Assistant's configuration is more accessible to non-programmers, while OpenHAB offers more flexibility for developers.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
openHAB Core
This project contains core bundles of the openHAB runtime.
Building and running the project is fairly easy if you follow the steps detailed below.
Please note that openHAB Core is not a product itself, but a framework to build solutions on top. It is picked up by the main openHAB distribution.
This means that what you build is primarily an artifact repository of OSGi bundles that can be used within smart home products.
1. Prerequisites
The build infrastructure is based on Maven. If you know Maven already then there won't be any surprises for you. If you have not worked with Maven yet, just follow the instructions and everything will miraculously work ;-)
What you need before you start:
- Java SE Development Kit 21
- Maven 3 from https://maven.apache.org/download.html
Make sure that the mvn
command is available on your path
2. Checkout
Checkout the source code from GitHub, e.g. by running:
git clone https://github.com/openhab/openhab-core.git
3. Building with Maven
To build this project from the sources, Maven takes care of everything:
- set
MAVEN_OPTS
to-Xms512m -Xmx1024m
- change into the openhab-core directory (
cd openhab-core
) - run
mvn clean spotless:apply install
to compile and package all sources
If there are tests that are failing occasionally on your local build, run mvn -DskipTests=true clean install
instead to skip them.
For an even quicker build, run mvn clean install -T1C -DskipChecks -DskipTests -Dspotless.check.skip=true
.
How to contribute
If you want to become a contributor to the project, please read about contributing and check our guidelines first.
Top Related Projects
:house_with_garden: Open source home automation that puts local control and privacy first.
Automate your life!
Open source Home Automation System
:house: My Home Assistant configuration, a bit different that others :) Be sure to :star2: this repository for updates!
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot