From a9a4d13adb253cbe7941bb66bacd696794a06539 Mon Sep 17 00:00:00 2001 From: robnielsen Date: Tue, 30 Jun 2020 22:44:48 -0500 Subject: [PATCH] [insteon] added support for motion sensor II (2844-222) (#8014) Signed-off-by: Rob Nielsen --- bundles/org.openhab.binding.insteon/README.md | 27 ++++++- .../insteon/internal/InsteonBinding.java | 1 + .../internal/InsteonBindingConstants.java | 3 + .../internal/device/CommandHandler.java | 13 ++-- .../internal/device/MessageHandler.java | 68 +++++++++++++---- .../binding/insteon/internal/driver/Port.java | 9 ++- .../handler/InsteonDeviceHandler.java | 74 +++++++++++++------ .../resources/ESH-INF/thing/thing-types.xml | 16 ++++ .../src/main/resources/device_features.xml | 10 +++ .../src/main/resources/device_types.xml | 11 +++ 10 files changed, 182 insertions(+), 50 deletions(-) diff --git a/bundles/org.openhab.binding.insteon/README.md b/bundles/org.openhab.binding.insteon/README.md index e8d1e20d2befa..a4c9ed5924704 100644 --- a/bundles/org.openhab.binding.insteon/README.md +++ b/bundles/org.openhab.binding.insteon/README.md @@ -102,6 +102,7 @@ These have been tested and should work out of the box: | 2413U | PowerLinc 2413U USB modem | 0x000045 | Bernd Pfrommer | | 2843-222 | Wireless Open/Close Sensor | 0x000049 | Josenivaldo Benito | | 2842-222 | Motion Sensor | 0x00004A | Bernd Pfrommer | +| 2844-222 | Motion Sensor II | F00.00.24 | Rob Nielsen | | 2486DWH8 | KeypadLinc Dimmer | 0x000051 | Chris Graham | | 2472D | OutletLincDimmer | 0x000068 | Chris Graham | | X10 switch | generic X10 switch | X00.00.01 | Bernd Pfrommer | @@ -118,6 +119,7 @@ In order to determine which channels a device supports, you can look at the devi | acDelay | Number | AC Delay | | backlightDuration | Number | Back Light Duration | | batteryLevel | Number | Battery Level | +| batteryPercent | Number:Dimensionless | Battery Percent | | batteryWatermarkLevel | Number | Battery Watermark Level | | beep | Switch | Beep | | bottomOutlet | Switch | Bottom Outlet | @@ -179,7 +181,9 @@ In order to determine which channels a device supports, you can look at the devi | stage1Duration | Number | Stage 1 Duration | | switch | Switch | Switch | | systemMode | Number | System Mode | +| tamperSwitch | Contact | Tamper Switch | | temperature | Number:Temperature | Temperature | +| temperatureLevel | Number | Temperature Level | | topOutlet | Switch | Top Outlet | | update | Switch | Update | | watts | Number:Power | Watts | @@ -388,12 +392,29 @@ Then create entries in the .items file like this: ``` Contact motionSensor "motion sensor [MAP(contact.map):%s]" { channel="insteon:device:home:AABBCC:contact"} - Number motionSensorBatteryLevel "motion sensor battery level [%.1f]" { channel="insteon:device:home:AABBCC:batteryLevel" } - Number motionSensorLightLevel "motion sensor light level [%.1f]" { channel="insteon:device:home:AABBCC:lightLevel" } + Number motionSensorBatteryLevel "motion sensor battery level" { channel="insteon:device:home:AABBCC:batteryLevel" } + Number motionSensorLightLevel "motion sensor light level" { channel="insteon:device:home:AABBCC:lightLevel" } ``` This will give you a contact, the battery level, and the light level. -Note that battery and light level are only updated when either there is motion, or the sensor battery runs low. +Note that battery and light level are only updated when either there is motion, light level above/below threshold, tamper switch activated, or the sensor battery runs low. + +The motion sensor II includes three additional channels: + +**Items** + +``` + Number motionSensorBatteryPercent "motion sensor battery percent" { channel="insteon:device:home:AABBCC:batteryPercent" } + Contact motionSensorTamperSwitch "motion sensor tamper switch [MAP(contact.map):%s]" { channel="insteon:device:home:AABBCC:tamperSwitch"} + Number motionSensorTemperatureLevel "motion sensor temperature level" { channel="insteon:device:home:AABBCC:temperatureLevel" } +``` + +The temperature can be calculated in Fahrenheit using the following formulas: + +* If the device is battery powered: `temperature = 0.73 * motionSensorTemperatureLevel - 20.53` +* If the device is USB powered: `temperature = 0.72 * motionSensorTemperatureLevel - 24.61` + +Since the motion sensor II might not be calibrated correctly, the values `20.53` and `24.61` can be adjusted as necessary to produce the correct temperature. ### Hidden Door Sensors diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonBinding.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonBinding.java index 0affda35cc761..fae0a67766091 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonBinding.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonBinding.java @@ -248,6 +248,7 @@ public InsteonDevice makeNewDevice(InsteonAddress addr, String productKey) { DeviceType dt = DeviceTypeLoader.instance().getDeviceType(productKey); InsteonDevice dev = InsteonDevice.makeDevice(dt); dev.setAddress(addr); + dev.setProductKey(productKey); dev.setDriver(driver); if (!dev.hasValidPollingInterval()) { dev.setPollInterval(devicePollIntervalMilliseconds); diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonBindingConstants.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonBindingConstants.java index 9040d5afa48a6..e23fd98520692 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonBindingConstants.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonBindingConstants.java @@ -33,6 +33,7 @@ public class InsteonBindingConstants { public static final String AC_DELAY = "acDelay"; public static final String BACKLIGHT_DURATION = "backlightDuration"; public static final String BATTERY_LEVEL = "batteryLevel"; + public static final String BATTERY_PERCENT = "batteryPercent"; public static final String BATTERY_WATERMARK_LEVEL = "batteryWatermarkLevel"; public static final String BEEP = "beep"; public static final String BOTTOM_OUTLET = "bottomOutlet"; @@ -102,7 +103,9 @@ public class InsteonBindingConstants { public static final String STAGE1_DURATION = "stage1Duration"; public static final String SWITCH = "switch"; public static final String SYSTEM_MODE = "systemMode"; + public static final String TAMPER_SWITCH = "tamperSwitch"; public static final String TEMPERATURE = "temperature"; + public static final String TEMPERATURE_LEVEL = "temperatureLevel"; public static final String TOP_OUTLET = "topOutlet"; public static final String UPDATE = "update"; public static final String WATTS = "watts"; diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java index 4a84247338f66..ad1d58297d94d 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/CommandHandler.java @@ -28,6 +28,7 @@ import org.eclipse.smarthome.core.types.Command; import org.openhab.binding.insteon.internal.config.InsteonChannelConfiguration; import org.openhab.binding.insteon.internal.device.DeviceFeatureListener.StateChangeType; +import org.openhab.binding.insteon.internal.handler.InsteonDeviceHandler; import org.openhab.binding.insteon.internal.message.FieldException; import org.openhab.binding.insteon.internal.message.InvalidMessageTypeException; import org.openhab.binding.insteon.internal.message.Msg; @@ -688,23 +689,25 @@ public static class PowerMeterCommandHandler extends CommandHandler { @Override public void handleCommand(InsteonChannelConfiguration conf, Command cmd, InsteonDevice dev) { - String cmdParam = conf.getParameters().get("cmd"); + String cmdParam = conf.getParameters().get(InsteonDeviceHandler.CMD); if (cmdParam == null) { logger.warn("{} ignoring cmd {} because no cmd= is configured!", nm(), cmd); return; } try { if (cmd == OnOffType.ON) { - if (cmdParam.equals("reset")) { + if (cmdParam.equals(InsteonDeviceHandler.CMD_RESET)) { Msg m = dev.makeStandardMessage((byte) 0x0f, (byte) 0x80, (byte) 0x00); dev.enqueueMessage(m, feature); logger.debug("{}: sent reset msg to power meter {}", nm(), dev.getAddress()); - feature.publish(OnOffType.OFF, StateChangeType.ALWAYS, "cmd", "reset"); - } else if (cmdParam.equals("update")) { + feature.publish(OnOffType.OFF, StateChangeType.ALWAYS, InsteonDeviceHandler.CMD, + InsteonDeviceHandler.CMD_RESET); + } else if (cmdParam.equals(InsteonDeviceHandler.CMD_UPDATE)) { Msg m = dev.makeStandardMessage((byte) 0x0f, (byte) 0x82, (byte) 0x00); dev.enqueueMessage(m, feature); logger.debug("{}: sent update msg to power meter {}", nm(), dev.getAddress()); - feature.publish(OnOffType.OFF, StateChangeType.ALWAYS, "cmd", "update"); + feature.publish(OnOffType.OFF, StateChangeType.ALWAYS, InsteonDeviceHandler.CMD, + InsteonDeviceHandler.CMD_UPDATE); } else { logger.warn("{}: ignoring unknown cmd {} for power meter {}", nm(), cmdParam, dev.getAddress()); } diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/MessageHandler.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/MessageHandler.java index bfdf7e699d06b..0b6028bdff07d 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/MessageHandler.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/MessageHandler.java @@ -32,6 +32,7 @@ import org.eclipse.smarthome.core.types.State; import org.openhab.binding.insteon.internal.device.DeviceFeatureListener.StateChangeType; import org.openhab.binding.insteon.internal.device.GroupMessageStateMachine.GroupMessage; +import org.openhab.binding.insteon.internal.handler.InsteonDeviceHandler; import org.openhab.binding.insteon.internal.message.FieldException; import org.openhab.binding.insteon.internal.message.InvalidMessageTypeException; import org.openhab.binding.insteon.internal.message.Msg; @@ -715,15 +716,46 @@ public void handleMessage(int group, byte cmd1, Msg msg, DeviceFeature f) { } try { int cmd2 = msg.getByte("command2") & 0xff; + int batteryLevel; + int lightLevel; + int temperatureLevel; switch (cmd2) { case 0x00: // this is a product data response message - int batteryLevel = msg.getByte("userData12") & 0xff; - int lightLevel = msg.getByte("userData11") & 0xff; + batteryLevel = msg.getByte("userData12") & 0xff; + lightLevel = msg.getByte("userData11") & 0xff; logger.debug("{}: {} got light level: {}, battery level: {}", nm(), dev.getAddress(), lightLevel, batteryLevel); - feature.publish(new DecimalType(lightLevel), StateChangeType.CHANGED, "field", "light_level"); - feature.publish(new DecimalType(batteryLevel), StateChangeType.CHANGED, "field", - "battery_level"); + feature.publish(new DecimalType(lightLevel), StateChangeType.CHANGED, + InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_LIGHT_LEVEL); + feature.publish(new DecimalType(batteryLevel), StateChangeType.CHANGED, + InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_BATTERY_LEVEL); + break; + case 0x03: // this is the 2844-222 data response message + batteryLevel = msg.getByte("userData6") & 0xff; + lightLevel = msg.getByte("userData7") & 0xff; + temperatureLevel = msg.getByte("userData8") & 0xff; + logger.debug("{}: {} got light level: {}, battery level: {}, temperature level: {}", nm(), + dev.getAddress(), lightLevel, batteryLevel, temperatureLevel); + feature.publish(new DecimalType(lightLevel), StateChangeType.CHANGED, + InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_LIGHT_LEVEL); + feature.publish(new DecimalType(batteryLevel), StateChangeType.CHANGED, + InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_BATTERY_LEVEL); + feature.publish(new DecimalType(temperatureLevel), StateChangeType.CHANGED, + InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_TEMPERATURE_LEVEL); + + // per 2844-222 dev doc: working battery level range is 0xd2 - 0x70 + int batteryPercentage; + if (batteryLevel >= 0xd2) { + batteryPercentage = 100; + } else if (batteryLevel <= 0x70) { + batteryPercentage = 0; + } else { + batteryPercentage = (batteryLevel - 0x70) * 100 / (0xd2 - 0x70); + } + logger.debug("{}: {} battery percentage: {}", nm(), dev.getAddress(), batteryPercentage); + feature.publish(new QuantityType<>(batteryPercentage, SmartHomeUnits.PERCENT), + StateChangeType.CHANGED, InsteonDeviceHandler.FIELD, + InsteonDeviceHandler.FIELD_BATTERY_PERCENTAGE); break; default: logger.warn("unknown cmd2 = {} in info reply message {}", cmd2, msg); @@ -756,10 +788,10 @@ public void handleMessage(int group, byte cmd1, Msg msg, DeviceFeature f) { int batteryWatermark = msg.getByte("userData7") & 0xff; logger.debug("{}: {} got light level: {}, battery level: {}", nm(), dev.getAddress(), batteryWatermark, batteryLevel); - feature.publish(new DecimalType(batteryWatermark), StateChangeType.CHANGED, "field", - "battery_watermark_level"); - feature.publish(new DecimalType(batteryLevel), StateChangeType.CHANGED, "field", - "battery_level"); + feature.publish(new DecimalType(batteryWatermark), StateChangeType.CHANGED, + InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_BATTERY_WATERMARK_LEVEL); + feature.publish(new DecimalType(batteryLevel), StateChangeType.CHANGED, + InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_BATTERY_LEVEL); break; default: logger.warn("unknown cmd2 = {} in info reply message {}", cmd2, msg); @@ -801,9 +833,9 @@ public void handleMessage(int group, byte cmd1, Msg msg, DeviceFeature f) { logger.debug("{}:{} watts: {} kwh: {} ", nm(), f.getDevice().getAddress(), watts, kwh); feature.publish(new QuantityType<>(kwh, SmartHomeUnits.KILOWATT_HOUR), StateChangeType.CHANGED, - "field", "kwh"); - feature.publish(new QuantityType<>(watts, SmartHomeUnits.WATT), StateChangeType.CHANGED, "field", - "watts"); + InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_KWH); + feature.publish(new QuantityType<>(watts, SmartHomeUnits.WATT), StateChangeType.CHANGED, + InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_WATTS); } catch (FieldException e) { logger.warn("error parsing {}: ", msg, e); } @@ -941,7 +973,11 @@ public static class ClosedSleepingContactHandler extends MessageHandler { @Override public void handleMessage(int group, byte cmd1, Msg msg, DeviceFeature f) { feature.publish(OpenClosedType.CLOSED, StateChangeType.ALWAYS); - sendExtendedQuery(f, (byte) 0x2e, (byte) 00); + if (f.getDevice().hasProductKey(InsteonDeviceHandler.MOTION_SENSOR_II_PRODUCT_KEY)) { + sendExtendedQuery(f, (byte) 0x2e, (byte) 03); + } else { + sendExtendedQuery(f, (byte) 0x2e, (byte) 00); + } } } @@ -954,7 +990,11 @@ public static class OpenedSleepingContactHandler extends MessageHandler { @Override public void handleMessage(int group, byte cmd1, Msg msg, DeviceFeature f) { feature.publish(OpenClosedType.OPEN, StateChangeType.ALWAYS); - sendExtendedQuery(f, (byte) 0x2e, (byte) 00); + if (f.getDevice().hasProductKey(InsteonDeviceHandler.MOTION_SENSOR_II_PRODUCT_KEY)) { + sendExtendedQuery(f, (byte) 0x2e, (byte) 03); + } else { + sendExtendedQuery(f, (byte) 0x2e, (byte) 00); + } } } diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/Port.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/Port.java index e10313f6f7d57..4c7484189a313 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/Port.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/driver/Port.java @@ -28,6 +28,7 @@ import org.openhab.binding.insteon.internal.device.InsteonAddress; import org.openhab.binding.insteon.internal.device.InsteonDevice; import org.openhab.binding.insteon.internal.device.ModemDBBuilder; +import org.openhab.binding.insteon.internal.handler.InsteonDeviceHandler; import org.openhab.binding.insteon.internal.message.FieldException; import org.openhab.binding.insteon.internal.message.InvalidMessageTypeException; import org.openhab.binding.insteon.internal.message.Msg; @@ -509,14 +510,14 @@ public void msg(Msg msg) { if (msg.getByte("Cmd") == 0x60) { // add the modem to the device list InsteonAddress a = new InsteonAddress(msg.getAddress("IMAddress")); - String prodKey = "0x000045"; - DeviceType dt = DeviceTypeLoader.instance().getDeviceType(prodKey); + DeviceType dt = DeviceTypeLoader.instance().getDeviceType(InsteonDeviceHandler.PLM_PRODUCT_KEY); if (dt == null) { - logger.warn("unknown modem product key: {} for modem: {}.", prodKey, a); + logger.warn("unknown modem product key: {} for modem: {}.", + InsteonDeviceHandler.PLM_PRODUCT_KEY, a); } else { device = InsteonDevice.makeDevice(dt); device.setAddress(a); - device.setProductKey(prodKey); + device.setProductKey(InsteonDeviceHandler.PLM_PRODUCT_KEY); device.setDriver(driver); device.setIsModem(true); logger.debug("found modem {} in device_types: {}", a, device.toString()); diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/handler/InsteonDeviceHandler.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/handler/InsteonDeviceHandler.java index 4acb2cce0de91..c4f19cb06604a 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/handler/InsteonDeviceHandler.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/handler/InsteonDeviceHandler.java @@ -55,11 +55,12 @@ public class InsteonDeviceHandler extends BaseThingHandler { private static final Set ALL_CHANNEL_IDS = Collections.unmodifiableSet(Stream.of( InsteonBindingConstants.AC_DELAY, InsteonBindingConstants.BACKLIGHT_DURATION, - InsteonBindingConstants.BATTERY_LEVEL, InsteonBindingConstants.BATTERY_WATERMARK_LEVEL, - InsteonBindingConstants.BEEP, InsteonBindingConstants.BOTTOM_OUTLET, InsteonBindingConstants.BUTTON_A, - InsteonBindingConstants.BUTTON_B, InsteonBindingConstants.BUTTON_C, InsteonBindingConstants.BUTTON_D, - InsteonBindingConstants.BUTTON_E, InsteonBindingConstants.BUTTON_F, InsteonBindingConstants.BUTTON_G, - InsteonBindingConstants.BUTTON_H, InsteonBindingConstants.BROADCAST_ON_OFF, InsteonBindingConstants.CONTACT, + InsteonBindingConstants.BATTERY_LEVEL, InsteonBindingConstants.BATTERY_PERCENT, + InsteonBindingConstants.BATTERY_WATERMARK_LEVEL, InsteonBindingConstants.BEEP, + InsteonBindingConstants.BOTTOM_OUTLET, InsteonBindingConstants.BUTTON_A, InsteonBindingConstants.BUTTON_B, + InsteonBindingConstants.BUTTON_C, InsteonBindingConstants.BUTTON_D, InsteonBindingConstants.BUTTON_E, + InsteonBindingConstants.BUTTON_F, InsteonBindingConstants.BUTTON_G, InsteonBindingConstants.BUTTON_H, + InsteonBindingConstants.BROADCAST_ON_OFF, InsteonBindingConstants.CONTACT, InsteonBindingConstants.COOL_SET_POINT, InsteonBindingConstants.DIMMER, InsteonBindingConstants.FAN, InsteonBindingConstants.FAN_MODE, InsteonBindingConstants.FAST_ON_OFF, InsteonBindingConstants.FAST_ON_OFF_BUTTON_A, InsteonBindingConstants.FAST_ON_OFF_BUTTON_B, @@ -86,28 +87,32 @@ public class InsteonDeviceHandler extends BaseThingHandler { InsteonBindingConstants.MANUAL_CHANGE_BUTTON_H, InsteonBindingConstants.NOTIFICATION, InsteonBindingConstants.ON_LEVEL, InsteonBindingConstants.RAMP_DIMMER, InsteonBindingConstants.RAMP_RATE, InsteonBindingConstants.RESET, InsteonBindingConstants.STAGE1_DURATION, InsteonBindingConstants.SWITCH, - InsteonBindingConstants.SYSTEM_MODE, InsteonBindingConstants.TEMPERATURE, + InsteonBindingConstants.SYSTEM_MODE, InsteonBindingConstants.TAMPER_SWITCH, + InsteonBindingConstants.TEMPERATURE, InsteonBindingConstants.TEMPERATURE_LEVEL, InsteonBindingConstants.TOP_OUTLET, InsteonBindingConstants.UPDATE, InsteonBindingConstants.WATTS) .collect(Collectors.toSet())); - private static final String BROADCAST_ON_OFF = "broadcastonoff"; - private static final String CMD = "cmd"; - private static final String CMD_RESET = "reset"; - private static final String CMD_UPDATE = "update"; - private static final String DATA = "data"; - private static final String FIELD = "field"; - private static final String FIELD_BATTERY_LEVEL = "battery_level"; - private static final String FIELD_BATTERY_WATERMARK_LEVEL = "battery_watermark_level"; - private static final String FIELD_KWH = "kwh"; - private static final String FIELD_LIGHT_LEVEL = "light_level"; - private static final String FIELD_WATTS = "watts"; - private static final String GROUP = "group"; - private static final String METER = "meter"; - - private static final String HIDDEN_DOOR_SENSOR_PRODUCT_KEY = "F00.00.03"; - private static final String MOTION_SENSOR_PRODUCT_KEY = "0x00004A"; - private static final String PLM_PRODUCT_KEY = "0x000045"; - private static final String POWER_METER_PRODUCT_KEY = "F00.00.17"; + public static final String BROADCAST_ON_OFF = "broadcastonoff"; + public static final String CMD = "cmd"; + public static final String CMD_RESET = "reset"; + public static final String CMD_UPDATE = "update"; + public static final String DATA = "data"; + public static final String FIELD = "field"; + public static final String FIELD_BATTERY_LEVEL = "battery_level"; + public static final String FIELD_BATTERY_PERCENTAGE = "battery_percentage"; + public static final String FIELD_BATTERY_WATERMARK_LEVEL = "battery_watermark_level"; + public static final String FIELD_KWH = "kwh"; + public static final String FIELD_LIGHT_LEVEL = "light_level"; + public static final String FIELD_TEMPERATURE_LEVEL = "temperature_level"; + public static final String FIELD_WATTS = "watts"; + public static final String GROUP = "group"; + public static final String METER = "meter"; + + public static final String HIDDEN_DOOR_SENSOR_PRODUCT_KEY = "F00.00.03"; + public static final String MOTION_SENSOR_II_PRODUCT_KEY = "F00.00.24"; + public static final String MOTION_SENSOR_PRODUCT_KEY = "0x00004A"; + public static final String PLM_PRODUCT_KEY = "0x000045"; + public static final String POWER_METER_PRODUCT_KEY = "F00.00.17"; private final Logger logger = LoggerFactory.getLogger(InsteonDeviceHandler.class); @@ -175,6 +180,13 @@ public void initialize() { || feature.equalsIgnoreCase(InsteonBindingConstants.LIGHT_LEVEL)) { feature = DATA; } + } else if (productKey.equals(MOTION_SENSOR_II_PRODUCT_KEY)) { + if (feature.equalsIgnoreCase(InsteonBindingConstants.BATTERY_LEVEL) + || feature.equalsIgnoreCase(InsteonBindingConstants.BATTERY_PERCENT) + || feature.equalsIgnoreCase(InsteonBindingConstants.LIGHT_LEVEL) + || feature.equalsIgnoreCase(InsteonBindingConstants.TEMPERATURE_LEVEL)) { + feature = DATA; + } } else if (productKey.equals(PLM_PRODUCT_KEY)) { String parts[] = feature.split("#"); if (parts.length == 2 && parts[0].equalsIgnoreCase(InsteonBindingConstants.BROADCAST_ON_OFF) @@ -312,6 +324,20 @@ public void channelLinked(ChannelUID channelUID) { params.put(FIELD, FIELD_LIGHT_LEVEL); feature = DATA; } + } else if (productKey.equals(MOTION_SENSOR_II_PRODUCT_KEY)) { + if (feature.equalsIgnoreCase(InsteonBindingConstants.BATTERY_LEVEL)) { + params.put(FIELD, FIELD_BATTERY_LEVEL); + feature = DATA; + } else if (feature.equalsIgnoreCase(InsteonBindingConstants.BATTERY_PERCENT)) { + params.put(FIELD, FIELD_BATTERY_PERCENTAGE); + feature = DATA; + } else if (feature.equalsIgnoreCase(InsteonBindingConstants.LIGHT_LEVEL)) { + params.put(FIELD, FIELD_LIGHT_LEVEL); + feature = DATA; + } else if (feature.equalsIgnoreCase(InsteonBindingConstants.TEMPERATURE_LEVEL)) { + params.put(FIELD, FIELD_TEMPERATURE_LEVEL); + feature = DATA; + } } else if (productKey.equals(PLM_PRODUCT_KEY)) { String parts[] = feature.split("#"); if (parts.length == 2 && parts[0].equalsIgnoreCase(InsteonBindingConstants.BROADCAST_ON_OFF) diff --git a/bundles/org.openhab.binding.insteon/src/main/resources/ESH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.insteon/src/main/resources/ESH-INF/thing/thing-types.xml index efe3885aea8b3..b93f72c14ed47 100644 --- a/bundles/org.openhab.binding.insteon/src/main/resources/ESH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.insteon/src/main/resources/ESH-INF/thing/thing-types.xml @@ -81,6 +81,7 @@ + @@ -114,6 +115,11 @@ + + Number:Dimensionless + + + Number @@ -459,11 +465,21 @@ + + Contact + + + Number:Temperature + + Number + + + Switch diff --git a/bundles/org.openhab.binding.insteon/src/main/resources/device_features.xml b/bundles/org.openhab.binding.insteon/src/main/resources/device_features.xml index 6dbfd7fb1bf30..5e42b34c691db 100644 --- a/bundles/org.openhab.binding.insteon/src/main/resources/device_features.xml +++ b/bundles/org.openhab.binding.insteon/src/main/resources/device_features.xml @@ -423,6 +423,16 @@ NoOpCommandHandler NoPollHandler + + DefaultDispatcher + NoOpMsgHandler + OpenedSleepingContactHandler + ClosedSleepingContactHandler + NoOpMsgHandler + NoOpMsgHandler + NoOpCommandHandler + NoPollHandler + SimpleDispatcher NoOpMsgHandler diff --git a/bundles/org.openhab.binding.insteon/src/main/resources/device_types.xml b/bundles/org.openhab.binding.insteon/src/main/resources/device_types.xml index 14d567c881fd1..7775b88f8facf 100644 --- a/bundles/org.openhab.binding.insteon/src/main/resources/device_types.xml +++ b/bundles/org.openhab.binding.insteon/src/main/resources/device_types.xml @@ -584,4 +584,15 @@ GenericLastTime + + + 2844-222 + Motion Sensor II + WirelessMotionSensorContact + WirelessMotionSensorLightLevelAboveThreshold + WirelessMotionSensorLowBattery + MotionSensorData + WirelessMotionSensor2TamperSwitch + GenericLastTime +