Skip to content

Commit

Permalink
[sbus] Initial contribution (openhab#18019)
Browse files Browse the repository at this point in the history
* Initial contribution

Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
  • Loading branch information
cipianpascu authored Feb 12, 2025
1 parent ee9697b commit 2a7a76f
Show file tree
Hide file tree
Showing 25 changed files with 1,884 additions and 0 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@
/bundles/org.openhab.binding.salus/ @magx2
/bundles/org.openhab.binding.samsungtv/ @NickWaterton
/bundles/org.openhab.binding.satel/ @druciak
/bundles/org.openhab.binding.sbus/ @cipianpascu
/bundles/org.openhab.binding.semsportal/ @itb3
/bundles/org.openhab.binding.senechome/ @vctender @KorbinianP @eguib
/bundles/org.openhab.binding.seneye/ @nikotanghe
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,11 @@
<artifactId>org.openhab.binding.satel</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.sbus</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.semsportal</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.sbus/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This content is produced and maintained by the openHAB project.

* Project home: https://www.openhab.org

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.

== Source Code

https://github.com/openhab/openhab-addons
136 changes: 136 additions & 0 deletions bundles/org.openhab.binding.sbus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Sbus Binding

This binding integrates Sbus devices with openHAB, allowing control and monitoring of Sbus-compatible devices over UDP.
Sbus is a protocol used for home automation devices that communicate over UDP networks.
The binding supports various device types including RGB/RGBW controllers, temperature sensors, and switch controllers.

## Supported Things

- `udp` - Sbus Bridge for UDP communication
- `rgbw` - RGB/RGBW Controllers for color and brightness control
- `temperature` - Temperature Sensors for monitoring environmental conditions
- `switch` - Switch Controllers for basic on/off and dimming control

## Discovery

Sbus devices communicate via UDP broadcast, but manual configuration is required to set up the devices in openHAB.
Auto-discovery is not supported at this moment.

## Binding Configuration

The binding itself does not require any special configuration.

## Thing Configuration

### Bridge Configuration

The Sbus Bridge has the following configuration parameters:

| Name | Type | Description | Default | Required | Advanced |
|---------|---------|------------------------------------------------------|---------|----------|-----------|
| host | text | IP address of the Sbus device (typically broadcast) | N/A | yes | no |
| port | integer | UDP port number | 6000 | no | no |

### RGBW Controller Configuration

| Name | Type | Description | Default | Required | Advanced |
|---------|---------|------------------------------------------------------|---------|----------|-----------|
| subnetId| integer | Subnet ID the RGBW controller is part of | N/A | yes | no |
| id | integer | Device ID of the RGBW controller | N/A | yes | no |
| refresh | integer | Refresh interval in seconds | 30 | no | yes |

### Temperature Sensor Configuration

| Name | Type | Description | Default | Required | Advanced |
|---------|---------|------------------------------------------------------|---------|----------|-----------|
| subnetId| integer | Subnet ID the temperature sensor is part of | N/A | yes | no |
| id | integer | Device ID of the temperature sensor | N/A | yes | no |
| refresh | integer | Refresh interval in seconds | 30 | no | yes |

### Switch Controller Configuration

| Name | Type | Description | Default | Required | Advanced |
|---------|---------|------------------------------------------------------|---------|----------|-----------|
| subnetId| integer | Subnet ID the switch controller is part of | N/A | yes | no |
| id | integer | Device ID of the switch controller | N/A | yes | no |
| refresh | integer | Refresh interval in seconds | 30 | no | yes |

## Channels

### RGBW Controller Channels

| Channel | Type | Read/Write | Description |
|---------|--------|------------|------------------------------------------------------------|
| color | Color | RW | HSB color picker that controls RGBW components (0-100%) |
| switch | Switch | RW | On/Off control for the RGBW output with optional timer |

### Temperature Sensor Channels

| Channel | Type | Read/Write | Description |
|-------------|---------------------|------------|--------------------------------|
| temperature | Number:Temperature | R | Current temperature reading. Can be configured to use Celsius (default) or Fahrenheit units |

### Switch Controller Channels

| Channel | Type | Read/Write | Description |
|---------|---------|------------|-----------------------------------------------------------|
| switch | Switch | RW | Basic ON/OFF state control |
| dimmer | Dimmer | RW | ON/OFF state with timer transition |
| paired | Contact | RW | OPEN/CLOSED state for two paired channels (e.g., curtains)|

## Full Example

### Thing Configuration

```java
Bridge sbus:udp:mybridge [ host="192.168.1.255", port=5000 ] {
Thing rgbw colorctrl [ id=72, refresh=30 ] {
Channels:
Type color-channel : color [ channelNumber=1 ] // HSB color picker, RGBW values stored at channel 1
Type switch-channel : power [ channelNumber=1 ] // On/Off control for the RGBW output For complex scenes, one Sbus color controller can keep up to 40 color states. The switch channelNumber has to fall into this range.
}

Thing temperature temp1 [ id=62, refresh=30 ] {
Channels:
Type temperature-channel : temperature [ channelNumber=1 ]
}

Thing switch switch1 [ id=75, refresh=30 ] {
Channels:
Type switch-channel : first_switch [ channelNumber=1 ]
Type dimmer-channel : second_switch [ channelNumber=2 ]
Type paired-channel : third_switch [ channelNumber=3 ]
}
}
```

### Item Configuration

```java
// Temperature Sensor
Number:Temperature Temp_Sensor "Temperature [%.1f °C]" { channel="sbus:temperature:mybridge:temp1:temperature" }

// Basic Switch
Switch Light_Switch "Switch" { channel="sbus:switch:mybridge:switch1:switch" }

// Paired Channel (e.g., for curtains)
Contact Curtain_Switch "Curtain [%s]" { channel="sbus:switch:mybridge:switch1:third_switch" }

// RGBW Controller with Power Control
Group gLight "RGBW Light" <light> ["Lighting"]
Color rgbwColor "Color" <colorwheel> (gLight) ["Control", "Light"] { channel="sbus:rgbw:mybridge:colorctrl:color" }
Switch rgbwPower "Power" <switch> (gLight) ["Switch", "Light"] { channel="sbus:rgbw:mybridge:colorctrl:power" }
```

### Sitemap Configuration

```perl
sitemap sbus label="Sbus Demo"
{
Frame label="Sbus Controls" {
Colorpicker item=Light_RGB
Text item=Temp_Sensor
Switch item=Light_Switch
Text item=Curtain_Switch
}
}
26 changes: 26 additions & 0 deletions bundles/org.openhab.binding.sbus/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.sbus</artifactId>

<name>openHAB Add-ons :: Bundles :: Sbus Binding</name>

<dependencies>
<dependency>
<groupId>ro.ciprianpascu</groupId>
<artifactId>j2sbus</artifactId>
<version>1.5.7</version>
<scope>compile</scope>
</dependency>
</dependencies>

</project>
9 changes: 9 additions & 0 deletions bundles/org.openhab.binding.sbus/src/main/feature/feature.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.sbus-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>

<feature name="openhab-binding-sbus" description="Sbus Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.sbus/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2010-2025 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.sbus;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link BindingConstants} class defines common constants used across the Sbus binding.
*
* @author Ciprian Pascu - Initial contribution
*/
@NonNullByDefault
public class BindingConstants {

private BindingConstants() {
// Prevent instantiation
}

public static final String BINDING_ID = "sbus";

// Bridge Type
public static final ThingTypeUID THING_TYPE_UDP_BRIDGE = new ThingTypeUID(BINDING_ID, "udp");

// Thing Types
public static final ThingTypeUID THING_TYPE_SWITCH = new ThingTypeUID(BINDING_ID, "switch");
public static final ThingTypeUID THING_TYPE_TEMPERATURE = new ThingTypeUID(BINDING_ID, "temperature");
public static final ThingTypeUID THING_TYPE_RGBW = new ThingTypeUID(BINDING_ID, "rgbw");

// Channel IDs for Switch Device
public static final String CHANNEL_SWITCH_STATE = "state";

// Channel IDs for Temperature Device
public static final String CHANNEL_TEMPERATURE = "temperature";

// Channel IDs for RGBW Device
public static final String CHANNEL_RED = "red";
public static final String CHANNEL_GREEN = "green";
public static final String CHANNEL_BLUE = "blue";
public static final String CHANNEL_WHITE = "white";
public static final String CHANNEL_COLOR = "color";

// Channel Types
public static final String CHANNEL_TYPE_COLOR = "color-channel";
public static final String CHANNEL_TYPE_SWITCH = "switch-channel";
public static final String CHANNEL_TYPE_DIMMER = "dimmer-channel";
public static final String CHANNEL_TYPE_PAIRED = "paired-channel";
}
Loading

0 comments on commit 2a7a76f

Please sign in to comment.