I have an Insteon Leak Sensor (Model 2852) and I’d like to add heartbeat support for it since this is an indication of battery status (there is no battery level reporting). The Insteon binding’s device_features.xml maps a cmd attribute (“Command 1”) to message handlers. However, the leak sensor heartbeat uses the same primary command as the wet/dry status notifications. For the heartbeat, the Command 2 value (“group” attribute in device_features.xml) is different.
I’m considering modifying the device_features.xml parsing to use both Command 1 (cmd) and Command 2 (group) as the key for message handlers and then use the extended keys to add the leak sensor heartbeat handlers. I’m wondering if @Bernd_Pfrommer or others have any concerns about this approach.
What do you want to ultimately do with the heartbeat? Parse it, and update the contact to wet/dry? In that case you would not need to add a new feature, but just modify the existing feature, currently “#contact”.
Assuming you would be happy with just that (parsing the incoming message successfully should also update the “lastheardfrom” feature, so you could see when that device has last given some sign of life (although it might already do that right now, by the mere fact that a message has come in from that device, whether it’s handled or not).
I’m sure you’ve seen these notes, but here’s the link for completeness:
Do you know what it is currently doing with the heartbeat messages? Do you have the debug log switched on? By code inspection, both the 0x11 and 0x13 heartbeat should reach the OpenedOrClosedContactHandler, but the 0x13 is discarded right away, and the 0x11 will be discarded later because cmd2 = 0x04.
I would modify the OpenedOrClosedContactHandler such that it will process both 0x11 and 0x13 messages. The 0x13 messages should only be processed if cmd2 = 0x04, and should translate to “wet” (publish CLOSED). The 0x11 should be processed as before, but should also publish OPEN(dry) when cmd2 = 0x04.
Docs say it only sends that message out once ever 24h. Be prepared for a long development cycle
I’m currently using the exec binding to scan the log files for the most recent heartbeat message processing (running the InsteonPLM MessageDispatcher at debug level). Like you and the documentation say, it sends a heartbeat about every 24 hours. I process both the timestamp and the status from the log.
If the lastheardfrom is updated whether or not the message is dispatched then that may work for the timestamp. I hadn’t thought of that.
Yes, the following is an example log message…
2015-10-27 01:45:45 DEBUG o.o.b.i.i.d.MessageDispatcher[:72]- 36.B0.D0:LeakSensorContact->OpenedOrClosedContactHandler cmd1:0x11 group 4/-1:IN:Cmd:0x50|fromAddress:36.B0.D0|toAddress:00.00.04|messageFlags:0xCB=ALL_LINK_BROADCAST:3:2|command1:0x11|command2:0x04|
The handler is invoked but it doesn’t recognize the group 4 (cmd2).
That sounds like it would work. I’ll try it out and submit a PR if there aren’t any other issues. Thanks!
@steve1 - great, thanks for pointing me to it. I must have something screwed up with my lastheardfrom item or sitemap then, I’ve had this running for a couple weeks and last heard from still is undated. I’ll check it out. Thanks!
OK, so I’ve played around with this for a few days. My leak sensor work fine showing me both wet and dry conditions (shorting leads to test for wet and pushing button to go back to dry). When I test this, it also populates the Last heard from field with the date/time of the change. I have both the sensor status and the LHF on my sitemap so I can easily see these, which makes me pretty confident that the sensor and openhab are set up correctly. I have gone more than 24 hours with the LHF not being updated so I have to assume the the heartbeat is not updating my LHF field.
Here are the lines in my PLM’s DB for the leak sensor. Do I need another special link for the heartbeat?
Bernd, as you pointed out: from the developer’s notes, it appeared that the heartbeat signal was sent to group 4. I had thought that the logfile in debug mode would have shown the incoming group 4 message whether or not my PLM was linked to group 4 for my leak sensor and I saw no traffic to group 4. I decided to add that link anyway and a few hours later I saw an update to my LastHeardFrom without a change in state of my leak sensor, so I went and checked my log and saw this:
2017-04-09 22:06:24 DEBUG o.o.b.i.InsteonPLMActiveBinding[:581]- got msg: IN:Cmd:0x50|fromAddress:3F.A0.8F|toAddress:00.00.04|messageFlags:0xCF=ALL_LINK_BROADCAST:3:3|command1:0x11|command2:0x04|
2017-04-09 22:06:24 DEBUG o.o.b.i.i.d.MessageDispatcher[:68]- all link message: IN:Cmd:0x50|fromAddress:3F.A0.8F|toAddress:00.00.04|messageFlags:0xCF=ALL_LINK_BROADCAST:3:3|command1:0x11|command2:0x04|
2017-04-09 22:06:24 DEBUG o.o.b.i.i.d.MessageDispatcher[:70]- all link message is no duplicate: true/true
2017-04-09 22:06:24 DEBUG o.o.b.i.i.d.MessageDispatcher[:72]- 3F.A0.8F:LeakSensorContact->OpenedOrClosedContactHandler cmd1:0x11 group 4/-1:IN:Cmd:0x50|fromAddress:3F.A0.8F|toAddress:00.00.04|messageFlags:0xCF=ALL_LINK_BROADCAST:3:3|command1:0x11|command2:0x04|
2017-04-09 22:06:24 DEBUG o.o.b.i.i.device.DeviceFeature[:264]- 3F.A0.8F:LeakSensorContact publishing: OPEN
2017-04-09 22:06:24 DEBUG o.o.b.i.i.device.DeviceFeature[:264]- 3F.A0.8F:GenericLastTime publishing: 2017-04-09T22:06:24
2017-04-09 22:06:25 DEBUG o.o.b.i.InsteonPLMActiveBinding[:581]- got msg: IN:Cmd:0x50|fromAddress:3F.A0.8F|toAddress:00.00.04|messageFlags:0xCF=ALL_LINK_BROADCAST:3:3|command1:0x11|command2:0x04|
2017-04-09 22:06:25 DEBUG o.o.b.i.i.d.MessageDispatcher[:68]- all link message: IN:Cmd:0x50|fromAddress:3F.A0.8F|toAddress:00.00.04|messageFlags:0xCF=ALL_LINK_BROADCAST:3:3|command1:0x11|command2:0x04|
2017-04-09 22:06:25 DEBUG o.o.b.i.i.device.DeviceFeature[:264]- 3F.A0.8F:GenericLastTime publishing: 2017-04-09T22:06:25
@tommycw10 or anyone else who has leak sensors working
Would you be able to share your leak sensor db? I tried adding my modem as a responder to group 4 to get the heartbeat messages, but not sure if it is working. My leak sensor contact item does not seem to change back to Dry unless I press the button.
Here is my link table for the sensor. Do you see if I did it incorrectly?
getting db, be patient!
sent db query msg, incoming records: 1 2 3 4dbbuilder.done() is called
0fff modem 30.DC.6C CTRL 11100010 group: ff ON LVL: 3 RMPRT: 0 BUTTON: 0
0ff7 modem 30.DC.6C RESP 10100010 group: 01 ON LVL: 3 RMPRT: 0 BUTTON: 0
0fef modem 30.DC.6C (RESP) 00100010 group: 04 ON LVL: 0 RMPRT: 0 BUTTON: 4
0fe7 00.00.00 00.00.00 (STOP) 00000000 group: 00 ON LVL: 0 RMPRT: 0 BUTTON: 0