From: Markus Michels Date: Sun, 4 Feb 2024 16:17:59 +0000 (+0100) Subject: Support for Shelly Plus Mini Gen 3 series of devices, Shelly Plus UNI (#16335) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=3fb5e66eb1e87a9b626c1d7c87515c802814cbd5;p=openhab-addons.git Support for Shelly Plus Mini Gen 3 series of devices, Shelly Plus UNI (#16335) and Shelly BLU Gateway. Signed-off-by: Markus Michels --- diff --git a/bundles/org.openhab.binding.shelly/README.md b/bundles/org.openhab.binding.shelly/README.md index 813f60237d..89b34d8e41 100644 --- a/bundles/org.openhab.binding.shelly/README.md +++ b/bundles/org.openhab.binding.shelly/README.md @@ -28,8 +28,8 @@ Also check out the [Shelly Manager](doc/ShellyManager.md), which The binding supports both hardware generations - Generation 1: The original Shelly devices like the Shelly 1, Shelly 2.5, Shelly Flood etc. -- Generation 2: The new Plus / Pro series of devices -- Shelly Plus Mini: Shelly Plus devices in compact format +- Generation 2: Plus / Pro series of devices +- Shelly Plus Mini: Shelly Plus devices in compact format (Gen 2+3) - Shelly BLU: Bluetooth based series of devices The binding provides the same feature set across all devices as good as possible and depending on device specific features. @@ -95,13 +95,13 @@ The binding provides the same feature set across all devices as good as possible | shellypluswdus | Shelly Plus Wall Dimmer US | SNDM-0013US | | shellywalldisplay | Shelly Plus Wall Display | SAWD-0A1XX10EU1 | -### Generation 2 Plus Mini series +### Generation 2 Plus Mini series (incl. Gen 3) -| thing-type | Model | Vendor ID | -| -------------------- | -------------------------------------------------------- | ---------------------------- | -| 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 | + | thing-type | Model | Vendor ID | + | -------------------- | -------------------------------------------------------- | ------------------------------ | + | shellymini1 | Shelly Plus 1 Mini with 1x relay | SNSW-001X8EU, S3SW-001X8EU | + | shellymini1pm | Shelly Plus 1PM Mini with 1x relay + power meter | SNSW-001P8EU, S3SW-001P8EU | + | shellyminipm | Shelly Plus PM Mini with 1x power meter | SNPM-001PCEU16, S3PM-001PCEU16 | ### Generation 2 Pro series diff --git a/bundles/org.openhab.binding.shelly/pom.xml b/bundles/org.openhab.binding.shelly/pom.xml index ccbe2a43a7..8e3f2c50af 100644 --- a/bundles/org.openhab.binding.shelly/pom.xml +++ b/bundles/org.openhab.binding.shelly/pom.xml @@ -15,6 +15,6 @@ org.openhab.binding.shelly - openHAB Add-ons :: Bundles :: Shelly Binding Gen1+2 + openHAB Add-ons :: Bundles :: Shelly Binding diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java index 7c3a639034..04dee188bd 100755 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java @@ -104,6 +104,7 @@ public class ShellyBindingConstants { THING_TYPE_SHELLYBLUBUTTON, // THING_TYPE_SHELLYBLUDW, // THING_TYPE_SHELLYBLUMOTION, // + THING_TYPE_SHELLYBLUGW, // THING_TYPE_SHELLYPROTECTED, // THING_TYPE_SHELLYUNKNOWN); diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java index 324075588d..c98ea91733 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java @@ -403,12 +403,12 @@ public class ShellyDeviceProfile { } public static boolean isGeneration2(String thingType) { - return thingType.startsWith("shellyplus") || thingType.startsWith("shellypro") - || thingType.startsWith("shellymini") || isBluSeries(thingType); + return thingType.startsWith("shellyplus") || thingType.startsWith("shellypro") || thingType.contains("mini") + || isBluSeries(thingType); } public static boolean isBluSeries(String thingType) { - return thingType.startsWith("shellyblu"); + return thingType.startsWith("shellyblu") && !thingType.startsWith(THING_TYPE_SHELLYBLUGW_STR); } public boolean coiotEnabled() { diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api2/Shelly2ApiJsonDTO.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api2/Shelly2ApiJsonDTO.java index ae0ad437ef..1143051df1 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api2/Shelly2ApiJsonDTO.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api2/Shelly2ApiJsonDTO.java @@ -521,11 +521,26 @@ public class Shelly2ApiJsonDTO { } public static class Shelly2DeviceStatus { + public class Shelly2InputCounts { + public Integer total; + @SerializedName("by_minute") + public Double[] byMinute; + public Double xtotal; + @SerializedName("xby_minute") + public Double[] xbyMinute; + @SerializedName("minute_ts") + public Integer minuteTS; + } + public class Shelly2InputStatus { public Integer id; public Boolean state; public Double percent; // analog input only public ArrayList errors;// shown only if at least one error is present. + public Double xpercent; + public Shelly2InputCounts counts; + public Double freq; + public Double xfreq; } public static class Shelly2DeviceStatusLight { diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java index 1441bdab64..bb3436d137 100755 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java @@ -143,7 +143,8 @@ public class ShellyDiscoveryParticipant implements MDNSDiscoveryParticipant { config.userId = bindingConfig.defaultUserId; config.password = bindingConfig.defaultPassword; - boolean gen2 = "2".equals(service.getPropertyString("gen")); + String gen = getString(service.getPropertyString("gen")); + boolean gen2 = "2".equals(gen) || "3".equals(gen); ShellyApiInterface api = null; boolean auth = false; ShellySettingsDevice devInfo; @@ -152,7 +153,8 @@ public class ShellyDiscoveryParticipant implements MDNSDiscoveryParticipant { api.initialize(); devInfo = api.getDeviceInfo(); model = devInfo.type; - auth = devInfo.auth; + gen2 = !(devInfo.gen == 1); // gen 2+3 + auth = getBool(devInfo.auth); if (devInfo.name != null) { deviceName = devInfo.name; } diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java index c9adaefc7e..1fab58a45b 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java @@ -40,6 +40,7 @@ public class ShellyThingCreator { public static final String SHELLYDT_SHELLY2 = "SHSW-21"; public static final String SHELLYDT_SHELLY25 = "SHSW-25"; public static final String SHELLYDT_SHPRO = "SHSW-44"; + public static final String SHELLYDT_4PRO = "SHPSW04P"; public static final String SHELLYDT_EM = "SHEM"; public static final String SHELLYDT_3EM = "SHEM-3"; public static final String SHELLYDT_HT = "SHHT-1"; @@ -79,6 +80,7 @@ public class ShellyThingCreator { public static final String SHELLYDT_PLUSI4DC = "SNSN-0D24X"; public static final String SHELLYDT_PLUSHT = "SNSN-0013A"; public static final String SHELLYDT_PLUSSMOKE = "SNSN-0031Z"; + public static final String SHELLYDT_PLUSUNI = "SNSN-0043X"; public static final String SHELLYDT_PLUSDIMMERUS = "SNDM-0013US"; public static final String SHELLYDT_PLUSDIMMER10V = "SNGW-0A11WW010"; public static final String SHELLYDT_PLUSWALLDISPLAY = "SAWD-0A1XX10EU1"; @@ -106,15 +108,20 @@ public class ShellyThingCreator { public static final String SHELLYDT_PRO4PM_2 = "SPSW-104PE16EU"; // Shelly Plus Mini Series - // Shelly Mini Series + // Mini Generation 2 public static final String SHELLYDT_MINI1 = "SNSW-001X8EU"; public static final String SHELLYDT_MINIPM = "SNPM-001PCEU16"; public static final String SHELLYDT_MINI1PM = "SNSW-001P8EU"; + // Mini Generation 3 + public static final String SHELLYDT_MINI1G3_1 = "S3SW-001X8EU"; + public static final String SHELLYDT_MINIG3_PM = "S3PM-001PCEU16"; + public static final String SHELLYDT_MINIG3_1PM = "S3SW-001P8EU"; // Shelly BLU Series public static final String SHELLYDT_BLUBUTTON = "SBBT"; public static final String SHELLYDT_BLUDW = "SBDW"; public static final String SHELLYDT_BLUMOTION = "SBMO"; + public static final String SHELLYDT_BLUGW = "SNGW-BT01"; // Thing names public static final String THING_TYPE_SHELLY1_STR = "shelly1"; @@ -195,6 +202,7 @@ public class ShellyThingCreator { public static final String THING_TYPE_SHELLYBLUBUTTON_STR = THING_TYPE_SHELLYBLU_PREFIX + "button"; public static final String THING_TYPE_SHELLYBLUDW_STR = THING_TYPE_SHELLYBLU_PREFIX + "dw"; public static final String THING_TYPE_SHELLYBLUMOTION_STR = THING_TYPE_SHELLYBLU_PREFIX + "motion"; + public static final String THING_TYPE_SHELLYBLUGW_STR = THING_TYPE_SHELLYBLU_PREFIX + "gw"; // Password protected or unknown device public static final String THING_TYPE_SHELLYPROTECTED_STR = "shellydevice"; @@ -316,6 +324,7 @@ public class ShellyThingCreator { public static final ThingTypeUID THING_TYPE_SHELLYBLUDW = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYBLUDW_STR); public static final ThingTypeUID THING_TYPE_SHELLYBLUMOTION = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYBLUMOTION_STR); + public static final ThingTypeUID THING_TYPE_SHELLYBLUGW = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYBLUGW_STR); private static final Map THING_TYPE_MAPPING = new LinkedHashMap<>(); static { @@ -323,6 +332,8 @@ public class ShellyThingCreator { THING_TYPE_MAPPING.put(SHELLYDT_1PM, THING_TYPE_SHELLY1PM_STR); THING_TYPE_MAPPING.put(SHELLYDT_1L, THING_TYPE_SHELLY1L_STR); THING_TYPE_MAPPING.put(SHELLYDT_1, THING_TYPE_SHELLY1_STR); + THING_TYPE_MAPPING.put(SHELLYDT_SHPRO, THING_TYPE_SHELLY4PRO_STR); + THING_TYPE_MAPPING.put(SHELLYDT_4PRO, THING_TYPE_SHELLY4PRO_STR); THING_TYPE_MAPPING.put(SHELLYDT_3EM, THING_TYPE_SHELLY3EM_STR); THING_TYPE_MAPPING.put(SHELLYDT_EM, THING_TYPE_SHELLYEM_STR); THING_TYPE_MAPPING.put(SHELLYDT_SHPLG_S, THING_TYPE_SHELLYPLUGS_STR); @@ -368,6 +379,9 @@ public class ShellyThingCreator { THING_TYPE_MAPPING.put(SHELLYDT_MINI1, THING_TYPE_SHELLYMINI1_STR); THING_TYPE_MAPPING.put(SHELLYDT_MINIPM, THING_TYPE_SHELLYMINIPM_STR); THING_TYPE_MAPPING.put(SHELLYDT_MINI1PM, THING_TYPE_SHELLYMINI1PM_STR); + THING_TYPE_MAPPING.put(SHELLYDT_MINI1G3_1, THING_TYPE_SHELLYMINI1_STR); + THING_TYPE_MAPPING.put(SHELLYDT_MINIG3_PM, THING_TYPE_SHELLYMINIPM_STR); + THING_TYPE_MAPPING.put(SHELLYDT_MINIG3_1PM, THING_TYPE_SHELLYMINI1PM_STR); // Pro Series THING_TYPE_MAPPING.put(SHELLYDT_PRO1, THING_TYPE_SHELLYPRO1_STR); @@ -395,6 +409,7 @@ public class ShellyThingCreator { THING_TYPE_MAPPING.put(SHELLYDT_BLUBUTTON, THING_TYPE_SHELLYBLUBUTTON_STR); THING_TYPE_MAPPING.put(SHELLYDT_BLUDW, THING_TYPE_SHELLYBLUDW_STR); THING_TYPE_MAPPING.put(SHELLYDT_BLUMOTION, THING_TYPE_SHELLYBLUMOTION_STR); + THING_TYPE_MAPPING.put(SHELLYDT_BLUGW, THING_TYPE_SHELLYBLUGW_STR); // Wall displays THING_TYPE_MAPPING.put(SHELLYDT_PLUSWALLDISPLAY, THING_TYPE_SHELLYPLUSWALLDISPLAY_STR); diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java index 64eac84506..08e73cb782 100755 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java @@ -150,7 +150,7 @@ public abstract class ShellyBaseHandler extends BaseThingHandler Map properties = thing.getProperties(); String gen = getString(properties.get(PROPERTY_DEV_GEN)); String thingType = getThingType(); - gen2 = "2".equals(gen) || ShellyDeviceProfile.isGeneration2(thingType); + gen2 = "2".equals(gen) || "3".equals(gen) || ShellyDeviceProfile.isGeneration2(thingType); blu = ShellyDeviceProfile.isBluSeries(thingType); this.api = !blu ? !gen2 ? new Shelly1HttpApi(thingName, this) : new Shelly2ApiRpc(thingName, thingTable, this) : new ShellyBluApi(thingName, thingTable, this); @@ -703,10 +703,6 @@ public abstract class ShellyBaseHandler extends BaseThingHandler return false; } - private boolean isWatchdogStarted() { - return watchdog > 0; - } - @Override public void reinitializeThing() { logger.debug("{}: Re-Initialize Thing", thingName); diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/manager/ShellyManagerPage.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/manager/ShellyManagerPage.java index ca1ca3a92c..8612f96657 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/manager/ShellyManagerPage.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/manager/ShellyManagerPage.java @@ -588,11 +588,12 @@ public class ShellyManagerPage { timer.schedule(task, delay * 1000); } - protected Map getThingHandlers() { + protected @Nullable Map getThingHandlers() { return handlerFactory.getThingHandlers(); } protected @Nullable ShellyManagerInterface getThingHandler(String uid) { - return getThingHandlers().get(uid); + Map th = getThingHandlers(); + return th != null ? th.get(uid) : null; } } diff --git a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/config/configblu.xml b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/config/configblu.xml index 7886954bd6..c46e22faa3 100644 --- a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/config/configblu.xml +++ b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/config/configblu.xml @@ -7,14 +7,31 @@ - @text/thing-type.config.shelly.deviceAddress.description + + @text/thing-type.config.shelly.deviceAddress.description - @text/thing-type.config.shelly.battery.lowBattery.description + + @text/thing-type.config.shelly.battery.lowBattery.description 20 % + + + + @text/thing-type.config.shelly.deviceIp.description + network-address + + + + + + @text/thing-type.config.shelly.enableBluGateway.description + true + + + diff --git a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties index 91e71dece6..987c3e5089 100644 --- a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties +++ b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties @@ -103,9 +103,9 @@ thing-type.shelly.shellypluswdus.description = Shelly Wall Dimmer US Device thing-type.shelly.shellyplus10v.description = Shelly Plus Dimmer 10V # Plus Mini Devices -thing-type.shelly.shellyplusmini1.description = Shelly Plus Mini 1 - Single Relay Switch -thing-type.shelly.shellyplusminipm.description = Shelly Plus Mini PM - Power Meter -thing-type.shelly.shellyplusmini1pm.description = Shelly Plus Mini 1PM - Single Relay Switch with Power Meter +thing-type.shelly.shellymini1.description = Shelly Plus Mini 1 - Single Relay Switch +thing-type.shelly.shellyminipm.description = Shelly Plus Mini PM - Power Meter +thing-type.shelly.shellymini1pm.description = Shelly Plus Mini 1PM - Single Relay Switch with Power Meter # Pro Devices thing-type.shelly.shellypro1.description = Shelly Pro 1 - Single Relay Switch @@ -122,6 +122,7 @@ thing-type.shelly.shellypro4pm.description = Shelly Pro 4PM - 4xRelay Switch wit thing-type.shelly.shellyblubutton.description = Shelly BLU Button 1 thing-type.shelly.shellybludw.description = Shelly BLU Door/Window Sensor thing-type.shelly.shellyblumotion.description = Shelly BLU Motion Sensor +thing-type.shelly.shellyblugw.description = Shelly BLU Gateway # Wall Displays thing-type.shelly.shellywalldisplay.description = Shelly Wall Display with sensors and input/output @@ -138,7 +139,7 @@ thing-type.config.shelly.password.description = Password for API access thing-type.config.shelly.updateInterval.label = Status Interval thing-type.config.shelly.updateInterval.description = Interval for the device status update thing-type.config.shelly.enableBluGateway.label = Enable BLU Gateway Support -thing-type.config.shelly.enableBluGateway.description = Enables BLU Gateway support incl- auto-upload of the required script +thing-type.config.shelly.enableBluGateway.description = Enables BLU Gateway support including auto-upload of the required script thing-type.config.shelly.eventsButton.label = Button Events thing-type.config.shelly.eventsButton.description = Activates the Button Action URLS thing-type.config.shelly.eventsPush.label = Push Events diff --git a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyBlu.xml b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyBlu.xml new file mode 100644 index 0000000000..47afe21774 --- /dev/null +++ b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyBlu.xml @@ -0,0 +1,60 @@ + + + + + + @text/thing-type.shelly.shellyblubutton.description + WallSwitch + + + + + + + serviceName + + + + + + @text/thing-type.shelly.shellybludw.description + Sensor + + + + + + + serviceName + + + + + + @text/thing-type.shelly.shellyblumotion.description + Sensor + + + + + + + serviceName + + + + + + @text/thing-type.shelly.shellyblugw.description + + + + + serviceName + + + + diff --git a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyBlu_sensor.xml b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyBlu_sensor.xml deleted file mode 100644 index d809f57280..0000000000 --- a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyBlu_sensor.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - @text/thing-type.shelly.shellyblubutton.description - WallSwitch - - - - - - - serviceName - - - - - - @text/thing-type.shelly.shellybludw.description - Sensor - - - - - - - serviceName - - - - - - @text/thing-type.shelly.shellyblumotion.description - Sensor - - - - - - - serviceName - - -