Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 93 additions & 50 deletions bundles/org.openhab.binding.sbus/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# 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.
This binding integrates Sbus-compatible hardware with openHAB, allowing control and monitoring over UDP networks.
Sbus is a protocol used for home automation that communicates via UDP broadcast messages.
The binding supports various thing types including RGB/RGBW controllers, temperature sensors, switch controllers, and multiple sensor types.

## Supported Things

- `udp` - Sbus Bridge for UDP communication
- `rgbw` - RGB/RGBW Controllers for color and brightness control
- `temperature` - Temperature Sensors for monitoring environmental conditions
- `temperature-sensor` - Temperature Sensors for monitoring environmental conditions
- `switch` - Switch Controllers for basic on/off and dimming control
- `contact-sensor` - Contact Sensors for monitoring open/closed states
- `motion-sensor` - Motion Sensors for detecting movement (9-in-1 devices)
- `lux-sensor` - Light Level Sensors for monitoring illuminance (LUX values)
- `contact-sensor` - Contact Sensors for monitoring open/closed states (supports both 012C and 02CA sensor types)
- `motion-sensor` - Motion Sensors for detecting movement
- `lux-sensor` - Light Level Sensors for measuring illuminance
- `temperature` - (Deprecated) Use `temperature-sensor` instead

## Discovery

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

## Binding Configuration
Expand All @@ -33,21 +34,29 @@ 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 |
| host | text | IP address for Sbus communication (typically broadcast) | N/A | yes | no |
| port | integer | UDP port number | 6000 | no | no |
| timeout | integer | Response timeout in milliseconds | 3000 | no | yes |

### Device Configuration
### Thing Configuration

All device types (RGBW Controller, Contact Sensor, Switch, Temperature, Motion Sensor, Lux Sensor) share the same configuration parameters:
Most thing types share the same basic configuration parameters:

| Name | Type | Description | Default | Required | Advanced |
|:--------|:--------|:-----------------------------------------------------|:-------:|:--------:|:---------:|
| subnetId| integer | Subnet ID the device is part of | N/A | yes | no |
| id | integer | Device ID | N/A | yes | no |
| subnetId| integer | Subnet ID | 1 | yes | no |
| id | integer | Unit ID | N/A | yes | no |
| refresh | integer | Refresh interval in seconds (0 = listen-only mode) | 30 | no | yes |

**Note:** Setting `refresh=0` enables listen-only mode for all device types. In this mode, handlers only process asynchronous broadcast messages without actively polling the devices. This is particularly useful for Motion Sensor and Lux Sensor devices that broadcast status updates (0x02CA) from 9-in-1 devices.
**Contact Sensor Additional Configuration:**

The `contact-sensor` thing type has an additional `type` parameter:

| Name | Type | Description | Default | Required | Advanced |
|:--------|:--------|:-----------------------------------------------------|:-------:|:--------:|:---------:|
| type | text | Sensor type: `012c` (dry contact) or `02ca` (multi-sensor) | 012c | no | no |

**Listen-Only Mode:** Setting `refresh=0` enables listen-only mode where the binding only processes broadcast messages without actively polling. This is useful for sensors that automatically broadcast their status updates.

## Channels

Expand All @@ -62,7 +71,7 @@ The color channel of RGBW controllers supports these additional parameters:

| Parameter | Type | Description | Default | Required | Advanced |
|:------------|:--------|:-----------------------------------------------------|:-------:|:--------:|:---------:|
| channelNumber | integer | The physical channel number on the Sbus device | N/A | yes | no |
| channelNumber | integer | The physical channel number | N/A | yes | no |
| enableWhite | boolean | Controls the white component support for RGB palette | true | no | yes |

### Temperature Sensor Channels
Expand All @@ -87,15 +96,17 @@ The color channel of RGBW controllers supports these additional parameters:

### Motion Sensor Channels

| Channel | Type | Read/Write | Description |
|:--------|:-------|:----------:|:----------------------------------------------------------|
| motion | Switch | R | Motion detection state (ON=motion detected, OFF=no motion) |
| Channel | Type | Read/Write | Description |
|:--------|:--------|:----------:|:----------------------------------------------------------|
| motion | Switch | R | Motion detection state (ON=motion detected, OFF=no motion)|

### Lux Sensor Channels

| Channel | Type | Read/Write | Description |
|:--------|:-------|:----------:|:----------------------------------------------------------|
| lux | Number | R | Light level in LUX units |
| Channel | Type | Read/Write | Description |
|:--------|:--------|:----------:|:----------------------------------------------------------|
| lux | Number | R | Light level in LUX units |

**Note:** All sensor channels require a `channelNumber` parameter to specify the physical channel number.

## Full Example

Expand All @@ -115,31 +126,32 @@ Bridge sbus:udp:mybridge [ host="192.168.1.255", port=5000, timeout=5000 ] {
Type switch-channel : power [ channelNumber=1 ]
}

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, pairedChannelNumber=4 ]
}

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

Thing contact-sensor contact1 [ type="012c", id=80, refresh=30 ] {
Channels:
Type contact-channel : contact [ channelNumber=1 ]
}


Thing motion-sensor motion1 [ id=85, refresh=0 ] {
Thing motion-sensor sensor_motion [ id=85, refresh=0 ] {
Channels:
Type motion-channel : motion
Type motion-channel : motion [ channelNumber=1 ]
}

Thing lux-sensor lux1 [ id=85, refresh=0 ] {
Thing lux-sensor sensor_lux [ id=85, refresh=0 ] {
Channels:
Type lux-channel : lux
Type lux-channel : lux [ channelNumber=1 ]
}
}
```
Expand All @@ -148,7 +160,7 @@ Bridge sbus:udp:mybridge [ host="192.168.1.255", port=5000, timeout=5000 ] {

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

// Basic Switch
Switch Light_Switch "Switch" { channel="sbus:switch:mybridge:switch1:switch" }
Expand All @@ -162,30 +174,61 @@ Color rgbwColor "Color" <colorwheel> (gLight) ["Control", "Light"]
Switch rgbwPower "Power" <switch> (gLight) ["Switch", "Light"] { channel="sbus:rgbw:mybridge:colorctrl:power" }

// Contact Sensor
Contact Door_Contact "Door [%s]" <door> { channel="sbus:contact-sensor:mybridge:contact1:contact" }
Contact Contact_Sensor "Contact [%s]" <contact> { channel="sbus:contact-sensor:mybridge:contact1:contact" }

// Motion Sensor (listen-only mode)
Switch Motion_Sensor "Motion [%s]" <motion> { channel="sbus:motion-sensor:mybridge:motion1:motion" }
// Motion Sensor
Switch Motion_Sensor "Motion [%s]" <motion> { channel="sbus:motion-sensor:mybridge:sensor_motion:motion" }

// Lux Sensor (listen-only mode)
Number Lux_Sensor "Light Level [%.0f lux]" <sun> { channel="sbus:lux-sensor:mybridge:lux1:lux" }
// Lux Sensor
Number Lux_Sensor "Light Level [%.0f lux]" <sun> { channel="sbus:lux-sensor:mybridge:sensor_lux:lux" }
```

### Sitemap Configuration

```perl
sitemap sbus label="Sbus Demo"
{
Frame label="Sbus Controls" {
Colorpicker item=Light_RGB
Text item=Temp_Sensor
Switch item=Light_Switch
Rollershutter item=Rollershutter_Switch
Text item=Door_Contact
}
## Usage Notes

### 9-in-1 Sensor Configuration

9-in-1 sensors are multi-function sensors that combine motion detection, light level measurement, and dry contact monitoring in a single physical unit. To configure a 9-in-1 sensor in openHAB, you need to create **three separate things** that all reference the same physical sensor:

1. **contact-sensor** (type: `02ca`) - For dry contact channels
2. **motion-sensor** - For motion detection
3. **lux-sensor** - For light level sensing

All three things must use the **same subnet ID and unit ID** to represent the same physical sensor.

**Example for a 9-in-1 sensor with ID 85:**

```java
Thing contact-sensor sensor_contact [ type="02ca", id=85, refresh=0 ] {
Channels:
Type contact-channel : contact1 [ channelNumber=1 ]
Type contact-channel : contact2 [ channelNumber=2 ]
}

## Usage Notes
Thing motion-sensor sensor_motion [ id=85, refresh=0 ] {
Channels:
Type motion-channel : motion [ channelNumber=1 ]
}

Thing lux-sensor sensor_lux [ id=85, refresh=0 ] {
Channels:
Type lux-channel : lux [ channelNumber=1 ]
}
```

**Benefits of this approach:**
- Clear separation of concerns - each thing handles one sensor type
- Flexible configuration - only create the things you need
- Follows openHAB best practices for thing organization
- Each thing can be configured independently

### Contact Sensor Types

The `contact-sensor` thing type supports two different sensor types via the `type` parameter:

- **`012c`** (default): 012C dry contact sensors
- **`02ca`**: 02CA multi-sensor dry contacts

Choose the appropriate type based on your hardware.

### RGB vs. RGBW Mode

Expand Down
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.sbus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>ro.ciprianpascu</groupId>
<artifactId>j2sbus</artifactId>
<version>1.6.3</version>
<version>1.6.4</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ private BindingConstants() {

// 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_TEMPERATURE = new ThingTypeUID(BINDING_ID, "temperature"); // Deprecated
public static final ThingTypeUID THING_TYPE_TEMPERATURE_SENSOR = new ThingTypeUID(BINDING_ID, "temperature-sensor");
public static final ThingTypeUID THING_TYPE_RGBW = new ThingTypeUID(BINDING_ID, "rgbw");
public static final ThingTypeUID THING_TYPE_CONTACT_SENSOR = new ThingTypeUID(BINDING_ID, "contact-sensor");
public static final ThingTypeUID THING_TYPE_MOTION_SENSOR = new ThingTypeUID(BINDING_ID, "motion-sensor");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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.internal.config;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link ContactSensorType} enum defines the types of contact sensors supported by the binding.
*
* @author Ciprian Pascu - Initial contribution
*/
@NonNullByDefault
public enum ContactSensorType {
/**
* 012C dry contact sensor using ReadDryChannelsRequest/Response protocol
*/
SENSOR_012C("012c"),

/**
* 02CA multi-sensor with dry contacts using ReadNineInOneStatusRequest/Response protocol
* and MotionSensorStatusReport (0x02CA) broadcasts
*/
MULTI_SENSOR_02CA("02ca");

private final String configValue;

ContactSensorType(String configValue) {
this.configValue = configValue;
}

/**
* Get the configuration value for this sensor type.
*
* @return the configuration value
*/
public String getConfigValue() {
return configValue;
}

/**
* Parse a configuration value into a ContactSensorType.
*
* @param value the configuration value
* @return the corresponding ContactSensorType, or SENSOR_24Z if not recognized
*/
public static ContactSensorType fromConfigValue(String value) {
for (ContactSensorType type : values()) {
if (type.configValue.equals(value)) {
return type;
}
}
return SENSOR_012C; // Default to 012C for backward compatibility or null values
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.internal.config;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link SbusContactConfig} class extends device configuration with contact sensor specific parameters.
*
* @author Ciprian Pascu - Initial contribution
*/
@NonNullByDefault
public class SbusContactConfig extends SbusDeviceConfig {
/**
* Sensor type for contact sensor.
* String value is used for configuration binding, converted to enum via ContactSensorType.fromConfigValue()
*/
public String type = ContactSensorType.SENSOR_012C.getConfigValue(); // Default to traditional behavior

/**
* Get the sensor type as an enum.
*
* @return the ContactSensorType enum value
*/
public ContactSensorType getSensorType() {
return ContactSensorType.fromConfigValue(type);
}
}
Loading