From 08099f8de46b3b0cbaaea0d46fca741eada2e17b Mon Sep 17 00:00:00 2001 From: Zhivka Dimova Date: Thu, 19 Sep 2024 15:07:15 +0200 Subject: [PATCH 1/3] [enocean] fix typos Rename constants name from *RESPONE to *RESPONSE Signed-off-by: Zhivka Dimova --- .../binding/enocean/internal/eep/D2_01/D2_01.java | 15 ++++++++------- .../enocean/internal/eep/D2_05/D2_05_00.java | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01.java index 3c0e3dfa86d..a52b1ec7d29 100644 --- a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01.java +++ b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01.java @@ -48,9 +48,9 @@ public abstract class D2_01 extends _VLDMessage { protected static final byte CMD_ACTUATOR_SET_STATUS = 0x01; protected static final byte CMD_ACTUATOR_STATUS_QUERY = 0x03; - protected static final byte CMD_ACTUATOR_STATUS_RESPONE = 0x04; + protected static final byte CMD_ACTUATOR_STATUS_RESPONSE = 0x04; protected static final byte CMD_ACTUATOR_MEASUREMENT_QUERY = 0x06; - protected static final byte CMD_ACTUATOR_MEASUREMENT_RESPONE = 0x07; + protected static final byte CMD_ACTUATOR_MEASUREMENT_RESPONSE = 0x07; protected static final byte ALL_CHANNELS_MASK = 0x1e; protected static final byte CHANNEL_A_MASK = 0x00; @@ -85,7 +85,7 @@ public abstract class D2_01 extends _VLDMessage { } protected State getSwitchingData() { - if (getCMD() == CMD_ACTUATOR_STATUS_RESPONE) { + if (getCMD() == CMD_ACTUATOR_STATUS_RESPONSE) { return OnOffType.from((bytes[bytes.length - 1] & OUTPUT_VALUE_MASK) != STATUS_SWITCHING_OFF); } @@ -97,7 +97,8 @@ public abstract class D2_01 extends _VLDMessage { } protected State getSwitchingData(byte channel) { - if (getCMD() == CMD_ACTUATOR_STATUS_RESPONE && (getChannel() == channel || getChannel() == ALL_CHANNELS_MASK)) { + if (getCMD() == CMD_ACTUATOR_STATUS_RESPONSE + && (getChannel() == channel || getChannel() == ALL_CHANNELS_MASK)) { return OnOffType.from((bytes[bytes.length - 1] & OUTPUT_VALUE_MASK) != STATUS_SWITCHING_OFF); } @@ -126,7 +127,7 @@ public abstract class D2_01 extends _VLDMessage { } protected State getDimmingData() { - if (getCMD() == CMD_ACTUATOR_STATUS_RESPONE) { + if (getCMD() == CMD_ACTUATOR_STATUS_RESPONSE) { return new PercentType((bytes[bytes.length - 1] & OUTPUT_VALUE_MASK)); } @@ -142,7 +143,7 @@ public abstract class D2_01 extends _VLDMessage { } protected State getEnergyMeasurementData() { - if (getCMD() == CMD_ACTUATOR_MEASUREMENT_RESPONE) { + if (getCMD() == CMD_ACTUATOR_MEASUREMENT_RESPONSE) { float factor = 1; switch (bytes[1] >>> 5) { @@ -169,7 +170,7 @@ public abstract class D2_01 extends _VLDMessage { } protected State getPowerMeasurementData() { - if (getCMD() == CMD_ACTUATOR_MEASUREMENT_RESPONE) { + if (getCMD() == CMD_ACTUATOR_MEASUREMENT_RESPONSE) { float factor = 1; switch (bytes[1] >>> 5) { diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_05/D2_05_00.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_05/D2_05_00.java index 5253357b523..edc0d110dc5 100644 --- a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_05/D2_05_00.java +++ b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_05/D2_05_00.java @@ -44,7 +44,7 @@ public class D2_05_00 extends _VLDMessage { protected static final byte CMD_ACTUATOR_SET_POSITION = 0x01; protected static final byte CMD_ACTUATOR_STOP = 0x02; protected static final byte CMD_ACTUATOR_POSITION_QUERY = 0x03; - protected static final byte CMD_ACTUATOR_POSITION_RESPONE = 0x04; + protected static final byte CMD_ACTUATOR_POSITION_RESPONSE = 0x04; protected static final byte ALL_CHANNELS_MASK = 0x1e; protected static final byte CHANNEL_A_MASK = 0x00; @@ -86,7 +86,7 @@ public class D2_05_00 extends _VLDMessage { } protected State getPositionData() { - if (getCMD() == CMD_ACTUATOR_POSITION_RESPONE) { + if (getCMD() == CMD_ACTUATOR_POSITION_RESPONSE) { int position = bytes[0] & 0x7f; if (position != 127) { return new PercentType(position); From 1e9da72a5f5aa1cb9f2c241db35641d7d7300ac3 Mon Sep 17 00:00:00 2001 From: Zhivka Dimova Date: Fri, 20 Sep 2024 15:40:47 +0200 Subject: [PATCH 2/3] [enocean]: D2-01-0C support for pilot wire mode Refs #6938 Signed-off-by: Zhivka Dimova --- .../internal/EnOceanBindingConstants.java | 4 ++ .../enocean/internal/eep/D2_01/D2_01_0C.java | 43 +++++++++++++++++++ .../binding/enocean/internal/eep/EEPType.java | 2 +- .../resources/OH-INF/i18n/enocean.properties | 8 ++++ .../main/resources/OH-INF/thing/channels.xml | 16 +++++++ 5 files changed, 72 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/EnOceanBindingConstants.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/EnOceanBindingConstants.java index 075ba0d4057..c03063723f6 100644 --- a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/EnOceanBindingConstants.java +++ b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/EnOceanBindingConstants.java @@ -168,6 +168,7 @@ public class EnOceanBindingConstants { public static final String CHANNEL_BATTERY_LEVEL = "batteryLevel"; public static final String CHANNEL_BATTERYLOW = "batteryLow"; + public static final String CHANNEL_PILOT_WIRE = "pilotWire"; public static final String CHANNEL_AUTOOFF = "autoOFF"; public static final String CHANNEL_DELAYRADIOOFF = "delayRadioOFF"; public static final String CHANNEL_EXTERNALINTERFACEMODE = "externalInterfaceMode"; @@ -425,6 +426,9 @@ public class EnOceanBindingConstants { Map.entry(CHANNEL_CUMULATIVEVALUE, new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_CUMULATIVEVALUE), CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Volume.class.getSimpleName())), + Map.entry(CHANNEL_PILOT_WIRE, + new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_PILOT_WIRE), + CoreItemFactory.NUMBER)), Map.entry(CHANNEL_AUTOOFF, new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_AUTOOFF), CoreItemFactory.NUMBER)), diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_0C.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_0C.java index 8e3243c8b72..c73df689e91 100644 --- a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_0C.java +++ b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/D2_01/D2_01_0C.java @@ -12,8 +12,19 @@ */ package org.openhab.binding.enocean.internal.eep.D2_01; +import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*; + +import java.util.function.Function; + import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.enocean.internal.messages.ERP1Message; +import org.openhab.core.config.core.Configuration; +import org.openhab.core.library.types.DecimalType; +import org.openhab.core.types.Command; +import org.openhab.core.types.RefreshType; +import org.openhab.core.types.State; +import org.openhab.core.types.UnDefType; /** * @@ -22,6 +33,10 @@ import org.openhab.binding.enocean.internal.messages.ERP1Message; @NonNullByDefault public class D2_01_0C extends D2_01 { + protected static final byte CMD_ACTUATOR_SET_PILOT_WIRE = 0x08; + protected static final byte CMD_ACTUATOR_PILOT_WIRE_QUERY = 0x09; + protected static final byte CMD_ACTUATOR_PILOT_WIRE_RESPONSE = 0x0A; + public D2_01_0C() { super(); } @@ -29,4 +44,32 @@ public class D2_01_0C extends D2_01 { public D2_01_0C(ERP1Message packet) { super(packet); } + + @Override + protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command, + Function getCurrentStateFunc, @Nullable Configuration config) { + if (channelId.equals(CHANNEL_PILOT_WIRE)) { + if (command == RefreshType.REFRESH) { + setData(CMD_ACTUATOR_PILOT_WIRE_QUERY, ALL_CHANNELS_MASK); + } else if (command instanceof DecimalType decimalCommand) { + setData(CMD_ACTUATOR_SET_PILOT_WIRE, decimalCommand.byteValue()); + } + } else { + super.convertFromCommandImpl(channelId, channelTypeId, command, getCurrentStateFunc, config); + } + } + + @Override + protected State convertToStateImpl(String channelId, String channelTypeId, + Function getCurrentStateFunc, Configuration config) { + if (channelId.equals(CHANNEL_PILOT_WIRE)) { + if (getCMD() == CMD_ACTUATOR_PILOT_WIRE_RESPONSE) { + return new DecimalType(bytes[1] & 0b111); + } + + return UnDefType.UNDEF; + } else { + return super.convertToStateImpl(channelId, channelTypeId, getCurrentStateFunc, config); + } + } } diff --git a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/EEPType.java b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/EEPType.java index 3a0ed4dd85d..e4b5e0324c1 100644 --- a/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/EEPType.java +++ b/bundles/org.openhab.binding.enocean/src/main/java/org/openhab/binding/enocean/internal/eep/EEPType.java @@ -476,7 +476,7 @@ public enum EEPType { SwitchWithEnergyMeasurment_0B(RORG.VLD, 0x01, 0x0B, true, D2_01_0B.class, THING_TYPE_MEASUREMENTSWITCH, CHANNEL_GENERAL_SWITCHING, CHANNEL_TOTALUSAGE, CHANNEL_INSTANTPOWER), SwitchWithEnergyMeasurment_0C(RORG.VLD, 0x01, 0x0C, true, D2_01_0C.class, THING_TYPE_MEASUREMENTSWITCH, - CHANNEL_GENERAL_SWITCHING, CHANNEL_TOTALUSAGE, CHANNEL_INSTANTPOWER), + CHANNEL_GENERAL_SWITCHING, CHANNEL_PILOT_WIRE, CHANNEL_TOTALUSAGE, CHANNEL_INSTANTPOWER), SwitchWithEnergyMeasurment_0D(RORG.VLD, 0x01, 0x0D, true, D2_01_0D.class, THING_TYPE_MEASUREMENTSWITCH, CHANNEL_GENERAL_SWITCHING), SwitchWithEnergyMeasurment_0E(RORG.VLD, 0x01, 0x0E, true, D2_01_0E.class, THING_TYPE_MEASUREMENTSWITCH, diff --git a/bundles/org.openhab.binding.enocean/src/main/resources/OH-INF/i18n/enocean.properties b/bundles/org.openhab.binding.enocean/src/main/resources/OH-INF/i18n/enocean.properties index 8e165ddaf32..3a489599a9e 100644 --- a/bundles/org.openhab.binding.enocean/src/main/resources/OH-INF/i18n/enocean.properties +++ b/bundles/org.openhab.binding.enocean/src/main/resources/OH-INF/i18n/enocean.properties @@ -519,6 +519,14 @@ channel-type.enocean.outdoorAirHeaterStatus.label = Outdoor Air Heater Status channel-type.enocean.outdoorAirHeaterStatus.description = Indicates if outdoor air heater is active or not channel-type.enocean.outdoorAirTemperature.label = Outdoor Temperature channel-type.enocean.outdoorAirTemperature.description = Current outdoor air temperature in degree Celsius +channel-type.enocean.pilotWire.label = Pilot wire +channel-type.enocean.pilotWire.description = Mode of a heating device +channel-type.enocean.pilotWire.state.option.0 = Off +channel-type.enocean.pilotWire.state.option.1 = Comfort +channel-type.enocean.pilotWire.state.option.2 = Eco +channel-type.enocean.pilotWire.state.option.3 = Anti-freeze +channel-type.enocean.pilotWire.state.option.4 = Comfort-1 +channel-type.enocean.pilotWire.state.option.5 = Comfort-2 channel-type.enocean.protectionPlusEvent.label = Protection Plus Event channel-type.enocean.protectionPlusEvent.description = Triggered when a Protection Plus capable device detects a break-in attempt. channel-type.enocean.rainStatus.label = Rain diff --git a/bundles/org.openhab.binding.enocean/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.enocean/src/main/resources/OH-INF/thing/channels.xml index 62a71eabaaf..6c65159f11a 100644 --- a/bundles/org.openhab.binding.enocean/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.enocean/src/main/resources/OH-INF/thing/channels.xml @@ -345,6 +345,22 @@ + + Number + + Mode of a heating device + + + + + + + + + + + + Number:ElectricPotential From 093a3b2b2235da754ddc6f786f12f0c95fbc4f91 Mon Sep 17 00:00:00 2001 From: Zhivka Dimova Date: Sat, 21 Sep 2024 07:12:17 +0200 Subject: [PATCH 3/3] [enocean]Add pilotWire channel in README Signed-off-by: Zhivka Dimova --- bundles/org.openhab.binding.enocean/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.enocean/README.md b/bundles/org.openhab.binding.enocean/README.md index 4454cfcffa5..b914f157966 100644 --- a/bundles/org.openhab.binding.enocean/README.md +++ b/bundles/org.openhab.binding.enocean/README.md @@ -94,7 +94,7 @@ Hence if your device supports one of the following EEPs the chances are good tha | environmentalSensor | A5-13 | 0x01-02 | temperature, windspeed, illumination, rainStatus | FWS61 | Discovery | | centralCommand | A5-38 | 0x08 | dimmer, generalSwitch | Eltako FUD14, FSR14 | Teach-in | | rollershutter | A5-3F/D2-05/A5-38 | 0x7F/00/08 | rollershutter | Eltako FSB14, NodOn SIN-2-RS-01| Teach-in/Discovery | -| measurementSwitch | D2-01 | 0x00-0F,11,12 | generalSwitch(/A/B), instantpower, totalusage, repeaterMode | NodOn In Wall Switch | Discovery | +| measurementSwitch | D2-01 | 0x00-0F,11,12 | generalSwitch(/A/B), dimmer, pilotWire, instantpower, totalusage, repeaterMode | NodOn In Wall Switch | Discovery | | windowSashHandleSensor | D2-06 | 0x50 | windowHandleState, windowSashState, batteryLevel, batteryLow, windowBreachEvent, windowCalibrationState, windowCalibrationStep | Siegenia Senso Secure | Discovery | | multiFunctionSmokeDetector | D2-14/F6-05 | 0x30/02 | smokeDetection, batteryLow | Insafe+, Afriso ASD | Discovery | | heatRecoveryVentilation | D2-50 | 0x00,01,10,11 | a lot of different state channels | Dimplex DL WE2 | Discovery | @@ -302,6 +302,7 @@ The channels of a thing are determined automatically based on the chosen EEP. | generalSwitch(/A/B) | Switch | Switch something (channel A/B) ON/OFF | | rollershutter | Rollershutter | Shut time (shutTime) in seconds can be configured | | angle | Number:Angle | The angle for blinds | +| pilotWire | Number | Device mode: 1 - Off, 2 - Comfort, 3 - Eco, 4 - Anti-freeze, 5 - Comfort1, 6 - Comfort2 | instantpower | Number:Power | Instant power consumption in Watts | | totalusage | Number:Energy | Used energy in Kilowatt hours | | teachInCMD | Switch | Sends a teach-in msg, content can configured with parameter teachInMSG |