@@ -103,7 +103,8 @@ public List<String> getUsages() {
103
103
"set a button radio group for a configured Insteon KeypadLinc device" ),
104
104
buildCommandUsage (CLEAR_BUTTON_RADIO_GROUP + " <thingId> <button1> <button2> [<button3> ... <button7>]" ,
105
105
"clear a button radio group for a configured Insteon KeypadLinc device" ),
106
- buildCommandUsage (REFRESH + " <thingId>" , "refresh data for a configured Insteon device" ));
106
+ buildCommandUsage (REFRESH + " " + ALL_OPTION + "|<thingId>" ,
107
+ "refresh data for a specific or all configured Insteon devices" ));
107
108
}
108
109
109
110
@ Override
@@ -222,7 +223,11 @@ public void execute(String[] args, Console console) {
222
223
break ;
223
224
case REFRESH :
224
225
if (args .length == 2 ) {
225
- refreshDevice (console , args [1 ]);
226
+ if (ALL_OPTION .equals (args [1 ])) {
227
+ refreshDevices (console );
228
+ } else {
229
+ refreshDevice (console , args [1 ], true );
230
+ }
226
231
} else {
227
232
printUsage (console , args [0 ]);
228
233
}
@@ -246,7 +251,6 @@ public boolean complete(String[] args, int cursorArgumentIndex, int cursorPositi
246
251
strings = getAllDeviceHandlers ().map (InsteonThingHandler ::getThingId ).toList ();
247
252
break ;
248
253
case LIST_DATABASE :
249
- case REFRESH :
250
254
strings = getInsteonDeviceHandlers ().map (InsteonDeviceHandler ::getThingId ).toList ();
251
255
break ;
252
256
case ADD_DATABASE_CONTROLLER :
@@ -272,6 +276,7 @@ public boolean complete(String[] args, int cursorArgumentIndex, int cursorPositi
272
276
break ;
273
277
case LIST_MISSING_LINKS :
274
278
case ADD_MISSING_LINKS :
279
+ case REFRESH :
275
280
strings = Stream .concat (Stream .of (ALL_OPTION ),
276
281
getInsteonDeviceHandlers ().map (InsteonDeviceHandler ::getThingId )).toList ();
277
282
break ;
@@ -510,7 +515,7 @@ private void addMissingLinks(Console console, String thingId) {
510
515
if (!device .isAwake () || !device .isResponding ()) {
511
516
console .println ("Scheduling " + deviceLinkCount + " missing links for device "
512
517
+ device .getAddress () + " to be added to its link database the next time it is "
513
- + (device .isBatteryPowered () ? "awake" : "responding " ) + "." );
518
+ + (device .isBatteryPowered () ? "awake" : "online " ) + "." );
514
519
} else {
515
520
console .println ("Adding " + deviceLinkCount + " missing links for device " + device .getAddress ()
516
521
+ " to its link database..." );
@@ -605,7 +610,7 @@ private void applyDatabaseChanges(Console console, String thingId, boolean isCon
605
610
if (!device .isAwake () || !device .isResponding () || !getModem ().getDB ().isComplete ()) {
606
611
console .println ("Scheduling " + count + " pending changes for device " + device .getAddress ()
607
612
+ " to be applied to its link database the next time it is "
608
- + (device .isBatteryPowered () ? "awake" : "responding " ) + "." );
613
+ + (device .isBatteryPowered () ? "awake" : "online " ) + "." );
609
614
} else {
610
615
console .println ("Applying " + count + " pending changes to link database for device "
611
616
+ device .getAddress () + "..." );
@@ -694,7 +699,11 @@ private void clearButtonRadioGroup(Console console, String[] args) {
694
699
}
695
700
}
696
701
697
- private void refreshDevice (Console console , String thingId ) {
702
+ private void refreshDevices (Console console ) {
703
+ getInsteonDeviceHandlers ().forEach (handler -> refreshDevice (console , handler .getThingId (), false ));
704
+ }
705
+
706
+ private void refreshDevice (Console console , String thingId , boolean immediate ) {
698
707
InsteonDevice device = getInsteonDevice (thingId );
699
708
if (device == null ) {
700
709
console .println ("The device " + thingId + " is not configured or enabled!" );
@@ -706,10 +715,10 @@ private void refreshDevice(Console console, String thingId) {
706
715
device .getLinkDB ().setReload (true );
707
716
device .resetFeaturesQueryStatus ();
708
717
709
- if (!device .isAwake () || !device .isResponding () || !getModem ().getDB ().isComplete ()) {
710
- console .println (
711
- "The device " + device . getAddress () + " is scheduled to be refreshed the next time it is "
712
- + (device .isBatteryPowered () ? "awake" : "responding " ) + "." );
718
+ if (!device .isAwake () || !device .isResponding () || !getModem ().getDB ().isComplete () || ! immediate ) {
719
+ console .println ("The device " + device . getAddress ()
720
+ + " is scheduled to be refreshed the next time it is "
721
+ + (device .isBatteryPowered () ? "awake" : ! device . isResponding () ? "online" : "polled " ) + "." );
713
722
} else {
714
723
console .println ("Refreshing device " + device .getAddress () + "..." );
715
724
device .doPoll (0L );
0 commit comments