Skip to content

Commit 3fb5e66

Browse files
authoredFeb 4, 2024
Support for Shelly Plus Mini Gen 3 series of devices, Shelly Plus UNI (openhab#16335)
and Shelly BLU Gateway. Signed-off-by: Markus Michels <markus7017@gmail.com>
1 parent dd38c23 commit 3fb5e66

File tree

12 files changed

+88
-28
lines changed

12 files changed

+88
-28
lines changed
 

‎bundles/org.openhab.binding.shelly/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ Also check out the [Shelly Manager](doc/ShellyManager.md), which
2828
The binding supports both hardware generations
2929

3030
- Generation 1: The original Shelly devices like the Shelly 1, Shelly 2.5, Shelly Flood etc.
31-
- Generation 2: The new Plus / Pro series of devices
32-
- Shelly Plus Mini: Shelly Plus devices in compact format
31+
- Generation 2: Plus / Pro series of devices
32+
- Shelly Plus Mini: Shelly Plus devices in compact format (Gen 2+3)
3333
- Shelly BLU: Bluetooth based series of devices
3434

3535
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
9595
| shellypluswdus | Shelly Plus Wall Dimmer US | SNDM-0013US |
9696
| shellywalldisplay | Shelly Plus Wall Display | SAWD-0A1XX10EU1 |
9797

98-
### Generation 2 Plus Mini series
98+
### Generation 2 Plus Mini series (incl. Gen 3)
9999

100-
| thing-type | Model | Vendor ID |
101-
| -------------------- | -------------------------------------------------------- | ---------------------------- |
102-
| shellymini1 | Shelly Plus 1 Mini with 1x relay | SNSW-001X8EU |
103-
| shellymini1pm | Shelly Plus 1PM Mini with 1x relay + power meter | SNSW-001P8EU |
104-
| shellyminipm | Shelly Plus PM Mini with 1x power meter | SNPM-001PCEU16 |
100+
| thing-type | Model | Vendor ID |
101+
| -------------------- | -------------------------------------------------------- | ------------------------------ |
102+
| shellymini1 | Shelly Plus 1 Mini with 1x relay | SNSW-001X8EU, S3SW-001X8EU |
103+
| shellymini1pm | Shelly Plus 1PM Mini with 1x relay + power meter | SNSW-001P8EU, S3SW-001P8EU |
104+
| shellyminipm | Shelly Plus PM Mini with 1x power meter | SNPM-001PCEU16, S3PM-001PCEU16 |
105105

106106
### Generation 2 Pro series
107107

‎bundles/org.openhab.binding.shelly/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
</properties>
1616

1717
<artifactId>org.openhab.binding.shelly</artifactId>
18-
<name>openHAB Add-ons :: Bundles :: Shelly Binding Gen1+2</name>
18+
<name>openHAB Add-ons :: Bundles :: Shelly Binding</name>
1919

2020
</project>

‎bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public class ShellyBindingConstants {
104104
THING_TYPE_SHELLYBLUBUTTON, //
105105
THING_TYPE_SHELLYBLUDW, //
106106
THING_TYPE_SHELLYBLUMOTION, //
107+
THING_TYPE_SHELLYBLUGW, //
107108

108109
THING_TYPE_SHELLYPROTECTED, //
109110
THING_TYPE_SHELLYUNKNOWN);

‎bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,12 @@ public static String extractFwVersion(@Nullable String version) {
403403
}
404404

405405
public static boolean isGeneration2(String thingType) {
406-
return thingType.startsWith("shellyplus") || thingType.startsWith("shellypro")
407-
|| thingType.startsWith("shellymini") || isBluSeries(thingType);
406+
return thingType.startsWith("shellyplus") || thingType.startsWith("shellypro") || thingType.contains("mini")
407+
|| isBluSeries(thingType);
408408
}
409409

410410
public static boolean isBluSeries(String thingType) {
411-
return thingType.startsWith("shellyblu");
411+
return thingType.startsWith("shellyblu") && !thingType.startsWith(THING_TYPE_SHELLYBLUGW_STR);
412412
}
413413

414414
public boolean coiotEnabled() {

‎bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api2/Shelly2ApiJsonDTO.java

+15
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,26 @@ public class Shelly2DeviceConfigWiFi {
521521
}
522522

523523
public static class Shelly2DeviceStatus {
524+
public class Shelly2InputCounts {
525+
public Integer total;
526+
@SerializedName("by_minute")
527+
public Double[] byMinute;
528+
public Double xtotal;
529+
@SerializedName("xby_minute")
530+
public Double[] xbyMinute;
531+
@SerializedName("minute_ts")
532+
public Integer minuteTS;
533+
}
534+
524535
public class Shelly2InputStatus {
525536
public Integer id;
526537
public Boolean state;
527538
public Double percent; // analog input only
528539
public ArrayList<String> errors;// shown only if at least one error is present.
540+
public Double xpercent;
541+
public Shelly2InputCounts counts;
542+
public Double freq;
543+
public Double xfreq;
529544
}
530545

531546
public static class Shelly2DeviceStatusLight {

‎bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ public DiscoveryResult createResult(final ServiceInfo service) {
143143
config.userId = bindingConfig.defaultUserId;
144144
config.password = bindingConfig.defaultPassword;
145145

146-
boolean gen2 = "2".equals(service.getPropertyString("gen"));
146+
String gen = getString(service.getPropertyString("gen"));
147+
boolean gen2 = "2".equals(gen) || "3".equals(gen);
147148
ShellyApiInterface api = null;
148149
boolean auth = false;
149150
ShellySettingsDevice devInfo;
@@ -152,7 +153,8 @@ public DiscoveryResult createResult(final ServiceInfo service) {
152153
api.initialize();
153154
devInfo = api.getDeviceInfo();
154155
model = devInfo.type;
155-
auth = devInfo.auth;
156+
gen2 = !(devInfo.gen == 1); // gen 2+3
157+
auth = getBool(devInfo.auth);
156158
if (devInfo.name != null) {
157159
deviceName = devInfo.name;
158160
}

‎bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class ShellyThingCreator {
4040
public static final String SHELLYDT_SHELLY2 = "SHSW-21";
4141
public static final String SHELLYDT_SHELLY25 = "SHSW-25";
4242
public static final String SHELLYDT_SHPRO = "SHSW-44";
43+
public static final String SHELLYDT_4PRO = "SHPSW04P";
4344
public static final String SHELLYDT_EM = "SHEM";
4445
public static final String SHELLYDT_3EM = "SHEM-3";
4546
public static final String SHELLYDT_HT = "SHHT-1";
@@ -79,6 +80,7 @@ public class ShellyThingCreator {
7980
public static final String SHELLYDT_PLUSI4DC = "SNSN-0D24X";
8081
public static final String SHELLYDT_PLUSHT = "SNSN-0013A";
8182
public static final String SHELLYDT_PLUSSMOKE = "SNSN-0031Z";
83+
public static final String SHELLYDT_PLUSUNI = "SNSN-0043X";
8284
public static final String SHELLYDT_PLUSDIMMERUS = "SNDM-0013US";
8385
public static final String SHELLYDT_PLUSDIMMER10V = "SNGW-0A11WW010";
8486
public static final String SHELLYDT_PLUSWALLDISPLAY = "SAWD-0A1XX10EU1";
@@ -106,15 +108,20 @@ public class ShellyThingCreator {
106108
public static final String SHELLYDT_PRO4PM_2 = "SPSW-104PE16EU";
107109

108110
// Shelly Plus Mini Series
109-
// Shelly Mini Series
111+
// Mini Generation 2
110112
public static final String SHELLYDT_MINI1 = "SNSW-001X8EU";
111113
public static final String SHELLYDT_MINIPM = "SNPM-001PCEU16";
112114
public static final String SHELLYDT_MINI1PM = "SNSW-001P8EU";
115+
// Mini Generation 3
116+
public static final String SHELLYDT_MINI1G3_1 = "S3SW-001X8EU";
117+
public static final String SHELLYDT_MINIG3_PM = "S3PM-001PCEU16";
118+
public static final String SHELLYDT_MINIG3_1PM = "S3SW-001P8EU";
113119

114120
// Shelly BLU Series
115121
public static final String SHELLYDT_BLUBUTTON = "SBBT";
116122
public static final String SHELLYDT_BLUDW = "SBDW";
117123
public static final String SHELLYDT_BLUMOTION = "SBMO";
124+
public static final String SHELLYDT_BLUGW = "SNGW-BT01";
118125

119126
// Thing names
120127
public static final String THING_TYPE_SHELLY1_STR = "shelly1";
@@ -195,6 +202,7 @@ public class ShellyThingCreator {
195202
public static final String THING_TYPE_SHELLYBLUBUTTON_STR = THING_TYPE_SHELLYBLU_PREFIX + "button";
196203
public static final String THING_TYPE_SHELLYBLUDW_STR = THING_TYPE_SHELLYBLU_PREFIX + "dw";
197204
public static final String THING_TYPE_SHELLYBLUMOTION_STR = THING_TYPE_SHELLYBLU_PREFIX + "motion";
205+
public static final String THING_TYPE_SHELLYBLUGW_STR = THING_TYPE_SHELLYBLU_PREFIX + "gw";
198206

199207
// Password protected or unknown device
200208
public static final String THING_TYPE_SHELLYPROTECTED_STR = "shellydevice";
@@ -316,13 +324,16 @@ public class ShellyThingCreator {
316324
public static final ThingTypeUID THING_TYPE_SHELLYBLUDW = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYBLUDW_STR);
317325
public static final ThingTypeUID THING_TYPE_SHELLYBLUMOTION = new ThingTypeUID(BINDING_ID,
318326
THING_TYPE_SHELLYBLUMOTION_STR);
327+
public static final ThingTypeUID THING_TYPE_SHELLYBLUGW = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYBLUGW_STR);
319328

320329
private static final Map<String, String> THING_TYPE_MAPPING = new LinkedHashMap<>();
321330
static {
322331
// mapping by device type id
323332
THING_TYPE_MAPPING.put(SHELLYDT_1PM, THING_TYPE_SHELLY1PM_STR);
324333
THING_TYPE_MAPPING.put(SHELLYDT_1L, THING_TYPE_SHELLY1L_STR);
325334
THING_TYPE_MAPPING.put(SHELLYDT_1, THING_TYPE_SHELLY1_STR);
335+
THING_TYPE_MAPPING.put(SHELLYDT_SHPRO, THING_TYPE_SHELLY4PRO_STR);
336+
THING_TYPE_MAPPING.put(SHELLYDT_4PRO, THING_TYPE_SHELLY4PRO_STR);
326337
THING_TYPE_MAPPING.put(SHELLYDT_3EM, THING_TYPE_SHELLY3EM_STR);
327338
THING_TYPE_MAPPING.put(SHELLYDT_EM, THING_TYPE_SHELLYEM_STR);
328339
THING_TYPE_MAPPING.put(SHELLYDT_SHPLG_S, THING_TYPE_SHELLYPLUGS_STR);
@@ -368,6 +379,9 @@ public class ShellyThingCreator {
368379
THING_TYPE_MAPPING.put(SHELLYDT_MINI1, THING_TYPE_SHELLYMINI1_STR);
369380
THING_TYPE_MAPPING.put(SHELLYDT_MINIPM, THING_TYPE_SHELLYMINIPM_STR);
370381
THING_TYPE_MAPPING.put(SHELLYDT_MINI1PM, THING_TYPE_SHELLYMINI1PM_STR);
382+
THING_TYPE_MAPPING.put(SHELLYDT_MINI1G3_1, THING_TYPE_SHELLYMINI1_STR);
383+
THING_TYPE_MAPPING.put(SHELLYDT_MINIG3_PM, THING_TYPE_SHELLYMINIPM_STR);
384+
THING_TYPE_MAPPING.put(SHELLYDT_MINIG3_1PM, THING_TYPE_SHELLYMINI1PM_STR);
371385

372386
// Pro Series
373387
THING_TYPE_MAPPING.put(SHELLYDT_PRO1, THING_TYPE_SHELLYPRO1_STR);
@@ -395,6 +409,7 @@ public class ShellyThingCreator {
395409
THING_TYPE_MAPPING.put(SHELLYDT_BLUBUTTON, THING_TYPE_SHELLYBLUBUTTON_STR);
396410
THING_TYPE_MAPPING.put(SHELLYDT_BLUDW, THING_TYPE_SHELLYBLUDW_STR);
397411
THING_TYPE_MAPPING.put(SHELLYDT_BLUMOTION, THING_TYPE_SHELLYBLUMOTION_STR);
412+
THING_TYPE_MAPPING.put(SHELLYDT_BLUGW, THING_TYPE_SHELLYBLUGW_STR);
398413

399414
// Wall displays
400415
THING_TYPE_MAPPING.put(SHELLYDT_PLUSWALLDISPLAY, THING_TYPE_SHELLYPLUSWALLDISPLAY_STR);

‎bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public ShellyBaseHandler(final Thing thing, final ShellyTranslationProvider tran
150150
Map<String, String> properties = thing.getProperties();
151151
String gen = getString(properties.get(PROPERTY_DEV_GEN));
152152
String thingType = getThingType();
153-
gen2 = "2".equals(gen) || ShellyDeviceProfile.isGeneration2(thingType);
153+
gen2 = "2".equals(gen) || "3".equals(gen) || ShellyDeviceProfile.isGeneration2(thingType);
154154
blu = ShellyDeviceProfile.isBluSeries(thingType);
155155
this.api = !blu ? !gen2 ? new Shelly1HttpApi(thingName, this) : new Shelly2ApiRpc(thingName, thingTable, this)
156156
: new ShellyBluApi(thingName, thingTable, this);
@@ -703,10 +703,6 @@ private boolean isWatchdogExpired() {
703703
return false;
704704
}
705705

706-
private boolean isWatchdogStarted() {
707-
return watchdog > 0;
708-
}
709-
710706
@Override
711707
public void reinitializeThing() {
712708
logger.debug("{}: Re-Initialize Thing", thingName);

‎bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/manager/ShellyManagerPage.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,12 @@ public void run() {
588588
timer.schedule(task, delay * 1000);
589589
}
590590

591-
protected Map<String, ShellyManagerInterface> getThingHandlers() {
591+
protected @Nullable Map<String, ShellyManagerInterface> getThingHandlers() {
592592
return handlerFactory.getThingHandlers();
593593
}
594594

595595
protected @Nullable ShellyManagerInterface getThingHandler(String uid) {
596-
return getThingHandlers().get(uid);
596+
Map<String, ShellyManagerInterface> th = getThingHandlers();
597+
return th != null ? th.get(uid) : null;
597598
}
598599
}

‎bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/config/configblu.xml

+19-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,31 @@
77
<config-description uri="thing-type:shelly:blubattery">
88
<parameter name="deviceAddress" type="text" required="true">
99
<label>@text/thing-type.config.shelly.deviceAddress.label</label>
10-
<description>@text/thing-type.config.shelly.deviceAddress.description</description>
10+
<description>
11+
@text/thing-type.config.shelly.deviceAddress.description</description>
1112
</parameter>
1213
<parameter name="lowBattery" type="integer" required="false">
1314
<label>@text/thing-type.config.shelly.battery.lowBattery.label</label>
14-
<description>@text/thing-type.config.shelly.battery.lowBattery.description</description>
15+
<description>
16+
@text/thing-type.config.shelly.battery.lowBattery.description</description>
1517
<default>20</default>
1618
<unitLabel>%</unitLabel>
1719
</parameter>
1820
</config-description>
1921

22+
<config-description uri="thing-type:shelly:blugw">
23+
<parameter name="deviceIp" type="text" required="true">
24+
<label>@text/thing-type.config.shelly.deviceIp.label</label>
25+
<description>@text/thing-type.config.shelly.deviceIp.description</description>
26+
<context>network-address</context>
27+
</parameter>
28+
29+
<parameter name="enableBluGateway" type="boolean" required="false">
30+
<label>@text/thing-type.config.shelly.enableBluGateway.label</label>
31+
<description>
32+
@text/thing-type.config.shelly.enableBluGateway.description</description>
33+
<default>true</default>
34+
</parameter>
35+
</config-description>
36+
2037
</config-description:config-descriptions>

‎bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties

+5-4
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ thing-type.shelly.shellypluswdus.description = Shelly Wall Dimmer US Device
103103
thing-type.shelly.shellyplus10v.description = Shelly Plus Dimmer 10V
104104

105105
# Plus Mini Devices
106-
thing-type.shelly.shellyplusmini1.description = Shelly Plus Mini 1 - Single Relay Switch
107-
thing-type.shelly.shellyplusminipm.description = Shelly Plus Mini PM - Power Meter
108-
thing-type.shelly.shellyplusmini1pm.description = Shelly Plus Mini 1PM - Single Relay Switch with Power Meter
106+
thing-type.shelly.shellymini1.description = Shelly Plus Mini 1 - Single Relay Switch
107+
thing-type.shelly.shellyminipm.description = Shelly Plus Mini PM - Power Meter
108+
thing-type.shelly.shellymini1pm.description = Shelly Plus Mini 1PM - Single Relay Switch with Power Meter
109109

110110
# Pro Devices
111111
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
122122
thing-type.shelly.shellyblubutton.description = Shelly BLU Button 1
123123
thing-type.shelly.shellybludw.description = Shelly BLU Door/Window Sensor
124124
thing-type.shelly.shellyblumotion.description = Shelly BLU Motion Sensor
125+
thing-type.shelly.shellyblugw.description = Shelly BLU Gateway
125126

126127
# Wall Displays
127128
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
138139
thing-type.config.shelly.updateInterval.label = Status Interval
139140
thing-type.config.shelly.updateInterval.description = Interval for the device status update
140141
thing-type.config.shelly.enableBluGateway.label = Enable BLU Gateway Support
141-
thing-type.config.shelly.enableBluGateway.description = Enables BLU Gateway support incl- auto-upload of the required script
142+
thing-type.config.shelly.enableBluGateway.description = Enables BLU Gateway support including auto-upload of the required script
142143
thing-type.config.shelly.eventsButton.label = Button Events
143144
thing-type.config.shelly.eventsButton.description = Activates the Button Action URLS
144145
thing-type.config.shelly.eventsPush.label = Push Events

‎bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyBlu_sensor.xml ‎bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyBlu.xml

+12
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,16 @@
4545
<representation-property>serviceName</representation-property>
4646
<config-description-ref uri="thing-type:shelly:blubattery"/>
4747
</thing-type>
48+
49+
<thing-type id="shellyblugw">
50+
<label>Shelly BLU Gateway</label>
51+
<description>@text/thing-type.shelly.shellyblugw.description</description>
52+
<channel-groups>
53+
<channel-group id="device" typeId="deviceStatus"/>
54+
</channel-groups>
55+
56+
<representation-property>serviceName</representation-property>
57+
<config-description-ref uri="thing-type:shelly:blugw"/>
58+
</thing-type>
59+
4860
</thing:thing-descriptions>

0 commit comments

Comments
 (0)
Please sign in to comment.