]> git.basschouten.com Git - openhab-addons.git/commitdiff
Fix stack overflow when an unknown CoAP Id is detected; Fix innerTemp (#16240)
authorMarkus Michels <markus7017@gmail.com>
Thu, 18 Jan 2024 21:05:22 +0000 (16:05 -0500)
committerGitHub <noreply@github.com>
Thu, 18 Jan 2024 21:05:22 +0000 (22:05 +0100)
channel creation for Gen2 devices not having this; Fix sensor
initialization on wakeup; Fix missingf temperature5 description; add
missing relay definition for shellywalldisplay; Some README fixes

bundles/org.openhab.binding.shelly/README.md
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api1/Shelly1CoIoTVersion2.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api1/Shelly1CoapHandler.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api2/Shelly2ApiClient.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyComponents.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/util/ShellyUtils.java
bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties
bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyGen2_sensor.xml

index d007aecebb813569339c62389bf08997b151c18a..813f60237d99d3502897df7b1f908535c9181c55 100644 (file)
@@ -96,12 +96,12 @@ The binding provides the same feature set across all devices as good as possible
 | shellywalldisplay    | Shelly Plus Wall Display                                 | SAWD-0A1XX10EU1              |
 
 ### Generation 2 Plus Mini series
+
 | thing-type           | Model                                                    | Vendor ID                    |
 | -------------------- | -------------------------------------------------------- | ---------------------------- |
-| shellymini1          | Shelly Plus 1 Mini with 1x relay                         | SNSW-001X16EU                |
-| shellymini1pm        | Shelly Plus 1PM Mini with 1x relay + power meter         | SNPM-001PCEU16               |
-| shellyminipm         | Shelly Plus PM Mini with 1x power meter                  | SNSW-001P8EU                 |
-
+| shellymini1          | Shelly Plus 1 Mini with 1x relay                         | SNSW-001X8EU                 |
+| shellymini1pm        | Shelly Plus 1PM Mini with 1x relay + power meter         | SNSW-001P8EU                 |
+| shellyminipm         | Shelly Plus PM Mini with 1x power meter                  | SNPM-001PCEU16               |
 
 ### Generation 2 Pro series
 
@@ -402,14 +402,18 @@ A new alarm will be triggered on a new condition or every 5 minutes if the condi
 
 ### Non-battery powered devices
 
-| Event Type  | Description                                                                       |
-| ----------- | --------------------------------------------------------------------------------- |
-| RESTARTED   | The device has been restarted. This could be an indicator for a firmware problem. |
-| WEAK_SIGNAL | An alarm is triggered when RSSI is < -80, which indicates an unstable connection. |
-| OVER_TEMP   | The device is overheating, check installation and housing.                        |
-| OVER_LOAD   | An over load condition has been detected, e.g. from the roller motor.             |
-| OVER_POWER  | Maximum allowed power was exceeded. The relay was turned off.                     |
-| LOAD_ERROR  | Device reported a load problem, so far Dimmer only.                               |
+| Event Type   | Description                                                                       |
+| ------------ | --------------------------------------------------------------------------------- |
+| RESTARTED    | The device has been restarted. This could be an indicator for a firmware problem. |
+| WEAK_SIGNAL  | An alarm is triggered when RSSI is < -80, which indicates an unstable connection. |
+| OVERTEMP     | The device is overheating, check installation and housing.                        |
+| OVERLOAD     | An over load condition has been detected, e.g. from the roller motor.             |
+| OVERPOWER    | Maximum allowed power was exceeded. The relay was turned off.                     |
+| LOAD_ERROR   | Device reported a load problem.                                                   |
+| SENSOR_ERROR | Device reported a sensor problem.                                                 |
+| VALVE_ERROR  | Device reported a problem with the valve.                                         |
+| VIBRATION    | Device reported vibration.                                                        |
+| LOW_BATTERY  | Device reported low battery.                                                      |
 
 ### Sensors
 
index 7e1eef50ff4636765cb307f77a40ae23dfd7ffc7..fc295303695998128db1a1d0b4dbb4ad223f05d6 100644 (file)
@@ -142,6 +142,9 @@ public class Shelly1CoIoTVersion2 extends Shelly1CoIoTProtocol implements Shelly
 
         processed = true;
         switch (sen.id) {
+            case "6": // 3EM: neutralCurrent
+                break;
+
             case "3106": // L, luminosity, lux, U32, -1
             case "3110": // S, luminosityLevel, dark/twilight/bright, "unknown"=unknown
             case "3111": // B, battery, 0-100%, unknown -1
index d933736be941cd8fcc618299f9682c33e7d058dc..9ab5e29c39bb794bca20600161ca66a0f8ad573c 100644 (file)
@@ -359,16 +359,12 @@ public class Shelly1CoapHandler implements Shelly1CoapListener {
                     valid &= addSensor(descr.sen.get(i));
                 }
             }
-            coiot.completeMissingSensorDefinition(sensorMap);
-
             if (!valid) {
-                logger.debug(
-                        "{}: Incompatible device description detected for CoIoT version {} (id length mismatch), discarding!",
-                        thingName, coiot.getVersion());
-
-                discover();
-                return;
+                logger.debug("{}: WARNING: Incompatible device description detected for CoIoT version {}!", thingName,
+                        coiot.getVersion());
             }
+
+            coiot.completeMissingSensorDefinition(sensorMap); // fix incomplete format
         } catch (JsonSyntaxException e) {
             logger.warn("{}: Unable to parse CoAP Device Description! JSON={}", thingName, payload);
         } catch (NullPointerException | IllegalArgumentException e) {
index 651fb195302b84ba7cc3f633efcc3419aef69fac..6ca8d4c11a2438651c052625e03275d26eea7b1f 100644 (file)
@@ -239,9 +239,6 @@ public class Shelly2ApiClient extends ShellyHttpClient {
             int duration = (int) (now() - rs.timerStartetAt);
             sr.timerRemaining = duration;
         }
-        if (status.tmp == null) {
-            status.tmp = new ShellySensorTmp();
-        }
         if (rs.temperature != null) {
             if (status.tmp == null) {
                 status.tmp = new ShellySensorTmp();
index a413fc59aa262b13bff05f08482616764f4e6f93..4e0a4a1f14152e1050106617f92b4a4b3326d922 100755 (executable)
@@ -293,8 +293,10 @@ public abstract class ShellyBaseHandler extends BaseThingHandler
             return false;
         }
 
-        updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.CONFIGURATION_PENDING,
-                messages.get("status.unknown.initializing"));
+        if (profile.alwaysOn || !profile.isInitialized()) {
+            updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.CONFIGURATION_PENDING,
+                    messages.get("status.unknown.initializing"));
+        }
 
         // Gen 1 only: Setup CoAP listener to we get the CoAP message, which triggers initialization even the thing
         // could not be fully initialized here. In this case the CoAP messages triggers auto-initialization (like the
@@ -513,7 +515,7 @@ public abstract class ShellyBaseHandler extends BaseThingHandler
     }
 
     private double getNumber(Command command) {
-        if (command instanceof QuantityType quantityCommand) {
+        if (command instanceof QuantityType<?> quantityCommand) {
             return quantityCommand.doubleValue();
         }
         if (command instanceof DecimalType decimalCommand) {
@@ -1279,7 +1281,7 @@ public abstract class ShellyBaseHandler extends BaseThingHandler
     public double getChannelDouble(String group, String channel) {
         State value = getChannelValue(group, channel);
         if (value != UnDefType.NULL) {
-            if (value instanceof QuantityType quantityCommand) {
+            if (value instanceof QuantityType<?> quantityCommand) {
                 return quantityCommand.toBigDecimal().doubleValue();
             }
             if (value instanceof DecimalType decimalCommand) {
index 6f862adc4636df636624d2cd2693d9266a54792f..fe6e70a5cd92f4e707e065e0dcfd0f3e11f1149a 100644 (file)
@@ -534,7 +534,7 @@ public class ShellyComponents {
             updated |= thingHandler.updateInputs(status);
 
             if (updated) {
-                thingHandler.updateChannel(profile.getControlGroup(0), CHANNEL_LAST_UPDATE, getTimestamp());
+                thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_LAST_UPDATE, getTimestamp());
             }
         }
         return updated;
index e54b5f2693e093b3bbc7c297333684309add105e..5a4a82676676bf0e3e3b70ceaf517d74f4345af4 100644 (file)
@@ -239,7 +239,7 @@ public class ShellyUtils {
         if (command instanceof DecimalType decimalCommand) {
             return decimalCommand.doubleValue();
         }
-        if (command instanceof QuantityType quantityCommand) {
+        if (command instanceof QuantityType<?> quantityCommand) {
             return quantityCommand.doubleValue();
         }
         throw new IllegalArgumentException("Unable to convert number");
index 2c2801bfcbc344185adba4689e029e093a1f05be..94797887498801575fd0bc04763b5c296be693c6 100644 (file)
@@ -246,7 +246,7 @@ channel-type.shelly.temperature3.description = Temperature of external Sensor #3
 channel-type.shelly.temperature4.label = Temperature 4
 channel-type.shelly.temperature4.description = Temperature of external Sensor #4
 channel-type.shelly.temperature5.label = Temperature 5
-channel-type.shelly.temperature6.description = Temperature of external Sensor #5
+channel-type.shelly.temperature5.description = Temperature of external Sensor #5
 channel-type.shelly.targetTemp.label = Target Temperature
 channel-type.shelly.targetTemp.description = Target Temperature in °C to be reached in auto-temperature mode
 channel-type.shelly.humidity.label = Humidity
index 482379537fef94dc606c46db499003bd974318a5..1d84911bed81b068a65dbf697f98643f82e23ad6 100644 (file)
@@ -38,6 +38,7 @@
                <category>Sensor</category>
                <channel-groups>
                        <channel-group id="sensors" typeId="sensorData"/>
+                       <channel-group id="relay" typeId="relayChannel"/>
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>