diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api2/Shelly2ApiRpc.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api2/Shelly2ApiRpc.java index 6e432322303a6..3b440dbe63b7c 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api2/Shelly2ApiRpc.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api2/Shelly2ApiRpc.java @@ -15,7 +15,7 @@ import static org.openhab.binding.shelly.internal.ShellyBindingConstants.*; import static org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.*; import static org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.*; -import static org.openhab.binding.shelly.internal.discovery.ShellyThingCreator.THING_TYPE_SHELLYPRO2_RELAY_STR; +import static org.openhab.binding.shelly.internal.discovery.ShellyThingCreator.*; import static org.openhab.binding.shelly.internal.util.ShellyUtils.*; import java.io.BufferedReader; @@ -259,6 +259,8 @@ public ShellyDeviceProfile getDeviceProfile(String thingType, @Nullable ShellySe // Mini PM has 1 meter, but no relay if (thingType.equals(THING_TYPE_SHELLYPRO2_RELAY_STR)) { profile.numMeters = 0; + } else if (thingType.equals(THING_TYPE_SHELLYPRO3EM_STR)) { + profile.numMeters = 3; } else if (dc.pm10 != null) { profile.numMeters = 1; } else if (dc.em0 != null) { diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyComponents.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyComponents.java index 1d5a0cc133234..95f00e6539701 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyComponents.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyComponents.java @@ -123,31 +123,6 @@ public static boolean updateRelay(ShellyBaseHandler thingHandler, ShellySettings getOpenClosed(getInteger(status.extSwitch.input0.input) == 1)); } } - if (status.extTemperature != null) { - // Shelly 1/1PM support up to 3 external sensors - // for whatever reason those are not represented as an array, but 3 elements - updated |= updateTempChannel(status.extTemperature.sensor1, thingHandler, CHANNEL_ESENSOR_TEMP1); - updated |= updateTempChannel(status.extTemperature.sensor2, thingHandler, CHANNEL_ESENSOR_TEMP2); - updated |= updateTempChannel(status.extTemperature.sensor3, thingHandler, CHANNEL_ESENSOR_TEMP3); - updated |= updateTempChannel(status.extTemperature.sensor4, thingHandler, CHANNEL_ESENSOR_TEMP4); - updated |= updateTempChannel(status.extTemperature.sensor5, thingHandler, CHANNEL_ESENSOR_TEMP5); - } - if ((status.extHumidity != null) && (status.extHumidity.sensor1 != null)) { - updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_ESENSOR_HUMIDITY, - toQuantityType(getDouble(status.extHumidity.sensor1.hum), DIGITS_PERCENT, Units.PERCENT)); - } - if ((status.extVoltage != null) && (status.extVoltage.sensor1 != null)) { - updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_ESENSOR_VOLTAGE, - toQuantityType(getDouble(status.extVoltage.sensor1.voltage), 4, Units.VOLT)); - } - if ((status.extDigitalInput != null) && (status.extDigitalInput.sensor1 != null)) { - updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_ESENSOR_DIGITALINPUT, - getOnOff(status.extDigitalInput.sensor1.state)); - } - if ((status.extAnalogInput != null) && (status.extAnalogInput.sensor1 != null)) { - updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_ESENSOR_ANALOGINPUT, toQuantityType( - getDouble(status.extAnalogInput.sensor1.percent), DIGITS_PERCENT, Units.PERCENT)); - } // Update Auto-ON/OFF timer updated |= thingHandler.updateChannel(groupName, CHANNEL_TIMER_AUTOON, @@ -556,6 +531,34 @@ public static boolean updateSensors(ShellyThingInterface thingHandler, ShellySet thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_LAST_UPDATE, getTimestamp()); } } + + // Update Add-On channeƶs + if (status.extTemperature != null) { + // Shelly 1/1PM support up to 3 external sensors + // for whatever reason those are not represented as an array, but 3 elements + updated |= updateTempChannel(status.extTemperature.sensor1, thingHandler, CHANNEL_ESENSOR_TEMP1); + updated |= updateTempChannel(status.extTemperature.sensor2, thingHandler, CHANNEL_ESENSOR_TEMP2); + updated |= updateTempChannel(status.extTemperature.sensor3, thingHandler, CHANNEL_ESENSOR_TEMP3); + updated |= updateTempChannel(status.extTemperature.sensor4, thingHandler, CHANNEL_ESENSOR_TEMP4); + updated |= updateTempChannel(status.extTemperature.sensor5, thingHandler, CHANNEL_ESENSOR_TEMP5); + } + if ((status.extHumidity != null) && (status.extHumidity.sensor1 != null)) { + updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_ESENSOR_HUMIDITY, + toQuantityType(getDouble(status.extHumidity.sensor1.hum), DIGITS_PERCENT, Units.PERCENT)); + } + if ((status.extVoltage != null) && (status.extVoltage.sensor1 != null)) { + updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_ESENSOR_VOLTAGE, + toQuantityType(getDouble(status.extVoltage.sensor1.voltage), 4, Units.VOLT)); + } + if ((status.extDigitalInput != null) && (status.extDigitalInput.sensor1 != null)) { + updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_ESENSOR_DIGITALINPUT, + getOnOff(status.extDigitalInput.sensor1.state)); + } + if ((status.extAnalogInput != null) && (status.extAnalogInput.sensor1 != null)) { + updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_ESENSOR_ANALOGINPUT, + toQuantityType(getDouble(status.extAnalogInput.sensor1.percent), DIGITS_PERCENT, Units.PERCENT)); + } + return updated; }