Skip to content

Commit

Permalink
[enocean]: D2-01-0C support for pilot wire mode
Browse files Browse the repository at this point in the history
Refs #6938
  • Loading branch information
lovery committed Sep 20, 2024
1 parent 08099f8 commit 305c27c
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
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 @@ -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 @@ -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

0 comments on commit 305c27c

Please sign in to comment.