mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 07:02:02 +01:00
[insteon] Add device refresh all command parameter (#18051)
Signed-off-by: Jeremy Setton <jeremy.setton@gmail.com>
This commit is contained in:
parent
19ca89c301
commit
51b5c89b6b
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user