Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enocean] D2-01-0C implement support for pilot wire mode #17450

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bundles/org.openhab.binding.enocean/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -85,7 +85,7 @@ protected void setSwitchingQueryData(byte outputChannel) {
}

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);
}

Expand All @@ -97,7 +97,8 @@ protected byte getChannel() {
}

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);
}

Expand Down Expand Up @@ -126,7 +127,7 @@ protected void setDimmingData(Command command, byte outputChannel, Configuration
}

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));
}

Expand All @@ -142,7 +143,7 @@ protected void setPowerMeasurementQueryData(byte outputChannel) {
}

protected State getEnergyMeasurementData() {
if (getCMD() == CMD_ACTUATOR_MEASUREMENT_RESPONE) {
if (getCMD() == CMD_ACTUATOR_MEASUREMENT_RESPONSE) {
float factor = 1;

switch (bytes[1] >>> 5) {
Expand All @@ -169,7 +170,7 @@ protected State getEnergyMeasurementData() {
}

protected State getPowerMeasurementData() {
if (getCMD() == CMD_ACTUATOR_MEASUREMENT_RESPONE) {
if (getCMD() == CMD_ACTUATOR_MEASUREMENT_RESPONSE) {
float factor = 1;

switch (bytes[1] >>> 5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
*
Expand All @@ -22,11 +33,43 @@
@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();
}

public D2_01_0C(ERP1Message packet) {
super(packet);
}

@Override
protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
Function<String, State> 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<String, @Nullable State> 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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -86,7 +86,7 @@ protected void setPositionQueryData(byte outputChannel) {
}

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,22 @@
</config-description>
</channel-type>

<channel-type id="pilotWire">
<item-type>Number</item-type>
<label>Pilot wire</label>
<description>Mode of a heating device</description>
<state>
<options>
<option value="0">Off</option>
<option value="1">Comfort</option>
<option value="2">Eco</option>
<option value="3">Anti-freeze</option>
<option value="4">Comfort-1</option>
<option value="5">Comfort-2</option>
</options>
</state>
</channel-type>

<channel-type id="batteryVoltage">
<item-type>Number:ElectricPotential</item-type>
<label>Battery Voltage</label>
Expand Down