Skip to content

Commit

Permalink
Add filter period channel.
Browse files Browse the repository at this point in the history
Fixes openhab#11310

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
  • Loading branch information
jlaur committed Oct 11, 2021
1 parent 60b4dad commit d847f3a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions bundles/org.openhab.binding.danfossairunit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ These are the available configuration parameters:
| exhaust_temp | recuperator | Number | RO | Temperature of the air when pushed outside |
| battery_life | service | Number | RO | Remaining Air Dial Battery Level (percentage) |
| filter_life | service | Number | RO | Remaining life of filter until exchange is necessary (percentage) |
| filter_period | service | Number | RW | Number of months between filter replacements (between 3 and 12) |


## Full Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public enum Channel {

// service channels
CHANNEL_BATTERY_LIFE("battery_life", ChannelGroup.SERVICE, DanfossAirUnit::getBatteryLife),
CHANNEL_FILTER_LIFE("filter_life", ChannelGroup.SERVICE, DanfossAirUnit::getFilterLife);
CHANNEL_FILTER_LIFE("filter_life", ChannelGroup.SERVICE, DanfossAirUnit::getFilterLife),
CHANNEL_FILTER_PERIOD("filter_period", ChannelGroup.SERVICE, DanfossAirUnit::getFilterPeriod,
DanfossAirUnit::setFilterPeriod);

private final String channelName;
private final ChannelGroup group;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class Commands {
public static byte[] EXHAUST_TEMPERATURE = { 0x14, 0x75 };
public static byte[] BATTERY_LIFE = { 0x03, 0x0f };
public static byte[] FILTER_LIFE = { 0x14, 0x6a };
public static byte[] FILTER_PERIOD = { 0x14, 0x69 };
public static byte[] CURRENT_TIME = { 0x15, (byte) 0xe0 };
public static byte[] AWAY_TO = { 0x15, 0x20 };
public static byte[] AWAY_FROM = { 0x15, 0x21 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ public DecimalType getFilterLife() throws IOException {
return new DecimalType(BigDecimal.valueOf(asPercentByte(getByte(REGISTER_1_READ, FILTER_LIFE))));
}

public DecimalType getFilterPeriod() throws IOException {
return new DecimalType(BigDecimal.valueOf(getByte(REGISTER_1_READ, FILTER_PERIOD)));
}

public DecimalType setFilterPeriod(Command cmd) throws IOException {
return setNumberTypeRegister(cmd, FILTER_PERIOD);
}

public DateTimeType getCurrentTime() throws IOException, UnexpectedResponseValueException {
ZonedDateTime timestamp = getTimestamp(REGISTER_1_READ, CURRENT_TIME);
return new DateTimeType(timestamp);
Expand All @@ -225,6 +233,14 @@ public PercentType setManualFanStep(Command cmd) throws IOException {
return setPercentTypeRegister(cmd, MANUAL_FAN_SPEED_STEP);
}

private DecimalType setNumberTypeRegister(Command cmd, byte[] register) throws IOException {
if (cmd instanceof DecimalType) {
byte value = (byte) ((((DecimalType) cmd).intValue()));
set(REGISTER_1_WRITE, register, value);
}
return new DecimalType(BigDecimal.valueOf(getByte(REGISTER_1_READ, register)));
}

private PercentType setPercentTypeRegister(Command cmd, byte[] register) throws IOException {
if (cmd instanceof PercentType) {
byte value = (byte) ((((PercentType) cmd).intValue() + 5) / 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
<label>Remaining Filter Life</label>
<description>Remaining life of filter until exchange is necessary</description>
</channel>
<channel id="filter_period" typeId="filterPeriod"/>
</channels>
</channel-group-type>

Expand Down Expand Up @@ -190,6 +191,12 @@
<category>Fan</category>
<state step="10" min="0" max="100" readOnly="true"/>
</channel-type>
<channel-type id="filterPeriod">
<item-type>Number</item-type>
<label>Filter Period</label>
<description>Number of months between filter replacements</description>
<state pattern="%d" min="3" max="12"/>
</channel-type>
<channel-type id="percentage">
<item-type>Number</item-type>
<label>Percentage</label>
Expand Down

0 comments on commit d847f3a

Please sign in to comment.