Compare commits

...

3 Commits

Author SHA1 Message Date
Florian Hotze
578fe57f8d
Merge a64e72aff4 into 51b5c89b6b 2025-01-06 14:48:54 +01:00
Jeremy
51b5c89b6b
[insteon] Add device refresh all command parameter (#18051)
Signed-off-by: Jeremy Setton <jeremy.setton@gmail.com>
2025-01-06 13:09:20 +01:00
Jeremy
19ca89c301
[insteon] Fix legacy all link broadcast message not processed (#18049)
Signed-off-by: Jeremy Setton <jeremy.setton@gmail.com>
2025-01-06 13:08:17 +01:00
3 changed files with 22 additions and 13 deletions

View File

@ -514,7 +514,7 @@ public class InsteonLegacyBinding implements LegacyDriverListener, LegacyPortLis
private void handleInsteonMessage(Msg msg) throws FieldException { private void handleInsteonMessage(Msg msg) throws FieldException {
InsteonAddress toAddr = msg.getInsteonAddress("toAddress"); InsteonAddress toAddr = msg.getInsteonAddress("toAddress");
if (!msg.isBroadcast() && !driver.isMsgForUs(toAddr)) { if (!msg.isBroadcast() && !msg.isAllLinkBroadcast() && !driver.isMsgForUs(toAddr)) {
// not for one of our modems, do not process // not for one of our modems, do not process
return; return;
} }

View File

@ -103,7 +103,8 @@ public class DeviceCommand extends InsteonCommand {
"set a button radio group for a configured Insteon KeypadLinc device"), "set a button radio group for a configured Insteon KeypadLinc device"),
buildCommandUsage(CLEAR_BUTTON_RADIO_GROUP + " <thingId> <button1> <button2> [<button3> ... <button7>]", buildCommandUsage(CLEAR_BUTTON_RADIO_GROUP + " <thingId> <button1> <button2> [<button3> ... <button7>]",
"clear a button radio group for a configured Insteon KeypadLinc device"), "clear a button radio group for a configured Insteon KeypadLinc device"),
buildCommandUsage(REFRESH + " <thingId>", "refresh data for a configured Insteon device")); buildCommandUsage(REFRESH + " " + ALL_OPTION + "|<thingId>",
"refresh data for a specific or all configured Insteon devices"));
} }
@Override @Override
@ -222,7 +223,11 @@ public class DeviceCommand extends InsteonCommand {
break; break;
case REFRESH: case REFRESH:
if (args.length == 2) { if (args.length == 2) {
refreshDevice(console, args[1]); if (ALL_OPTION.equals(args[1])) {
refreshDevices(console);
} else {
refreshDevice(console, args[1], true);
}
} else { } else {
printUsage(console, args[0]); printUsage(console, args[0]);
} }
@ -246,7 +251,6 @@ public class DeviceCommand extends InsteonCommand {
strings = getAllDeviceHandlers().map(InsteonThingHandler::getThingId).toList(); strings = getAllDeviceHandlers().map(InsteonThingHandler::getThingId).toList();
break; break;
case LIST_DATABASE: case LIST_DATABASE:
case REFRESH:
strings = getInsteonDeviceHandlers().map(InsteonDeviceHandler::getThingId).toList(); strings = getInsteonDeviceHandlers().map(InsteonDeviceHandler::getThingId).toList();
break; break;
case ADD_DATABASE_CONTROLLER: case ADD_DATABASE_CONTROLLER:
@ -272,6 +276,7 @@ public class DeviceCommand extends InsteonCommand {
break; break;
case LIST_MISSING_LINKS: case LIST_MISSING_LINKS:
case ADD_MISSING_LINKS: case ADD_MISSING_LINKS:
case REFRESH:
strings = Stream.concat(Stream.of(ALL_OPTION), strings = Stream.concat(Stream.of(ALL_OPTION),
getInsteonDeviceHandlers().map(InsteonDeviceHandler::getThingId)).toList(); getInsteonDeviceHandlers().map(InsteonDeviceHandler::getThingId)).toList();
break; break;
@ -510,7 +515,7 @@ public class DeviceCommand extends InsteonCommand {
if (!device.isAwake() || !device.isResponding()) { if (!device.isAwake() || !device.isResponding()) {
console.println("Scheduling " + deviceLinkCount + " missing links for device " console.println("Scheduling " + deviceLinkCount + " missing links for device "
+ device.getAddress() + " to be added to its link database the next time it is " + device.getAddress() + " to be added to its link database the next time it is "
+ (device.isBatteryPowered() ? "awake" : "responding") + "."); + (device.isBatteryPowered() ? "awake" : "online") + ".");
} else { } else {
console.println("Adding " + deviceLinkCount + " missing links for device " + device.getAddress() console.println("Adding " + deviceLinkCount + " missing links for device " + device.getAddress()
+ " to its link database..."); + " to its link database...");
@ -605,7 +610,7 @@ public class DeviceCommand extends InsteonCommand {
if (!device.isAwake() || !device.isResponding() || !getModem().getDB().isComplete()) { if (!device.isAwake() || !device.isResponding() || !getModem().getDB().isComplete()) {
console.println("Scheduling " + count + " pending changes for device " + device.getAddress() console.println("Scheduling " + count + " pending changes for device " + device.getAddress()
+ " to be applied to its link database the next time it is " + " to be applied to its link database the next time it is "
+ (device.isBatteryPowered() ? "awake" : "responding") + "."); + (device.isBatteryPowered() ? "awake" : "online") + ".");
} else { } else {
console.println("Applying " + count + " pending changes to link database for device " console.println("Applying " + count + " pending changes to link database for device "
+ device.getAddress() + "..."); + device.getAddress() + "...");
@ -694,7 +699,11 @@ public class DeviceCommand extends InsteonCommand {
} }
} }
private void refreshDevice(Console console, String thingId) { private void refreshDevices(Console console) {
getInsteonDeviceHandlers().forEach(handler -> refreshDevice(console, handler.getThingId(), false));
}
private void refreshDevice(Console console, String thingId, boolean immediate) {
InsteonDevice device = getInsteonDevice(thingId); InsteonDevice device = getInsteonDevice(thingId);
if (device == null) { if (device == null) {
console.println("The device " + thingId + " is not configured or enabled!"); console.println("The device " + thingId + " is not configured or enabled!");
@ -706,10 +715,10 @@ public class DeviceCommand extends InsteonCommand {
device.getLinkDB().setReload(true); device.getLinkDB().setReload(true);
device.resetFeaturesQueryStatus(); device.resetFeaturesQueryStatus();
if (!device.isAwake() || !device.isResponding() || !getModem().getDB().isComplete()) { if (!device.isAwake() || !device.isResponding() || !getModem().getDB().isComplete() || !immediate) {
console.println( console.println("The device " + device.getAddress()
"The device " + device.getAddress() + " is scheduled to be refreshed the next time it is " + " is scheduled to be refreshed the next time it is "
+ (device.isBatteryPowered() ? "awake" : "responding") + "."); + (device.isBatteryPowered() ? "awake" : !device.isResponding() ? "online" : "polled") + ".");
} else { } else {
console.println("Refreshing device " + device.getAddress() + "..."); console.println("Refreshing device " + device.getAddress() + "...");
device.doPoll(0L); device.doPoll(0L);

View File

@ -334,7 +334,7 @@ public class LegacyDevice {
if (qe == null) { if (qe == null) {
return 0L; return 0L;
} }
if (!qe.getMsg().isBroadcast()) { if (!qe.getMsg().isAllLinkBroadcast()) {
logger.debug("qe taken off direct: {} {}", qe.getFeature(), qe.getMsg()); logger.debug("qe taken off direct: {} {}", qe.getFeature(), qe.getMsg());
lastQueryTime = timeNow; lastQueryTime = timeNow;
// mark feature as pending // mark feature as pending
@ -382,7 +382,7 @@ public class LegacyDevice {
synchronized (mrequestQueue) { synchronized (mrequestQueue) {
mrequestQueue.add(new QEntry(feature, msg, now + delay)); mrequestQueue.add(new QEntry(feature, msg, now + delay));
} }
if (!msg.isBroadcast()) { if (!msg.isAllLinkBroadcast()) {
msg.setQuietTime(QUIET_TIME_DIRECT_MESSAGE); msg.setQuietTime(QUIET_TIME_DIRECT_MESSAGE);
} }
logger.trace("enqueing direct message with delay {}", delay); logger.trace("enqueing direct message with delay {}", delay);