diff --git a/bundles/org.openhab.binding.sbus/pom.xml b/bundles/org.openhab.binding.sbus/pom.xml index 35b19d9cc757d..c3557dccf818b 100644 --- a/bundles/org.openhab.binding.sbus/pom.xml +++ b/bundles/org.openhab.binding.sbus/pom.xml @@ -18,7 +18,7 @@ ro.ciprianpascu j2sbus - 1.5.4 + 1.5.5 compile diff --git a/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/handler/SbusRgbwHandler.java b/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/handler/SbusRgbwHandler.java index 145414afe831f..127795a7a4d12 100644 --- a/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/handler/SbusRgbwHandler.java +++ b/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/handler/SbusRgbwHandler.java @@ -227,8 +227,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { && command instanceof HSBType hsbCommand) { // Handle color command int[] rgbw = hsbToRgbw(hsbCommand); - adapter.writeRgbw(config.subnetId, config.id, channelConfig.channelNumber, rgbw[0], rgbw[1], - rgbw[2], rgbw[3]); + adapter.writeRgbw(config.subnetId, config.id, channelConfig.channelNumber, rgbw); updateState(channelUID, hsbCommand); } else if (BindingConstants.CHANNEL_TYPE_SWITCH.equals(channelTypeId) && command instanceof OnOffType onOffCommand) { diff --git a/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/handler/SbusService.java b/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/handler/SbusService.java index 56cf88af176d8..a949fbffae8c9 100644 --- a/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/handler/SbusService.java +++ b/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/handler/SbusService.java @@ -27,10 +27,11 @@ public interface SbusService { * * @param subnetId the subnet ID of the device * @param id the device ID + * @param temperatureUnit The unit of measurement (e.g., 0 for Fahrenheit, 1 for Celsius) * @return array of temperature values in Celsius * @throws Exception if reading fails */ - float[] readTemperatures(int subnetId, int id) throws Exception; + float[] readTemperatures(int subnetId, int id, int temperatureUnit) throws Exception; /** * Reads RGBW values from a device channel. @@ -59,13 +60,10 @@ public interface SbusService { * @param subnetId the subnet ID of the device * @param id the device ID * @param channelNumber the channel number to write to - * @param r red value (0-255) - * @param g green value (0-255) - * @param b blue value (0-255) - * @param w white value (0-255) + * @param color An array of 4 integers representing RGBW values (0-255 each) * @throws Exception if writing fails */ - void writeRgbw(int subnetId, int id, int channelNumber, int r, int g, int b, int w) throws Exception; + void writeRgbw(int subnetId, int id, int channelNumber, int[] color) throws Exception; /** * Writes a value to a single channel. diff --git a/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/handler/SbusTemperatureHandler.java b/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/handler/SbusTemperatureHandler.java index 16f3681fb860a..04fb24fa58849 100644 --- a/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/handler/SbusTemperatureHandler.java +++ b/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/handler/SbusTemperatureHandler.java @@ -68,7 +68,7 @@ protected void pollDevice() { SbusDeviceConfig config = getConfigAs(SbusDeviceConfig.class); // Read temperatures in Celsius from device - float[] temperatures = adapter.readTemperatures(config.subnetId, config.id); + float[] temperatures = adapter.readTemperatures(config.subnetId, config.id, 1); // Iterate over all channels and update their states with corresponding temperatures for (Channel channel : getThing().getChannels()) { diff --git a/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/internal/SbusServiceImpl.java b/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/internal/SbusServiceImpl.java index 9a32e8ee77b87..b2dc78ee7ab04 100644 --- a/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/internal/SbusServiceImpl.java +++ b/bundles/org.openhab.binding.sbus/src/main/java/org/openhab/binding/sbus/internal/SbusServiceImpl.java @@ -43,6 +43,7 @@ public SbusServiceImpl() { * @param port the port number to use * @throws Exception if initialization fails */ + @Override public void initialize(String host, int port) throws Exception { this.adapter = new SbusAdapter(host, port); } @@ -53,12 +54,12 @@ public void deactivate() { } @Override - public float[] readTemperatures(int subnetId, int id) throws Exception { + public float[] readTemperatures(int subnetId, int id, int temperatureUnit) throws Exception { final SbusAdapter adapter = this.adapter; if (adapter == null) { throw new IllegalStateException("SbusAdapter not initialized"); } - return adapter.readTemperatures(subnetId, id); + return adapter.readTemperatures(subnetId, id, temperatureUnit); } @Override @@ -80,12 +81,12 @@ public int[] readStatusChannels(int subnetId, int id) throws Exception { } @Override - public void writeRgbw(int subnetId, int id, int channelNumber, int r, int g, int b, int w) throws Exception { + public void writeRgbw(int subnetId, int id, int channelNumber, int[] color) throws Exception { final SbusAdapter adapter = this.adapter; if (adapter == null) { throw new IllegalStateException("SbusAdapter not initialized"); } - adapter.writeRgbw(subnetId, id, channelNumber, r, g, b, w); + adapter.writeRgbw(subnetId, id, channelNumber, color); } @Override