Insteon Hidden Door Sensor - 2 nodes - problem if door opened and closed too fast

Insteon Hidden Door Sensors can be configured in 2 different modes. ‘1 node’ or ‘2 nodes’

  • In ‘1 node’ mode a 0x11 ON command is sent when the door is opened and a 0x13 OFF command is sent when the door is closed, both on group 1.
  • In ‘2 nodes’ mode a 0x11 ON command is sent on group 1 when the door is opened and a 0x11 ON command is sent on group 2 when the door is closed.

With no modification the current Insteon PLM code for the Hidden Door Sensor will not work as desired since there is never a 0x13 sent on group one, so even with modification of the features/devices xml file to monitor group 2, only the first message on each group is accepted and all others are ignored as duplicates.

So, I decided to modify the Binding Code to add a new MessageHandler:

public static class OpenedOrClosedSleepingContactHandler extends MessageHandler {
        OpenedOrClosedSleepingContactHandler(DeviceFeature p) {
            super(p);
        }

        @Override
        public void handleMessage(int group, byte cmd1, Msg msg, DeviceFeature f, String fromPort) {
            try {
                byte cmd2 = msg.getByte("command2");
                switch (cmd1) {
                    case 0x11: // ON
                        switch (cmd2) {
                            case 0x01:
                                m_feature.publish(OpenClosedType.OPEN, StateChangeType.CHANGED);
                                sendExtendedQuery(f, (byte) 0x2e, (byte) 00);
                                break;
                            case 0x02:
                                m_feature.publish(OpenClosedType.CLOSED, StateChangeType.CHANGED);
                                sendExtendedQuery(f, (byte) 0x2e, (byte) 00);
                                break;
                            default: // do nothing
                                break;
                        }
                        break;
                    case 0x13: // OFF
                        switch (cmd2) {
                            case 0x01: // Group 1
                                m_feature.publish(OpenClosedType.CLOSED, StateChangeType.CHANGED);
                                sendExtendedQuery(f, (byte) 0x2e, (byte) 00);
                                break;
                            default: // do nothing
                                break;
                        }
                        break;
                }
            } catch (FieldException e) {
                logger.debug("{} no cmd2 found, dropping msg {}", nm(), msg);
                return;
            }
        }
    }

Please note:

  • I am a .Net developer so please excuse any Java Faux pas
  • All of my Hidden Door Sensors are in the 2 nodes configuration so I haven’t tested the code to see if it works in the 1 node config.

My plan was to make this handler work for both node configurations but at the moment I have a new feature and device type to make this work that I am using for all of my (3) hidden door sensors:

Feature:

 <!-- Hidden Door Sensor (Two Nodes) -->
 <feature name="HiddenDoorSensorContact2Nodes">
	<message-dispatcher>DefaultDispatcher</message-dispatcher>
	<message-handler cmd="0x03">NoOpMsgHandler</message-handler>
	<message-handler cmd="0x11">OpenedOrClosedSleepingContactHandler</message-handler>
	<message-handler cmd="0x13">OpenedOrClosedSleepingContactHandler</message-handler>
	<message-handler cmd="0x19">NoOpMsgHandler</message-handler>
	<message-handler cmd="0x2e">NoOpMsgHandler</message-handler>
	<command-handler command="OnOffType">NoOpCommandHandler</command-handler>
	<poll-handler>NoPollHandler</poll-handler>
</feature>

Device:

<device productKey="F00.00.03">
     <model>2845-222</model>
     <description>Hidden Door Sensor (Two Nodes)</description>
     <feature name="contact2nodes">HiddenDoorSensorContact2Nodes</feature>
     <feature name="data">HiddenDoorSensorData</feature>
     <feature name="lastheardfrom">GenericLastTime</feature>
 </device>

Anyway, this all seems to work fine as long as I open and then close the door with a significant delay between the open and the close. If the door is opened and then closed too quickly, then OH never gets the CLOSED event.

I dug around in the InsteonPLM.log file and I have found what could be the problem.

2017-06-05 12:33:57 org.openhab.binding.insteonplm.InsteonPLMActiveBinding$PortListener.msg(InsteonPLMActiveBinding.java:591) - got msg: IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:00.00.01|messageFlags:0xCB=ALL_LINK_BROADCAST:3:2|command1:0x11|command2:0x01|
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.MessageDispatcher.handleAllLinkMessage(MessageDispatcher.java:75) - all link message: IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:00.00.01|messageFlags:0xCB=ALL_LINK_BROADCAST:3:2|command1:0x11|command2:0x01|
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.MessageDispatcher.handleAllLinkMessage(MessageDispatcher.java:77) - all link message is no duplicate: true/true
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.MessageDispatcher.handleAllLinkMessage(MessageDispatcher.java:79) - 2C.74.E7:HiddenDoorSensorData->NoOpMsgHandler cmd1:0x11 group 1/1:IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:00.00.01|messageFlags:0xCB=ALL_LINK_BROADCAST:3:2|command1:0x11|command2:0x01|
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.MessageDispatcher.handleAllLinkMessage(MessageDispatcher.java:75) - all link message: IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:00.00.01|messageFlags:0xCB=ALL_LINK_BROADCAST:3:2|command1:0x11|command2:0x01|
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.MessageDispatcher.handleAllLinkMessage(MessageDispatcher.java:77) - all link message is no duplicate: true/true
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.MessageDispatcher.handleAllLinkMessage(MessageDispatcher.java:79) - 2C.74.E7:HiddenDoorSensorContact2Nodes->OpenedOrClosedSleepingContactHandler cmd1:0x11 group 1/-1:IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:00.00.01|messageFlags:0xCB=ALL_LINK_BROADCAST:3:2|command1:0x11|command2:0x01|
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.DeviceFeature.publish(DeviceFeature.java:321) - 2C.74.E7:HiddenDoorSensorContact2Nodes publishing: OPEN
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.DeviceFeature.publish(DeviceFeature.java:321) - 2C.74.E7:GenericLastTime publishing: 2017-06-05T12:33:57
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.InsteonDevice.processRequestQueue(InsteonDevice.java:451) - still waiting for query reply from 2C.74.E7 for another 1595 usec
2017-06-05 12:33:57 org.openhab.binding.insteonplm.InsteonPLMActiveBinding$PortListener.msg(InsteonPLMActiveBinding.java:591) - got msg: IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:00.00.01|messageFlags:0xC7=ALL_LINK_BROADCAST:3:1|command1:0x11|command2:0x01|
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.MessageDispatcher.handleAllLinkMessage(MessageDispatcher.java:75) - all link message: IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:00.00.01|messageFlags:0xC7=ALL_LINK_BROADCAST:3:1|command1:0x11|command2:0x01|
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.MessageDispatcher.handleAllLinkMessage(MessageDispatcher.java:75) - all link message: IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:00.00.01|messageFlags:0xC7=ALL_LINK_BROADCAST:3:1|command1:0x11|command2:0x01|
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.DeviceFeature.publish(DeviceFeature.java:321) - 2C.74.E7:GenericLastTime publishing: 2017-06-05T12:33:57
2017-06-05 12:33:57 org.openhab.binding.insteonplm.InsteonPLMActiveBinding$PortListener.msg(InsteonPLMActiveBinding.java:591) - got msg: IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:44.31.A5|messageFlags:0x41=ALL_LINK_CLEANUP:1:0|command1:0x11|command2:0x01|
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.MessageDispatcher.handleAllLinkMessage(MessageDispatcher.java:75) - all link message: IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:44.31.A5|messageFlags:0x41=ALL_LINK_CLEANUP:1:0|command1:0x11|command2:0x01|
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.MessageDispatcher.handleAllLinkMessage(MessageDispatcher.java:75) - all link message: IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:44.31.A5|messageFlags:0x41=ALL_LINK_CLEANUP:1:0|command1:0x11|command2:0x01|
2017-06-05 12:33:57 org.openhab.binding.insteonplm.internal.device.DeviceFeature.publish(DeviceFeature.java:321) - 2C.74.E7:GenericLastTime publishing: 2017-06-05T12:33:57
2017-06-05 12:33:59 org.openhab.binding.insteonplm.internal.device.InsteonDevice.processRequestQueue(InsteonDevice.java:454) - gave up waiting for query reply from device 2C.74.E7
2017-06-05 12:33:59 org.openhab.binding.insteonplm.internal.device.InsteonDevice.processRequestQueue(InsteonDevice.java:459) - qe taken off direct: HiddenDoorSensorContact2Nodes(1:1:5) OUT:Cmd:0x62|toAddress:2C.74.E7|messageFlags:0x1F=DIRECT:3:3|command1:0x2E|command2:0x00|userData1:0x00|userData2:0x00|userData3:0x00|userData4:0x00|userData5:0x00|userData6:0x00|userData7:0x00|userData8:0x00|userData9:0x00|userData10:0x00|userData11:0x00|userData12:0x00|userData13:0x00|userData14:0xD2|
2017-06-05 12:33:59 org.openhab.binding.insteonplm.internal.device.InsteonDevice.processRequestQueue(InsteonDevice.java:479) - next request queue processed in 2000 msec, quiettime = 2000
2017-06-05 12:33:59 org.openhab.binding.insteonplm.internal.driver.Port$IOStreamWriter.run(Port.java:415) - writing (500): OUT:Cmd:0x62|toAddress:2C.74.E7|messageFlags:0x1F=DIRECT:3:3|command1:0x2E|command2:0x00|userData1:0x00|userData2:0x00|userData3:0x00|userData4:0x00|userData5:0x00|userData6:0x00|userData7:0x00|userData8:0x00|userData9:0x00|userData10:0x00|userData11:0x00|userData12:0x00|userData13:0x00|userData14:0xD2|
2017-06-05 12:34:01 org.openhab.binding.insteonplm.internal.device.RequestQueueManager$RequestQueueReader.run(RequestQueueManager.java:137) - device queue for 2C.74.E7 is empty!
2017-06-05 12:34:02 org.openhab.binding.insteonplm.InsteonPLMActiveBinding$PortListener.msg(InsteonPLMActiveBinding.java:591) - got msg: IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:44.31.A5|messageFlags:0x4B=ALL_LINK_CLEANUP:3:2|command1:0x11|command2:0x02|
2017-06-05 12:34:02 org.openhab.binding.insteonplm.internal.device.MessageDispatcher.handleAllLinkMessage(MessageDispatcher.java:75) - all link message: IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:44.31.A5|messageFlags:0x4B=ALL_LINK_CLEANUP:3:2|command1:0x11|command2:0x02|
2017-06-05 12:34:02 org.openhab.binding.insteonplm.internal.device.MessageDispatcher.handleAllLinkMessage(MessageDispatcher.java:75) - all link message: IN:Cmd:0x50|fromAddress:2C.74.E7|toAddress:44.31.A5|messageFlags:0x4B=ALL_LINK_CLEANUP:3:2|command1:0x11|command2:0x02|
2017-06-05 12:34:02 org.openhab.binding.insteonplm.internal.device.DeviceFeature.publish(DeviceFeature.java:321) - 2C.74.E7:GenericLastTime publishing: 2017-06-05T12:34:02 

It looks like the binding is seeing the OPEN (0x11 on group 1) as an ALL_LINK_BROADCAST but then when the CLOSE (0x11 on group 2) comes in, the binding is seeing it as and ALL_LINK_CLEANUP so therefore not interpreting it as a command and not triggering an OH event.

I could be way off on my theory as I’m still trying to learn but any ideas/advice would be appreciated.

Have a look at this:

There was lots of discussion on this some time ago. There is an issue with the way the binding handles this sensor. I just implemented some changes to the insteon-terminal code to be able to support the hidden door sensors there for configuration of 1 node/2 mode and open/close repeat etc. This was going to be my next thing to tackle.

Its been a while since I read that other thread, but IIRC, I think the issue is exactly what you stated: if operated too quickly the messages get rejected a duplicates. That thread has a lot of suggestions for work arounds, but I think the fix is probably a change to the part of the code that attempts to filter out duplicates. Unfortunately I don’t quite understand that bit very well.

I’ve been using the work around where I set the sensors to repeat their open/closed status (every 5 mins for 50 mins). That way if one gets missed, it will be corrected in 5 mins. OK for overall status, but not good for automating anything.

@tommycw10 Thanks! That thread seems to cover everything I am seeing and makes sense as to the reasons behind it.
In the middle there there are some, as far as I can see, plausible ideas for how to solve this issue, but updating the code around handling duplicates is beyond what I am comfortable with at the moment.

It’s a shame the solution seems to be to use a Z-wave sensor instead, especially since these Insteon door sensors work reliably when controlled by Houslinc. The other ideas around repeating etc. make me worry about the battery life and would not provide a very responsive solution.

I would like to think I could get the code right eventually to make this work without completely breaking everything else but I doubt I will get anywhere with this any time soon.