mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[shelly] Adaption to OH3, Shelly Plug US, minor fixes (#8642)
* OH3 adaption - fixes small issues when running on OH3 * #8612: Fix total consumption for RGW2+Roller * #8492: Shelly Plug US * 2 more immediate = true catched and removed * spotless applied Signed-off-by: Markus Michels <markus7017@gmail.com>
This commit is contained in:
parent
9c6c80d41f
commit
ff4d97eb2a
26
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java
Normal file → Executable file
26
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java
Normal file → Executable file
@ -47,6 +47,7 @@ public class ShellyBindingConstants {
|
||||
public static final String THING_TYPE_SHELLY4PRO_STR = "shelly4pro";
|
||||
public static final String THING_TYPE_SHELLYPLUG_STR = "shellyplug";
|
||||
public static final String THING_TYPE_SHELLYPLUGS_STR = "shellyplugs";
|
||||
public static final String THING_TYPE_SHELLYPLUGU1_STR = "shellyplugu1"; // Shely Plug US
|
||||
public static final String THING_TYPE_SHELLYDIMMER_STR = "shellydimmer";
|
||||
public static final String THING_TYPE_SHELLYDIMMER2_STR = "shellydimmer2";
|
||||
public static final String THING_TYPE_SHELLYIX3_STR = "shellyix3";
|
||||
@ -73,6 +74,7 @@ public class ShellyBindingConstants {
|
||||
public static final String SHELLYDT_1PM = "SHSW-PM";
|
||||
public static final String SHELLYDT_SHPLG = "SHPLG-1";
|
||||
public static final String SHELLYDT_SHPLG_S = "SHPLG-S";
|
||||
public static final String SHELLYDT_SHPLG_U1 = "SHPLG-U1";
|
||||
public static final String SHELLYDT_SHELLY2 = "SHSW-21";
|
||||
public static final String SHELLYDT_SHELLY25 = "SHSW-25";
|
||||
public static final String SHELLYDT_SHPRO = "SHSW-44";
|
||||
@ -108,6 +110,8 @@ public class ShellyBindingConstants {
|
||||
public static final ThingTypeUID THING_TYPE_SHELLY4PRO = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLY4PRO_STR);
|
||||
public static final ThingTypeUID THING_TYPE_SHELLYPLUG = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPLUG_STR);
|
||||
public static final ThingTypeUID THING_TYPE_SHELLYPLUGS = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPLUGS_STR);
|
||||
public static final ThingTypeUID THING_TYPE_SHELLYPLUGU1 = new ThingTypeUID(BINDING_ID,
|
||||
THING_TYPE_SHELLYPLUGU1_STR);
|
||||
public static final ThingTypeUID THING_TYPE_SHELLYDIMMER = new ThingTypeUID(BINDING_ID,
|
||||
THING_TYPE_SHELLYDIMMER_STR);
|
||||
public static final ThingTypeUID THING_TYPE_SHELLYDIMMER2 = new ThingTypeUID(BINDING_ID,
|
||||
@ -138,18 +142,16 @@ public class ShellyBindingConstants {
|
||||
public static final ThingTypeUID THING_TYPE_SHELLYUNKNOWN = new ThingTypeUID(BINDING_ID,
|
||||
THING_TYPE_SHELLYUNKNOWN_STR);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
|
||||
.unmodifiableSet(Stream
|
||||
.of(THING_TYPE_SHELLY1, THING_TYPE_SHELLY1PM, THING_TYPE_SHELLYEM, THING_TYPE_SHELLY3EM,
|
||||
THING_TYPE_SHELLY2_RELAY, THING_TYPE_SHELLY2_ROLLER, THING_TYPE_SHELLY25_RELAY,
|
||||
THING_TYPE_SHELLY25_ROLLER, THING_TYPE_SHELLY4PRO, THING_TYPE_SHELLYPLUG,
|
||||
THING_TYPE_SHELLYPLUGS, THING_TYPE_SHELLYDIMMER, THING_TYPE_SHELLYDIMMER2,
|
||||
THING_TYPE_SHELLYIX3, THING_TYPE_SHELLYBULB, THING_TYPE_SHELLYDUO, THING_TYPE_SHELLYVINTAGE,
|
||||
THING_TYPE_SHELLYRGBW2_COLOR, THING_TYPE_SHELLYRGBW2_WHITE, THING_TYPE_SHELLYHT,
|
||||
THING_TYPE_SHELLYSENSE, THING_TYPE_SHELLYEYE, THING_TYPE_SHELLYSMOKE, THING_TYPE_SHELLYGAS,
|
||||
THING_TYPE_SHELLYFLOOD, THING_TYPE_SHELLYDOORWIN, THING_TYPE_SHELLYDOORWIN2,
|
||||
THING_TYPE_SHELLYBUTTON1, THING_TYPE_SHELLYPROTECTED, THING_TYPE_SHELLYUNKNOWN)
|
||||
.collect(Collectors.toSet()));
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet(
|
||||
Stream.of(THING_TYPE_SHELLY1, THING_TYPE_SHELLY1PM, THING_TYPE_SHELLYEM, THING_TYPE_SHELLY3EM,
|
||||
THING_TYPE_SHELLY2_RELAY, THING_TYPE_SHELLY2_ROLLER, THING_TYPE_SHELLY25_RELAY,
|
||||
THING_TYPE_SHELLY25_ROLLER, THING_TYPE_SHELLY4PRO, THING_TYPE_SHELLYPLUG, THING_TYPE_SHELLYPLUGS,
|
||||
THING_TYPE_SHELLYPLUGU1, THING_TYPE_SHELLYDIMMER, THING_TYPE_SHELLYDIMMER2, THING_TYPE_SHELLYIX3,
|
||||
THING_TYPE_SHELLYBULB, THING_TYPE_SHELLYDUO, THING_TYPE_SHELLYVINTAGE, THING_TYPE_SHELLYRGBW2_COLOR,
|
||||
THING_TYPE_SHELLYRGBW2_WHITE, THING_TYPE_SHELLYHT, THING_TYPE_SHELLYSENSE, THING_TYPE_SHELLYEYE,
|
||||
THING_TYPE_SHELLYSMOKE, THING_TYPE_SHELLYGAS, THING_TYPE_SHELLYFLOOD, THING_TYPE_SHELLYDOORWIN,
|
||||
THING_TYPE_SHELLYDOORWIN2, THING_TYPE_SHELLYBUTTON1, THING_TYPE_SHELLYPROTECTED,
|
||||
THING_TYPE_SHELLYUNKNOWN).collect(Collectors.toSet()));
|
||||
|
||||
// Thing Configuration Properties
|
||||
public static final String CONFIG_DEVICEIP = "deviceIp";
|
||||
|
0
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyHandlerFactory.java
Normal file → Executable file
0
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyHandlerFactory.java
Normal file → Executable file
@ -237,7 +237,7 @@ public class ShellyCoapHandler implements ShellyCoapListener {
|
||||
reqStatus = sendRequest(reqStatus, config.deviceIp, COLOIT_URI_DEVSTATUS, Type.NON);
|
||||
discovering = true;
|
||||
}
|
||||
} catch (IllegalArgumentException | NullPointerException e) {
|
||||
} catch (JsonSyntaxException | IllegalArgumentException | NullPointerException e) {
|
||||
logger.debug("{}: Unable to process CoIoT Message for payload={}", thingName, payload, e);
|
||||
resetSerial();
|
||||
}
|
||||
|
0
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/config/ShellyThingConfiguration.java
Normal file → Executable file
0
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/config/ShellyThingConfiguration.java
Normal file → Executable file
2
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java
Normal file → Executable file
2
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java
Normal file → Executable file
@ -186,7 +186,7 @@ public class ShellyDiscoveryParticipant implements MDNSDiscoveryParticipant {
|
||||
String thingLabel = deviceName.isEmpty() ? name + " - " + address
|
||||
: deviceName + " (" + name + "@" + address + ")";
|
||||
return DiscoveryResultBuilder.create(thingUID).withProperties(properties).withLabel(thingLabel)
|
||||
.withRepresentationProperty(name).build();
|
||||
.withRepresentationProperty(PROPERTY_DEV_NAME).build();
|
||||
}
|
||||
} catch (IOException | NullPointerException e) {
|
||||
// maybe some format description was buggy
|
||||
|
@ -32,11 +32,13 @@ import org.openhab.core.thing.ThingUID;
|
||||
public class ShellyThingCreator {
|
||||
private static final Map<String, String> THING_TYPE_MAPPING = new LinkedHashMap<>();
|
||||
static {
|
||||
// mapping by thing type
|
||||
// mapping by device type id
|
||||
THING_TYPE_MAPPING.put(SHELLYDT_1PM, THING_TYPE_SHELLY1PM_STR);
|
||||
THING_TYPE_MAPPING.put(SHELLYDT_1, THING_TYPE_SHELLY1_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);
|
||||
THING_TYPE_MAPPING.put(SHELLYDT_SHPLG_U1, THING_TYPE_SHELLYPLUGU1_STR);
|
||||
THING_TYPE_MAPPING.put(SHELLYDT_GAS, THING_TYPE_SHELLYGAS_STR);
|
||||
THING_TYPE_MAPPING.put(SHELLYDT_DW, THING_TYPE_SHELLYDOORWIN_STR);
|
||||
THING_TYPE_MAPPING.put(SHELLYDT_DW2, THING_TYPE_SHELLYDOORWIN2_STR);
|
||||
@ -112,6 +114,9 @@ public class ShellyThingCreator {
|
||||
if (name.startsWith(THING_TYPE_SHELLYPLUGS_STR) || name.contains("-s")) {
|
||||
return THING_TYPE_SHELLYPLUGS_STR;
|
||||
}
|
||||
if (name.startsWith(THING_TYPE_SHELLYPLUGU1_STR)) {
|
||||
return THING_TYPE_SHELLYPLUGU1_STR;
|
||||
}
|
||||
return THING_TYPE_SHELLYPLUG_STR;
|
||||
}
|
||||
if (name.startsWith(THING_TYPE_SHELLYRGBW2_PREFIX)) {
|
||||
|
0
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java
Normal file → Executable file
0
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java
Normal file → Executable file
@ -207,7 +207,7 @@ public class ShellyComponents {
|
||||
toQuantityType(getDouble(lastMin1), DIGITS_WATT, SmartHomeUnits.WATT));
|
||||
|
||||
// convert totalWatts into kw/h
|
||||
totalWatts = totalWatts / (60.0 * 10000.0);
|
||||
totalWatts = totalWatts / (60.0 * 1000.0);
|
||||
updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_CURRENTWATTS,
|
||||
toQuantityType(getDouble(currentWatts), DIGITS_WATT, SmartHomeUnits.WATT));
|
||||
updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_TOTALKWH,
|
||||
|
@ -465,7 +465,7 @@ channel-type.shelly.colorEffectRGBW2.option.1 = Meteoritenregen
|
||||
channel-type.shelly.colorEffectRGBW2.option.2 = Farbverlauf
|
||||
channel-type.shelly.colorEffectRGBW2.option.3 = Blitzen
|
||||
channel-type.shelly.sensorTemp.label = Temperatur
|
||||
channel-type.shelly.sensorTemp.description = Aktuelle Temperatur des Sensors in ∞C
|
||||
channel-type.shelly.sensorTemp.description = Aktuelle Temperatur des Sensors in °C
|
||||
channel-type.shelly.sensorExtTemp.label = Temperatur
|
||||
channel-type.shelly.sensorExtTemp.description = Aktuelle Temperatur des externen Sensors in ∞C
|
||||
channel-type.shelly.sensorExtHum.label = Luftfeuchtigkeit
|
||||
|
@ -14,6 +14,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:light"/>
|
||||
</thing-type>
|
||||
|
||||
@ -27,6 +28,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:light"/>
|
||||
</thing-type>
|
||||
|
||||
@ -40,6 +42,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:light"/>
|
||||
</thing-type>
|
||||
|
||||
@ -54,6 +57,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:rgbw2"/>
|
||||
</thing-type>
|
||||
|
||||
@ -78,6 +82,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:rgbw2"/>
|
||||
</thing-type>
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:relay"/>
|
||||
</thing-type>
|
||||
|
||||
@ -26,6 +27,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:relay"/>
|
||||
</thing-type>
|
||||
|
||||
@ -43,6 +45,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:relay"/>
|
||||
</thing-type>
|
||||
|
||||
@ -64,6 +67,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:relay"/>
|
||||
</thing-type>
|
||||
|
||||
@ -82,8 +86,10 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:relay"/>
|
||||
</thing-type>
|
||||
|
||||
<thing-type id="shelly2-roller">
|
||||
<label>Shelly2 Roller (SHSW-21)</label>
|
||||
<description>Shelly2 in Roller Mode</description>
|
||||
@ -94,6 +100,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:roller"/>
|
||||
</thing-type>
|
||||
|
||||
@ -116,8 +123,10 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:relay"/>
|
||||
</thing-type>
|
||||
|
||||
<thing-type id="shelly25-roller">
|
||||
<label>Shelly2.5 Roller (SHSW-25)</label>
|
||||
<description>Shelly2 in Roller Mode</description>
|
||||
@ -128,6 +137,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:roller"/>
|
||||
</thing-type>
|
||||
|
||||
@ -163,6 +173,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:relay"/>
|
||||
</thing-type>
|
||||
|
||||
@ -175,6 +186,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:relay"/>
|
||||
</thing-type>
|
||||
|
||||
@ -188,6 +200,21 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:relay"/>
|
||||
</thing-type>
|
||||
|
||||
<thing-type id="shellyplugu1">
|
||||
<label>Shelly Plug US (SHPLG-U1)</label>
|
||||
<description>Shelly Plug US with relay and meter</description>
|
||||
|
||||
<channel-groups>
|
||||
<channel-group id="relay" typeId="relayChannelPlug"/>
|
||||
<channel-group id="meter" typeId="meter"/>
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:relay"/>
|
||||
</thing-type>
|
||||
|
||||
@ -201,6 +228,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:dimmer"/>
|
||||
</thing-type>
|
||||
|
||||
@ -214,6 +242,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:dimmer"/>
|
||||
</thing-type>
|
||||
|
||||
@ -227,6 +256,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:relay"/>
|
||||
</thing-type>
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:battery"/>
|
||||
</thing-type>
|
||||
|
||||
@ -27,6 +28,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:battery"/>
|
||||
</thing-type>
|
||||
|
||||
@ -39,6 +41,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:basic"/>
|
||||
</thing-type>
|
||||
|
||||
@ -51,6 +54,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:battery"/>
|
||||
</thing-type>
|
||||
|
||||
@ -64,6 +68,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:battery"/>
|
||||
</thing-type>
|
||||
|
||||
@ -77,6 +82,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:battery"/>
|
||||
</thing-type>
|
||||
|
||||
@ -90,6 +96,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:battery"/>
|
||||
</thing-type>
|
||||
|
||||
@ -103,6 +110,7 @@
|
||||
<channel-group id="device" typeId="deviceStatus"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description-ref uri="thing-type:shelly:battery"/>
|
||||
</thing-type>
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
<label>Shelly Device</label>
|
||||
<description>A password protected or unknown device.</description>
|
||||
|
||||
<representation-property>deviceName</representation-property>
|
||||
<config-description>
|
||||
<parameter name="userId" type="text" required="true">
|
||||
<label>UserID</label>
|
||||
@ -30,6 +31,7 @@
|
||||
<thing-type id="shellyunknown">
|
||||
<label>Unknown Shelly Device</label>
|
||||
<description>This device is currently not supported</description>
|
||||
<representation-property>deviceName</representation-property>
|
||||
</thing-type>
|
||||
|
||||
</thing:thing-descriptions>
|
||||
|
Loading…
Reference in New Issue
Block a user