Skip to content

Commit f4338cc

Browse files
authoredFeb 16, 2025
[insteon] Fix missing links implementation (openhab#18274)
Signed-off-by: Jeremy Setton <jeremy.setton@gmail.com>
1 parent 2e1eb1f commit f4338cc

File tree

14 files changed

+69
-245
lines changed

14 files changed

+69
-245
lines changed
 

‎bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonBindingConstants.java

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public class InsteonBindingConstants {
7575
public static final String FEATURE_LED_ON_OFF = "ledOnOff";
7676
public static final String FEATURE_LINK_FF_GROUP = "linkFFGroup";
7777
public static final String FEATURE_LOW_BATTERY_THRESHOLD = "lowBatteryThreshold";
78+
public static final String FEATURE_MONITOR_MODE = "monitorMode";
7879
public static final String FEATURE_ON_LEVEL = "onLevel";
7980
public static final String FEATURE_PING = "ping";
8081
public static final String FEATURE_RAMP_RATE = "rampRate";

‎bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/command/DeviceCommand.java

+18-17
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.openhab.binding.insteon.internal.device.InsteonDevice;
2929
import org.openhab.binding.insteon.internal.device.ProductData;
3030
import org.openhab.binding.insteon.internal.device.database.LinkDBRecord;
31+
import org.openhab.binding.insteon.internal.device.database.ModemDBRecord;
3132
import org.openhab.binding.insteon.internal.device.feature.FeatureEnums.KeypadButtonToggleMode;
3233
import org.openhab.binding.insteon.internal.handler.InsteonDeviceHandler;
3334
import org.openhab.binding.insteon.internal.handler.InsteonThingHandler;
@@ -465,9 +466,9 @@ private void listMissingLinks(Console console, String thingId) {
465466
console.println("The modem database is not loaded yet.");
466467
} else {
467468
List<String> deviceLinks = device.getMissingDeviceLinks().entrySet().stream()
468-
.map(entry -> String.format("%s: %s", entry.getKey(), entry.getValue().getRecord())).toList();
469+
.map(entry -> String.format("%s: %s", entry.getKey(), entry.getValue())).toList();
469470
List<String> modemLinks = device.getMissingModemLinks().entrySet().stream()
470-
.map(entry -> String.format("%s: %s", entry.getKey(), entry.getValue().getRecord())).toList();
471+
.map(entry -> String.format("%s: %s", entry.getKey(), entry.getValue())).toList();
471472
if (deviceLinks.isEmpty() && modemLinks.isEmpty()) {
472473
console.println("There are no missing links for device " + device.getAddress() + ".");
473474
} else {
@@ -499,33 +500,33 @@ private void addMissingLinks(Console console, String thingId) {
499500
console.println("The device " + thingId + " is not configured or enabled!");
500501
} else if (!device.getLinkDB().isComplete()) {
501502
console.println("The link database for device " + thingId + " is not loaded yet.");
502-
} else if (!device.getLinkDB().getChanges().isEmpty()) {
503-
console.println("The link database for device " + thingId + " has pending changes.");
504503
} else if (!getModem().getDB().isComplete()) {
505504
console.println("The modem database is not loaded yet.");
506-
} else if (!getModem().getDB().getChanges().isEmpty()) {
507-
console.println("The modem database has pending changes.");
508505
} else {
509-
int deviceLinkCount = device.getMissingDeviceLinks().size();
510-
int modemLinkCount = device.getMissingModemLinks().size();
511-
if (deviceLinkCount == 0 && modemLinkCount == 0) {
506+
List<LinkDBRecord> deviceLinks = device.getMissingDeviceLinks().values().stream().toList();
507+
List<ModemDBRecord> modemLinks = device.getMissingModemLinks().values().stream().toList();
508+
if (deviceLinks.isEmpty() && modemLinks.isEmpty()) {
512509
console.println("There are no missing links for device " + device.getAddress() + ".");
513510
} else {
514-
if (deviceLinkCount > 0) {
511+
if (!deviceLinks.isEmpty()) {
515512
if (!device.isAwake() || !device.isResponding()) {
516-
console.println("Scheduling " + deviceLinkCount + " missing links for device "
513+
console.println("Scheduling " + deviceLinks.size() + " missing links for device "
517514
+ device.getAddress() + " to be added to its link database the next time it is "
518515
+ (device.isBatteryPowered() ? "awake" : "online") + ".");
519516
} else {
520-
console.println("Adding " + deviceLinkCount + " missing links for device " + device.getAddress()
521-
+ " to its link database...");
517+
console.println("Adding " + deviceLinks.size() + " missing links for device "
518+
+ device.getAddress() + " to its link database...");
522519
}
523-
device.addMissingDeviceLinks();
520+
deviceLinks.forEach(record -> device.getLinkDB().markRecordForAddOrModify(record.getAddress(),
521+
record.getGroup(), record.isController(), record.getData()));
522+
device.getLinkDB().update();
524523
}
525-
if (modemLinkCount > 0) {
526-
console.println("Adding " + modemLinkCount + " missing links for device " + device.getAddress()
524+
if (!modemLinks.isEmpty()) {
525+
console.println("Adding " + modemLinks.size() + " missing links for device " + device.getAddress()
527526
+ " to the modem database...");
528-
device.addMissingModemLinks();
527+
modemLinks.forEach(record -> getModem().getDB().markRecordForAddOrModify(record.getAddress(),
528+
record.getGroup(), record.isController(), record.getData()));
529+
getModem().getDB().update();
529530
}
530531
}
531532
}

‎bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/DefaultLink.java

+2-15
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@
1212
*/
1313
package org.openhab.binding.insteon.internal.device;
1414

15-
import java.util.List;
16-
1715
import org.eclipse.jdt.annotation.NonNullByDefault;
1816
import org.openhab.binding.insteon.internal.device.database.LinkDBRecord;
1917
import org.openhab.binding.insteon.internal.device.database.ModemDBRecord;
20-
import org.openhab.binding.insteon.internal.transport.message.Msg;
2118

2219
/**
2320
* The {@link DefaultLink} represents a device default link
@@ -29,13 +26,11 @@ public class DefaultLink {
2926
private String name;
3027
private LinkDBRecord linkDBRecord;
3128
private ModemDBRecord modemDBRecord;
32-
private List<Msg> commands;
3329

34-
public DefaultLink(String name, LinkDBRecord linkDBRecord, ModemDBRecord modemDBRecord, List<Msg> commands) {
30+
public DefaultLink(String name, LinkDBRecord linkDBRecord, ModemDBRecord modemDBRecord) {
3531
this.name = name;
3632
this.linkDBRecord = linkDBRecord;
3733
this.modemDBRecord = modemDBRecord;
38-
this.commands = commands;
3934
}
4035

4136
public String getName() {
@@ -50,16 +45,8 @@ public ModemDBRecord getModemDBRecord() {
5045
return modemDBRecord;
5146
}
5247

53-
public List<Msg> getCommands() {
54-
return commands;
55-
}
56-
5748
@Override
5849
public String toString() {
59-
String s = name + "|linkDB:" + linkDBRecord + "|modemDB:" + modemDBRecord;
60-
if (!commands.isEmpty()) {
61-
s += "|commands:" + commands;
62-
}
63-
return s;
50+
return name + "|linkDB:" + linkDBRecord + "|modemDB:" + modemDBRecord;
6451
}
6552
}

‎bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/DeviceFeature.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ public int getGroup() {
236236

237237
public int getComponentId() {
238238
int componentId = 0;
239-
if (device instanceof InsteonDevice insteonDevice) {
239+
if (device instanceof InsteonDevice insteonDevice && isControllerOrResponderFeature()) {
240240
// use feature group as component id if device has more than one controller or responder feature,
241-
// othewise use the component id of the link db first record
241+
// set to 1 if device link db has a matching record, otherwise fall back to 0
242242
if (insteonDevice.getControllerOrResponderFeatures().size() > 1) {
243243
componentId = getGroup();
244-
} else {
245-
componentId = insteonDevice.getLinkDB().getFirstRecordComponentId();
244+
} else if (insteonDevice.getLinkDB().hasComponentIdRecord(1, isControllerFeature())) {
245+
componentId = 1;
246246
}
247247
}
248248
return componentId;

‎bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/DeviceType.java

-62
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
import java.util.stream.Collectors;
2222

2323
import org.eclipse.jdt.annotation.NonNullByDefault;
24-
import org.eclipse.jdt.annotation.Nullable;
25-
import org.openhab.binding.insteon.internal.transport.message.FieldException;
26-
import org.openhab.binding.insteon.internal.transport.message.InvalidMessageTypeException;
27-
import org.openhab.binding.insteon.internal.transport.message.Msg;
2824
import org.openhab.binding.insteon.internal.utils.HexUtils;
2925

3026
/**
@@ -175,7 +171,6 @@ public static class DefaultLinkEntry {
175171
private boolean controller;
176172
private int group;
177173
private byte[] data;
178-
private List<CommandEntry> commands = new ArrayList<>();
179174

180175
public DefaultLinkEntry(String name, boolean controller, int group, byte[] data) {
181176
this.name = name;
@@ -196,14 +191,6 @@ public byte[] getData() {
196191
return data;
197192
}
198193

199-
public List<CommandEntry> getCommands() {
200-
return commands;
201-
}
202-
203-
public void addCommand(CommandEntry command) {
204-
commands.add(command);
205-
}
206-
207194
@Override
208195
public String toString() {
209196
String s = name + "->";
@@ -212,55 +199,6 @@ public String toString() {
212199
s += "|data1:" + HexUtils.getHexString(data[0]);
213200
s += "|data2:" + HexUtils.getHexString(data[1]);
214201
s += "|data3:" + HexUtils.getHexString(data[2]);
215-
if (!commands.isEmpty()) {
216-
s += "|commands:" + commands;
217-
}
218-
return s;
219-
}
220-
}
221-
222-
/**
223-
* Class that reflects a command entry
224-
*/
225-
public static class CommandEntry {
226-
private String name;
227-
private int ext;
228-
private byte cmd1;
229-
private byte cmd2;
230-
private byte[] data;
231-
232-
public CommandEntry(String name, int ext, byte cmd1, byte cmd2, byte[] data) {
233-
this.name = name;
234-
this.ext = ext;
235-
this.cmd1 = cmd1;
236-
this.cmd2 = cmd2;
237-
this.data = data;
238-
}
239-
240-
public @Nullable Msg getMessage(InsteonDevice device) {
241-
try {
242-
if (ext == 0) {
243-
return Msg.makeStandardMessage(device.getAddress(), cmd1, cmd2);
244-
} else if (ext == 1) {
245-
return Msg.makeExtendedMessage(device.getAddress(), cmd1, cmd2, data,
246-
device.getInsteonEngine().supportsChecksum());
247-
} else if (ext == 2) {
248-
return Msg.makeExtendedMessageCRC2(device.getAddress(), cmd1, cmd2, data);
249-
}
250-
} catch (FieldException | InvalidMessageTypeException e) {
251-
}
252-
return null;
253-
}
254-
255-
@Override
256-
public String toString() {
257-
String s = name + "->";
258-
s += "ext:" + ext;
259-
s += "|cmd1:" + HexUtils.getHexString(cmd1);
260-
s += "|cmd2:" + HexUtils.getHexString(cmd2);
261-
s += "|data1:" + HexUtils.getHexString(data[0]);
262-
s += "|data2:" + HexUtils.getHexString(data[1]);
263-
s += "|data3:" + HexUtils.getHexString(data[2]);
264202
return s;
265203
}
266204
}

‎bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/DeviceTypeRegistry.java

-43
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
import org.eclipse.jdt.annotation.NonNullByDefault;
2020
import org.eclipse.jdt.annotation.Nullable;
2121
import org.openhab.binding.insteon.internal.InsteonResourceLoader;
22-
import org.openhab.binding.insteon.internal.device.DeviceType.CommandEntry;
2322
import org.openhab.binding.insteon.internal.device.DeviceType.DefaultLinkEntry;
2423
import org.openhab.binding.insteon.internal.device.DeviceType.FeatureEntry;
25-
import org.openhab.binding.insteon.internal.utils.HexUtils;
2624
import org.w3c.dom.Element;
2725
import org.w3c.dom.Node;
2826
import org.w3c.dom.NodeList;
@@ -249,52 +247,11 @@ private void parseDefaultLink(Element element, Map<String, DefaultLinkEntry> lin
249247
getHexAttributeAsByte(element, "data3") };
250248

251249
DefaultLinkEntry link = new DefaultLinkEntry(name, isController, group, data);
252-
253-
NodeList nodes = element.getChildNodes();
254-
for (int i = 0; i < nodes.getLength(); i++) {
255-
Node node = nodes.item(i);
256-
if (node.getNodeType() == Node.ELEMENT_NODE) {
257-
Element child = (Element) node;
258-
String nodeName = child.getNodeName();
259-
if ("command".equals(nodeName)) {
260-
link.addCommand(getDefaultLinkCommand(child));
261-
}
262-
}
263-
}
264-
265250
if (links.putIfAbsent(name, link) != null) {
266251
throw new SAXException("duplicate default link: " + name);
267252
}
268253
}
269254

270-
/**
271-
* Returns a default link command
272-
*
273-
* @param element element to parse
274-
* @return default link command
275-
* @throws SAXException
276-
*/
277-
private CommandEntry getDefaultLinkCommand(Element element) throws SAXException {
278-
String name = element.getAttribute("name");
279-
if (name.isEmpty()) {
280-
throw new SAXException("undefined default link command name");
281-
}
282-
int ext = getAttributeAsInteger(element, "ext");
283-
if (ext < 0 || ext > 2) {
284-
throw new SAXException("out of bound default link command ext argument: " + ext);
285-
}
286-
byte cmd1 = getHexAttributeAsByte(element, "cmd1");
287-
if (cmd1 == 0) {
288-
throw new SAXException("invalid default link command cmd1 argument: " + HexUtils.getHexString(cmd1));
289-
}
290-
byte cmd2 = getHexAttributeAsByte(element, "cmd2", (byte) 0x00);
291-
byte[] data = { getHexAttributeAsByte(element, "data1", (byte) 0x00),
292-
getHexAttributeAsByte(element, "data2", (byte) 0x00),
293-
getHexAttributeAsByte(element, "data3", (byte) 0x00) };
294-
295-
return new CommandEntry(name, ext, cmd1, cmd2, data);
296-
}
297-
298255
/**
299256
* Singleton instance function
300257
*

‎bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/InsteonDevice.java

+14-67
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import static org.openhab.binding.insteon.internal.InsteonBindingConstants.*;
1616

17-
import java.io.IOException;
1817
import java.util.HashMap;
1918
import java.util.LinkedHashMap;
2019
import java.util.LinkedList;
@@ -34,10 +33,7 @@
3433
import org.openhab.binding.insteon.internal.config.InsteonChannelConfiguration;
3534
import org.openhab.binding.insteon.internal.device.DeviceFeature.QueryStatus;
3635
import org.openhab.binding.insteon.internal.device.database.LinkDB;
37-
import org.openhab.binding.insteon.internal.device.database.LinkDBChange;
3836
import org.openhab.binding.insteon.internal.device.database.LinkDBRecord;
39-
import org.openhab.binding.insteon.internal.device.database.ModemDB;
40-
import org.openhab.binding.insteon.internal.device.database.ModemDBChange;
4137
import org.openhab.binding.insteon.internal.device.database.ModemDBEntry;
4238
import org.openhab.binding.insteon.internal.device.database.ModemDBRecord;
4339
import org.openhab.binding.insteon.internal.device.feature.FeatureEnums.DeviceTypeRenamer;
@@ -618,11 +614,8 @@ public void updateDefaultLinks() {
618614
// create modem db record
619615
ModemDBRecord modemDBRecord = ModemDBRecord.create(address, link.getGroup(), !link.isController(),
620616
!link.isController() ? productData.getRecordData() : new byte[3]);
621-
// create default link commands
622-
List<Msg> commands = link.getCommands().stream().map(command -> command.getMessage(this))
623-
.filter(Objects::nonNull).map(Objects::requireNonNull).toList();
624617
// add default link
625-
addDefaultLink(new DefaultLink(name, linkDBRecord, modemDBRecord, commands));
618+
addDefaultLink(new DefaultLink(name, linkDBRecord, modemDBRecord));
626619
});
627620
}
628621

@@ -644,14 +637,16 @@ private void addDefaultLink(DefaultLink link) {
644637
*
645638
* @return map of missing link db records based on default links
646639
*/
647-
public Map<String, LinkDBChange> getMissingDeviceLinks() {
648-
Map<String, LinkDBChange> links = new LinkedHashMap<>();
640+
public Map<String, LinkDBRecord> getMissingDeviceLinks() {
641+
Map<String, LinkDBRecord> links = new LinkedHashMap<>();
649642
if (linkDB.isComplete() && hasModemDBEntry()) {
643+
int linkCount = getDefaultLinks().size();
650644
for (DefaultLink link : getDefaultLinks()) {
651645
LinkDBRecord record = link.getLinkDBRecord();
652-
if ((record.getComponentId() > 0 && !linkDB.hasComponentIdRecord(record.getComponentId(), true))
653-
|| !linkDB.hasGroupRecord(record.getGroup(), true)) {
654-
links.put(link.getName(), LinkDBChange.forAdd(record));
646+
if ((linkCount > 1 && record.getComponentId() > 0
647+
&& !linkDB.hasComponentIdRecord(record.getComponentId(), record.isController()))
648+
|| !linkDB.hasGroupRecord(record.getGroup(), record.isController())) {
649+
links.put(link.getName(), record);
655650
}
656651
}
657652
}
@@ -663,14 +658,16 @@ public Map<String, LinkDBChange> getMissingDeviceLinks() {
663658
*
664659
* @return map of missing modem db records based on default links
665660
*/
666-
public Map<String, ModemDBChange> getMissingModemLinks() {
667-
Map<String, ModemDBChange> links = new LinkedHashMap<>();
661+
public Map<String, ModemDBRecord> getMissingModemLinks() {
662+
Map<String, ModemDBRecord> links = new LinkedHashMap<>();
668663
InsteonModem modem = getModem();
669664
if (modem != null && modem.getDB().isComplete() && hasModemDBEntry()) {
665+
State monitorMode = modem.getFeatureState(FEATURE_MONITOR_MODE);
670666
for (DefaultLink link : getDefaultLinks()) {
671667
ModemDBRecord record = link.getModemDBRecord();
672-
if (!modem.getDB().hasRecord(record.getAddress(), record.getGroup(), record.isController())) {
673-
links.put(link.getName(), ModemDBChange.forAdd(record));
668+
if ((OnOffType.OFF.equals(monitorMode) || record.isController())
669+
&& !modem.getDB().hasRecord(record.getAddress(), record.getGroup(), record.isController())) {
670+
links.put(link.getName(), record);
674671
}
675672
}
676673
}
@@ -700,56 +697,6 @@ public void logMissingLinks() {
700697
}
701698
}
702699

703-
/**
704-
* Adds missing links to link db for this device
705-
*/
706-
public void addMissingDeviceLinks() {
707-
if (getDefaultLinks().isEmpty()) {
708-
return;
709-
}
710-
List<LinkDBChange> changes = getMissingDeviceLinks().values().stream().distinct().toList();
711-
if (changes.isEmpty()) {
712-
logger.debug("no missing default links from link db to add for {}", address);
713-
} else {
714-
logger.trace("adding missing default links to link db for {}", address);
715-
linkDB.clearChanges();
716-
changes.forEach(linkDB::addChange);
717-
linkDB.update();
718-
}
719-
720-
InsteonModem modem = getModem();
721-
if (modem != null) {
722-
getMissingDeviceLinks().keySet().stream().map(this::getDefaultLink).filter(Objects::nonNull)
723-
.map(Objects::requireNonNull).flatMap(link -> link.getCommands().stream()).forEach(msg -> {
724-
try {
725-
modem.writeMessage(msg);
726-
} catch (IOException e) {
727-
logger.warn("message write failed for msg: {}", msg, e);
728-
}
729-
});
730-
}
731-
}
732-
733-
/**
734-
* Adds missing links to modem db for this device
735-
*/
736-
public void addMissingModemLinks() {
737-
InsteonModem modem = getModem();
738-
if (modem == null || getDefaultLinks().isEmpty()) {
739-
return;
740-
}
741-
List<ModemDBChange> changes = getMissingModemLinks().values().stream().distinct().toList();
742-
if (changes.isEmpty()) {
743-
logger.debug("no missing default links from modem db to add for {}", address);
744-
} else {
745-
logger.trace("adding missing default links to modem db for {}", address);
746-
ModemDB modemDB = modem.getDB();
747-
modemDB.clearChanges();
748-
changes.forEach(modemDB::addChange);
749-
modemDB.update();
750-
}
751-
}
752-
753700
/**
754701
* Sets a keypad button radio group
755702
*

‎bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/database/LinkDB.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ public int getLastRecordLocation() {
9292
}
9393
}
9494

95-
public int getFirstRecordComponentId() {
96-
return Optional.ofNullable(getFirstRecord()).map(LinkDBRecord::getComponentId).orElse(0);
97-
}
98-
9995
public @Nullable LinkDBRecord getRecord(int location) {
10096
synchronized (records) {
10197
return records.get(location);
@@ -351,8 +347,8 @@ public void update(long delay) {
351347
public @Nullable LinkDBRecord addRecord(LinkDBRecord record) {
352348
synchronized (records) {
353349
LinkDBRecord prevRecord = records.put(record.getLocation(), record);
354-
// move last record if overwritten
355-
if (prevRecord != null && prevRecord.isLast()) {
350+
// move last record if overwritten by a different record
351+
if (prevRecord != null && prevRecord.isLast() && !prevRecord.equals(record)) {
356352
int location = prevRecord.getLocation() - LinkDBRecord.SIZE;
357353
records.put(location, LinkDBRecord.withNewLocation(location, prevRecord));
358354
if (logger.isTraceEnabled()) {
@@ -414,7 +410,7 @@ public void clearChanges() {
414410
*
415411
* @param change the change to add
416412
*/
417-
public void addChange(LinkDBChange change) {
413+
private void addChange(LinkDBChange change) {
418414
synchronized (changes) {
419415
LinkDBChange prevChange = changes.put(change.getLocation(), change);
420416
if (prevChange == null) {

‎bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/database/LinkDBChange.java

-10
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ public static LinkDBChange forAdd(int location, InsteonAddress address, int grou
5151
return new LinkDBChange(LinkDBRecord.create(location, address, group, isController, data), ChangeType.ADD);
5252
}
5353

54-
/**
55-
* Factory method for creating a new LinkDBChange for add
56-
*
57-
* @param record the record to add
58-
* @return the link db change
59-
*/
60-
public static LinkDBChange forAdd(LinkDBRecord record) {
61-
return new LinkDBChange(record, ChangeType.ADD);
62-
}
63-
6454
/**
6555
* Factory method for creating a new LinkDBChange for modify
6656
*

‎bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/database/ModemDB.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public void clearChanges() {
391391
*
392392
* @param change the change to add
393393
*/
394-
public void addChange(ModemDBChange change) {
394+
private void addChange(ModemDBChange change) {
395395
ModemDBRecord record = change.getRecord();
396396
int index = getChangeIndex(record.getAddress(), record.getGroup(), record.isController());
397397
if (index == -1) {

‎bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/database/ModemDBChange.java

-10
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ public static ModemDBChange forAdd(InsteonAddress address, int group, boolean is
4040
return new ModemDBChange(ModemDBRecord.create(address, group, isController, data), ChangeType.ADD);
4141
}
4242

43-
/**
44-
* Factory method for creating a new ModemDBChange for add
45-
*
46-
* @param record the record to add
47-
* @return the modem db change
48-
*/
49-
public static ModemDBChange forAdd(ModemDBRecord record) {
50-
return new ModemDBChange(record, ChangeType.ADD);
51-
}
52-
5343
/**
5444
* Factory method for creating a new ModemDBChange for modify
5545
*

‎bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/feature/MessageHandler.java

+14
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,20 @@ protected State getBitState(boolean is24Hr) {
17181718
}
17191719
}
17201720

1721+
/**
1722+
* Thermostat status reporting reply message handler
1723+
*/
1724+
public static class ThermostatStatusReportingReplyHandler extends MessageHandler {
1725+
ThermostatStatusReportingReplyHandler(DeviceFeature feature) {
1726+
super(feature);
1727+
}
1728+
1729+
@Override
1730+
public void handleMessage(byte cmd1, Msg msg) {
1731+
logger.debug("{}: thermostat status reporting enabled on {}", nm(), getInsteonDevice().getAddress());
1732+
}
1733+
}
1734+
17211735
/**
17221736
* Venstar thermostat system mode message handler
17231737
*/

‎bundles/org.openhab.binding.insteon/src/main/resources/device-features.xml

+6
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,12 @@
922922
<command-handler default="true">NoOpCommandHandler</command-handler>
923923
<poll-handler>NoPollHandler</poll-handler>
924924
</feature-type>
925+
<feature-type name="ThermostatStatusReporting" hidden="true">
926+
<message-dispatcher>DefaultDispatcher</message-dispatcher>
927+
<message-handler command="0x19">ThermostatStatusReportingReplyHandler</message-handler>
928+
<message-handler default="true">NoOpMsgHandler</message-handler>
929+
<poll-handler ext="1" cmd1="0x2E" cmd2="0x00" d2="0x08">FlexPollHandler</poll-handler>
930+
</feature-type>
925931

926932
<feature-type name="VenstarCoolSetpoint">
927933
<message-dispatcher>DefaultDispatcher</message-dispatcher>

‎bundles/org.openhab.binding.insteon/src/main/resources/device-types.xml

+6-9
Original file line numberDiff line numberDiff line change
@@ -731,13 +731,12 @@
731731
<feature name="timeFormat">ThermostatTimeFormat</feature>
732732
<feature name="ledOnOff" bit="6">ThermostatOpFlags</feature>
733733
</feature-group>
734+
<feature name="reporting">ThermostatStatusReporting</feature>
734735
<default-link name="cooling" type="controller" group="1" data1="0x03" data2="0x00" data3="0x01"/>
735736
<default-link name="heating" type="controller" group="2" data1="0x03" data2="0x00" data3="0x02"/>
736737
<default-link name="dehumidifying" type="controller" group="3" data1="0x03" data2="0x00" data3="0x03"/>
737738
<default-link name="humidifying" type="controller" group="4" data1="0x03" data2="0x00" data3="0x04"/>
738-
<default-link name="broadcast" type="controller" group="239" data1="0x03" data2="0x00" data3="0xEF">
739-
<command name="enableStatusReporting" ext="1" cmd1="0x2E" cmd2="0x00" data2="0x08"/>
740-
</default-link>
739+
<default-link name="broadcast" type="controller" group="239" data1="0x03" data2="0x00" data3="0xEF"/>
741740
</device-type>
742741

743742
<device-type name="ClimateControl_WirelessThermostat" batteryPowered="true">
@@ -773,13 +772,12 @@
773772
<feature-group name="opFlagsGroup" type="OpFlagsGroup">
774773
<feature name="stayAwake" on="0x06" off="0x07">OpFlags</feature>
775774
</feature-group>
775+
<feature name="reporting">ThermostatStatusReporting</feature>
776776
<default-link name="cooling" type="controller" group="1" data1="0x03" data2="0x00" data3="0x01"/>
777777
<default-link name="heating" type="controller" group="2" data1="0x03" data2="0x00" data3="0x02"/>
778778
<default-link name="dehumidifying" type="controller" group="3" data1="0x03" data2="0x00" data3="0x03"/>
779779
<default-link name="humidifying" type="controller" group="4" data1="0x03" data2="0x00" data3="0x04"/>
780-
<default-link name="broadcast" type="controller" group="239" data1="0x03" data2="0x00" data3="0xEF">
781-
<command name="enableStatusReporting" ext="1" cmd1="0x2E" cmd2="0x00" data2="0x08"/>
782-
</default-link>
780+
<default-link name="broadcast" type="controller" group="239" data1="0x03" data2="0x00" data3="0xEF"/>
783781
</device-type>
784782

785783
<device-type name="ClimateControl_VenstarThermostat">
@@ -798,12 +796,11 @@
798796
<feature name="programLock" bit="7" on="0x04" off="0x05">OpFlags</feature>
799797
<feature name="ledOnOff" bit="5" on="0x06" off="0x07" inverted="true">OpFlags</feature>
800798
</feature-group>
799+
<feature name="reporting">ThermostatStatusReporting</feature>
801800
<default-link name="cooling" type="controller" group="1" data1="0x03" data2="0x00" data3="0x01"/>
802801
<default-link name="heating" type="controller" group="2" data1="0x03" data2="0x00" data3="0x02"/>
803802
<default-link name="fan" type="controller" group="3" data1="0x03" data2="0x00" data3="0x03"/>
804-
<default-link name="broadcast" type="controller" group="239" data1="0x03" data2="0x00" data3="0xEF">
805-
<command name="enableStatusReporting" ext="1" cmd1="0x2E" cmd2="0x00" data2="0x08"/>
806-
</default-link>
803+
<default-link name="broadcast" type="controller" group="239" data1="0x03" data2="0x00" data3="0xEF"/>
807804
</device-type>
808805

809806
<!-- Sensors and Actuators -->

0 commit comments

Comments
 (0)
Please sign in to comment.