From 08706f1314dc79b6ffbe33ba73bc802b53f56ff4 Mon Sep 17 00:00:00 2001 From: James Hewitt Date: Wed, 23 Jun 2021 17:10:29 +0100 Subject: [PATCH] [rfxcom] Add Novy extractor fans (#10891) --- bundles/org.openhab.binding.rfxcom/README.md | 30 ++++++-- .../internal/RFXComBindingConstants.java | 14 ++-- .../internal/messages/RFXComBaseMessage.java | 2 + .../internal/messages/RFXComFanMessage.java | 54 ++++++++++----- .../messages/RFXComMessageFactory.java | 1 + .../main/resources/OH-INF/thing/fan_novy.xml | 41 +++++++++++ .../RFXComFanLucciAirDcMessageTest.java | 5 -- .../messages/RFXComFanNovyMessage.java | 68 +++++++++++++++++++ 8 files changed, 184 insertions(+), 31 deletions(-) create mode 100644 bundles/org.openhab.binding.rfxcom/src/main/resources/OH-INF/thing/fan_novy.xml create mode 100644 bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanNovyMessage.java diff --git a/bundles/org.openhab.binding.rfxcom/README.md b/bundles/org.openhab.binding.rfxcom/README.md index 30685dc1c6616..de8f614a8a70c 100644 --- a/bundles/org.openhab.binding.rfxcom/README.md +++ b/bundles/org.openhab.binding.rfxcom/README.md @@ -439,7 +439,7 @@ A DateTime device A group of fan devices -#### Standard Fan +#### fan - Standard Fan A Fan device @@ -474,7 +474,7 @@ Switch item=FanLightSwitch label="Light" mappings=[ON="On"] Switch item=FanSpeedSwitch label="Speed" mappings=[LOW=Low, MED=Medium, HI=High] ``` -#### Falmec fan +#### fan_falmec - Falmec fan A Falmec Fan device @@ -496,7 +496,7 @@ A Falmec Fan device * Specifies device sub type. * FALMEC - Falmec -#### Lucci Air DC fan +#### fan_lucci_dc - Lucci Air DC fan A Lucci Air DC fan device @@ -517,7 +517,7 @@ A Lucci Air DC fan device * Specifies device sub type. * LUCCI_AIR_DC - Lucci Air DC -#### Lucci Air DC II fan +#### fan_lucci_dc_ii - Lucci Air DC II fan A Lucci Air DC II fan device @@ -538,6 +538,28 @@ A Lucci Air DC II fan device * subType - Sub Type * Specifies device sub type. * LUCCI_AIR_DC_II - Lucci Air DC II + +#### fan_novy - Novy extractor fan + +A Novy extractor fan. + +##### Channels + +| Name | Channel Type | Item Type | Remarks | +|--------------|-------------------------------------|---------------|--------------------------| +| command | [command](#channels) | Switch | | +| commandString| [commandString](#channels) | String | Options: POWER, UP, DOWN, LIGHT, LEARN, RESET_FILTER | +| fanSpeed | [fanspeedcontrol](#channels) | RollerShutter | Options: UP / DOWN | +| fanLight | [fanlight](#channels) | Switch | | +| signalLevel | [system.signal-strength](#channels) | Number | | + +##### Configuration Options + +* deviceId - Device Id + * Device id, example 47360 +* subType - Sub Type + * Specifies device sub type. + * NOVY - Novy extractor fan ### energy - RFXCOM Energy Sensor diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/RFXComBindingConstants.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/RFXComBindingConstants.java index d300abab5a258..d7c67118fa711 100644 --- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/RFXComBindingConstants.java +++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/RFXComBindingConstants.java @@ -133,6 +133,7 @@ public class RFXComBindingConstants { private static final ThingTypeUID THING_TYPE_FAN_FT1211R = new ThingTypeUID(BINDING_ID, "fan_ft1211r"); private static final ThingTypeUID THING_TYPE_FAN_FALMEC = new ThingTypeUID(BINDING_ID, "fan_falmec"); private static final ThingTypeUID THING_TYPE_FAN_LUCCI_DC_II = new ThingTypeUID(BINDING_ID, "fan_lucci_dc_ii"); + private static final ThingTypeUID THING_TYPE_FAN_NOVY = new ThingTypeUID(BINDING_ID, "fan_novy"); private static final ThingTypeUID THING_TYPE_FS20 = new ThingTypeUID(BINDING_ID, "fs20"); private static final ThingTypeUID THING_TYPE_GAS_USAGE = new ThingTypeUID(BINDING_ID, "gasusage"); private static final ThingTypeUID THING_TYPE_HOME_CONFORT = new ThingTypeUID(BINDING_ID, "homeconfort"); @@ -177,12 +178,12 @@ public class RFXComBindingConstants { THING_TYPE_CAMERA1, THING_TYPE_CHIME, THING_TYPE_CURRENT, THING_TYPE_CURRENT_ENERGY, THING_TYPE_CURTAIN1, THING_TYPE_DATE_TIME, THING_TYPE_ENERGY, THING_TYPE_FAN, THING_TYPE_FAN_SF01, THING_TYPE_FAN_ITHO, THING_TYPE_FAN_SEAV, THING_TYPE_FAN_LUCCI_DC, THING_TYPE_FAN_FT1211R, - THING_TYPE_FAN_FALMEC, THING_TYPE_FAN_LUCCI_DC_II, THING_TYPE_GAS_USAGE, THING_TYPE_HOME_CONFORT, - THING_TYPE_HUMIDITY, THING_TYPE_IO_LINES, THING_TYPE_LIGHTNING1, THING_TYPE_LIGHTNING2, - THING_TYPE_LIGHTNING3, THING_TYPE_LIGHTNING4, THING_TYPE_LIGHTNING5, THING_TYPE_LIGHTNING6, - THING_TYPE_POWER, THING_TYPE_RADIATOR1, THING_TYPE_RAIN, THING_TYPE_RAW, THING_TYPE_REMOTE_CONTROL, - THING_TYPE_RFX_METER, THING_TYPE_RFX_SENSOR, THING_TYPE_RFY, THING_TYPE_SECURITY1, - THING_TYPE_SECURITY2, THING_TYPE_TEMPERATURE, THING_TYPE_TEMPERATURE_HUMIDITY, + THING_TYPE_FAN_FALMEC, THING_TYPE_FAN_LUCCI_DC_II, THING_TYPE_FAN_NOVY, THING_TYPE_GAS_USAGE, + THING_TYPE_HOME_CONFORT, THING_TYPE_HUMIDITY, THING_TYPE_IO_LINES, THING_TYPE_LIGHTNING1, + THING_TYPE_LIGHTNING2, THING_TYPE_LIGHTNING3, THING_TYPE_LIGHTNING4, THING_TYPE_LIGHTNING5, + THING_TYPE_LIGHTNING6, THING_TYPE_POWER, THING_TYPE_RADIATOR1, THING_TYPE_RAIN, THING_TYPE_RAW, + THING_TYPE_REMOTE_CONTROL, THING_TYPE_RFX_METER, THING_TYPE_RFX_SENSOR, THING_TYPE_RFY, + THING_TYPE_SECURITY1, THING_TYPE_SECURITY2, THING_TYPE_TEMPERATURE, THING_TYPE_TEMPERATURE_HUMIDITY, THING_TYPE_TEMPERATURE_HUMIDITY_BAROMETRIC, THING_TYPE_TEMPERATURE_RAIN, THING_TYPE_THERMOSTAT1, THING_TYPE_THERMOSTAT2, THING_TYPE_THERMOSTAT3, THING_TYPE_UNDECODED, THING_TYPE_UV, THING_TYPE_WATER_USAGE, THING_TYPE_WEIGHTING_SCALE, THING_TYPE_WIND).collect(Collectors.toSet())); @@ -211,6 +212,7 @@ public class RFXComBindingConstants { put(PacketType.FAN_FT1211R, RFXComBindingConstants.THING_TYPE_FAN_FT1211R); put(PacketType.FAN_FALMEC, RFXComBindingConstants.THING_TYPE_FAN_FALMEC); put(PacketType.FAN_LUCCI_DC_II, RFXComBindingConstants.THING_TYPE_FAN_LUCCI_DC_II); + put(PacketType.FAN_NOVY, RFXComBindingConstants.THING_TYPE_FAN_NOVY); put(PacketType.FS20, RFXComBindingConstants.THING_TYPE_FS20); put(PacketType.GAS, RFXComBindingConstants.THING_TYPE_GAS_USAGE); put(PacketType.HOME_CONFORT, RFXComBindingConstants.THING_TYPE_HOME_CONFORT); diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBaseMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBaseMessage.java index 1f49b97f339b9..0e6d32917e06f 100644 --- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBaseMessage.java +++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComBaseMessage.java @@ -47,6 +47,8 @@ public enum PacketType implements ByteEnumWrapper { FAN_SEAV(23, RFXComFanMessage.SubType.SEAV_TXS4), FAN_FT1211R(23, RFXComFanMessage.SubType.FT1211R), FAN_FALMEC(23, RFXComFanMessage.SubType.FALMEC), + FAN_ITHO_CVE_ECO_RFT(23, RFXComFanMessage.SubType.ITHO_CVE_ECO_RFT), + FAN_NOVY(23, RFXComFanMessage.SubType.NOVY), CURTAIN1(24), BLINDS1(25), RFY(26), diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessage.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessage.java index 87c0fa6df69b6..feecca8979920 100644 --- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessage.java +++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanMessage.java @@ -41,16 +41,18 @@ public class RFXComFanMessage extends RFXComDeviceMessageImpl { public enum SubType implements ByteEnumWrapper { - SF01(0), - CVE_RFT(1), - LUCCI_AIR_FAN(2), - SEAV_TXS4(3), - WESTINGHOUSE_7226640(4), - LUCCI_AIR_DC(5), - CASAFAN(6), - FT1211R(7), - FALMEC(8), - LUCCI_AIR_DC_II(9); + SF01(0x00), + CVE_RFT(0x01), + LUCCI_AIR_FAN(0x02), + SEAV_TXS4(0x03), + WESTINGHOUSE_7226640(0x04), + LUCCI_AIR_DC(0x05), + CASAFAN(0x06), + FT1211R(0x07), + FALMEC(0x08), + LUCCI_AIR_DC_II(0x09), + ITHO_CVE_ECO_RFT(0x0A), + NOVY(0x0B); private final int subType; @@ -111,7 +113,14 @@ public enum Commands implements ByteEnumWrapperWithSupportedSubTypes { LUCCI_AIR_DC_II_SPEED_5(6, 5, LUCCI_AIR_DC_II), LUCCI_AIR_DC_II_SPEED_6(7, 6, LUCCI_AIR_DC_II), LUCCI_AIR_DC_II_LIGHT(8, LUCCI_AIR_DC_II), - LUCCI_AIR_DC_II_REVERSE(9, LUCCI_AIR_DC_II); + LUCCI_AIR_DC_II_REVERSE(9, LUCCI_AIR_DC_II), + + NOVY_POWER(1, NOVY), + NOVY_UP(2, NOVY), + NOVY_DOWN(3, NOVY), + NOVY_LIGHT(4, NOVY), + NOVY_LEARN(5, NOVY), + NOVY_RESET_FILTER(6, NOVY); private final int command; private final Integer speed; @@ -155,10 +164,10 @@ public List supportedBySubTypes() { private static final List GENERIC_SUB_TYPES = Arrays.asList(WESTINGHOUSE_7226640, CASAFAN, LUCCI_AIR_FAN); private static final List LIGHT_ON_COMMANDS = Arrays.asList(LIGHT, LUCCI_AIR_DC_LIGHT, - LUCCI_AIR_DC_II_LIGHT, FALMEC_LIGHT_ON); - private static final List ON_COMMANDS = Arrays.asList(Commands.HI, MED, LOW, FALMEC_SPEED_1, - FALMEC_SPEED_2, FALMEC_SPEED_3, FALMEC_SPEED_4, LUCCI_AIR_DC_II_SPEED_1, LUCCI_AIR_DC_II_SPEED_2, - LUCCI_AIR_DC_II_SPEED_3, LUCCI_AIR_DC_II_SPEED_4, LUCCI_AIR_DC_II_SPEED_5, LUCCI_AIR_DC_II_SPEED_6); + LUCCI_AIR_DC_II_LIGHT, FALMEC_LIGHT_ON, NOVY_LIGHT); + private static final List ON_COMMANDS = Arrays.asList(HI, MED, LOW, FALMEC_SPEED_1, FALMEC_SPEED_2, + FALMEC_SPEED_3, FALMEC_SPEED_4, LUCCI_AIR_DC_II_SPEED_1, LUCCI_AIR_DC_II_SPEED_2, LUCCI_AIR_DC_II_SPEED_3, + LUCCI_AIR_DC_II_SPEED_4, LUCCI_AIR_DC_II_SPEED_5, LUCCI_AIR_DC_II_SPEED_6); private static final List OFF_COMMANDS = Arrays.asList(OFF, FALMEC_POWER_OFF, LUCCI_AIR_DC_II_POWER_OFF); private SubType subType; @@ -194,6 +203,10 @@ public PacketType getPacketType() { return PacketType.FAN_FALMEC; case LUCCI_AIR_DC_II: return PacketType.FAN_LUCCI_DC_II; + case ITHO_CVE_ECO_RFT: + return PacketType.FAN_ITHO_CVE_ECO_RFT; + case NOVY: + return PacketType.FAN_NOVY; } return super.getPacketType(); } @@ -315,9 +328,11 @@ private State handleFanSpeedChannel() { return new DecimalType(command.getSpeed()); case LUCCI_AIR_DC_DOWN: + case NOVY_DOWN: return UpDownType.DOWN; case LUCCI_AIR_DC_UP: + case NOVY_UP: return UpDownType.UP; default: @@ -367,10 +382,12 @@ private Commands handleCommandString(String channelId, Type type) throws RFXComU case "POWER_OFF": case "UP": case "DOWN": + case "LEARN": case "LIGHT": case "REVERSE": case "NATURAL_FLOW": case "PAIR": + case "RESET_FILTER": case "SPEED_1": case "SPEED_2": case "SPEED_3": @@ -417,6 +434,12 @@ private Commands handleFanSpeedCommand(String channelId, Type type) throws RFXCo } else { return Commands.LUCCI_AIR_DC_DOWN; } + } else if (type instanceof UpDownType && subType == NOVY) { + if (UpDownType.UP == type) { + return Commands.NOVY_UP; + } else { + return Commands.NOVY_DOWN; + } } throw new RFXComUnsupportedChannelException("Channel " + channelId + " does not accept " + type); } @@ -427,7 +450,6 @@ private Commands handleFanLightCommand(String channelId, Type type) throws RFXCo case LUCCI_AIR_FAN: case CASAFAN: case WESTINGHOUSE_7226640: - case LUCCI_AIR_DC: return LIGHT; case FALMEC: diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComMessageFactory.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComMessageFactory.java index 0a3ec7d47bea6..231d79aa2ad07 100644 --- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComMessageFactory.java +++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages/RFXComMessageFactory.java @@ -51,6 +51,7 @@ public class RFXComMessageFactory { // put(PacketType.FAN_FT1211R, RFXComFanMessage.class); put(PacketType.FAN_FALMEC, RFXComFanMessage.class); put(PacketType.FAN_LUCCI_DC_II, RFXComFanMessage.class); + put(PacketType.FAN_NOVY, RFXComFanMessage.class); put(PacketType.CURTAIN1, RFXComCurtain1Message.class); put(PacketType.BLINDS1, RFXComBlinds1Message.class); put(PacketType.RFY, RFXComRfyMessage.class); diff --git a/bundles/org.openhab.binding.rfxcom/src/main/resources/OH-INF/thing/fan_novy.xml b/bundles/org.openhab.binding.rfxcom/src/main/resources/OH-INF/thing/fan_novy.xml new file mode 100644 index 0000000000000..c71bc11ae5cf5 --- /dev/null +++ b/bundles/org.openhab.binding.rfxcom/src/main/resources/OH-INF/thing/fan_novy.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + A Novy extractor fan. + + + + + + + + + + + + Unit Id. Example 1000 + + + + Specifies device sub type. + + + + NOVY + + + + + diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanLucciAirDcMessageTest.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanLucciAirDcMessageTest.java index 31a0336b0b74d..f2d26d80313f7 100644 --- a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanLucciAirDcMessageTest.java +++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanLucciAirDcMessageTest.java @@ -34,11 +34,6 @@ @NonNullByDefault public class RFXComFanLucciAirDcMessageTest { - @Test - public void testFanLightOn() throws RFXComException { - testCommand(CHANNEL_FAN_LIGHT, OnOffType.ON, OnOffType.ON, null, StringType.valueOf("LIGHT")); - } - @Test public void testUp() throws RFXComException { testCommand(CHANNEL_FAN_SPEED, UpDownType.UP, UnDefType.UNDEF, UpDownType.UP, StringType.valueOf("UP")); diff --git a/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanNovyMessage.java b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanNovyMessage.java new file mode 100644 index 0000000000000..a1ae01bbc1b5d --- /dev/null +++ b/bundles/org.openhab.binding.rfxcom/src/test/java/org/openhab/binding/rfxcom/internal/messages/RFXComFanNovyMessage.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2010-2021 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.rfxcom.internal.messages; + +import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*; +import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.FAN_NOVY; +import static org.openhab.binding.rfxcom.internal.messages.RFXComFanMessage.SubType.NOVY; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.junit.jupiter.api.Test; +import org.openhab.binding.rfxcom.internal.exceptions.RFXComException; +import org.openhab.core.library.types.OnOffType; +import org.openhab.core.library.types.StringType; +import org.openhab.core.library.types.UpDownType; +import org.openhab.core.types.State; +import org.openhab.core.types.UnDefType; + +/** + * Test for RFXCom-binding + * + * @author Martin van Wingerden - Initial contribution + */ +@NonNullByDefault +public class RFXComFanNovyMessage { + + @Test + public void testUp() throws RFXComException { + testCommand(CHANNEL_FAN_SPEED, UpDownType.UP, UnDefType.UNDEF, UpDownType.UP, StringType.valueOf("UP")); + } + + @Test + public void testDown() throws RFXComException { + testCommand(CHANNEL_FAN_SPEED, UpDownType.DOWN, UnDefType.UNDEF, UpDownType.DOWN, StringType.valueOf("DOWN")); + } + + @Test + public void testCommandString() throws RFXComException { + testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("POWER"), UnDefType.UNDEF, null, + StringType.valueOf("POWER")); + testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("UP"), UnDefType.UNDEF, UpDownType.UP, + StringType.valueOf("UP")); + testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("DOWN"), UnDefType.UNDEF, UpDownType.DOWN, + StringType.valueOf("DOWN")); + testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("LIGHT"), OnOffType.ON, null, + StringType.valueOf("LIGHT")); + testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("LEARN"), UnDefType.UNDEF, null, + StringType.valueOf("LEARN")); + testCommand(CHANNEL_COMMAND_STRING, StringType.valueOf("RESET_FILTER"), UnDefType.UNDEF, null, + StringType.valueOf("RESET_FILTER")); + } + + private void testCommand(String channel, State inputValue, State expectedLightCommand, + @Nullable State expectedFanSpeed, State expectedCommandString) throws RFXComException { + RFXComFanMessageTest.testCommand(NOVY, channel, inputValue, null, expectedLightCommand, expectedFanSpeed, + expectedCommandString, FAN_NOVY); + } +}