@@ -47,6 +47,8 @@ public class ModemCommand extends InsteonCommand {
47
47
48
48
private static final String LIST_ALL = "listAll" ;
49
49
private static final String LIST_DATABASE = "listDatabase" ;
50
+ private static final String LIST_FEATURES = "listFeatures" ;
51
+ private static final String LIST_PRODUCT_DATA = "listProductData" ;
50
52
private static final String RELOAD_DATABASE = "reloadDatabase" ;
51
53
private static final String BACKUP_DATABASE = "backupDatabase" ;
52
54
private static final String RESTORE_DATABASE = "restoreDatabase" ;
@@ -60,9 +62,10 @@ public class ModemCommand extends InsteonCommand {
60
62
private static final String RESET = "reset" ;
61
63
private static final String SWITCH = "switch" ;
62
64
63
- private static final List <String > SUBCMDS = List .of (LIST_ALL , LIST_DATABASE , RELOAD_DATABASE , BACKUP_DATABASE ,
64
- RESTORE_DATABASE , ADD_DATABASE_CONTROLLER , ADD_DATABASE_RESPONDER , DELETE_DATABASE_RECORD ,
65
- APPLY_DATABASE_CHANGES , CLEAR_DATABASE_CHANGES , ADD_DEVICE , REMOVE_DEVICE , RESET , SWITCH );
65
+ private static final List <String > SUBCMDS = List .of (LIST_ALL , LIST_DATABASE , LIST_FEATURES , LIST_PRODUCT_DATA ,
66
+ RELOAD_DATABASE , BACKUP_DATABASE , RESTORE_DATABASE , ADD_DATABASE_CONTROLLER , ADD_DATABASE_RESPONDER ,
67
+ DELETE_DATABASE_RECORD , APPLY_DATABASE_CHANGES , CLEAR_DATABASE_CHANGES , ADD_DEVICE , REMOVE_DEVICE , RESET ,
68
+ SWITCH );
66
69
67
70
private static final String CONFIRM_OPTION = "--confirm" ;
68
71
private static final String FORCE_OPTION = "--force" ;
@@ -80,6 +83,8 @@ public List<String> getUsages() {
80
83
buildCommandUsage (LIST_ALL , "list configured Insteon modem bridges with related channels and status" ),
81
84
buildCommandUsage (LIST_DATABASE + " [" + RECORDS_OPTION + "]" ,
82
85
"list all-link database summary or records and pending changes for the Insteon modem" ),
86
+ buildCommandUsage (LIST_FEATURES , "list features for the Insteon modem" ),
87
+ buildCommandUsage (LIST_PRODUCT_DATA , "list product data for the Insteon modem" ),
83
88
buildCommandUsage (RELOAD_DATABASE , "reload all-link database from the Insteon modem" ),
84
89
buildCommandUsage (BACKUP_DATABASE , "backup all-link database from the Insteon modem to a file" ),
85
90
buildCommandUsage (RESTORE_DATABASE + " <filename> " + CONFIRM_OPTION ,
@@ -127,6 +132,20 @@ public void execute(String[] args, Console console) {
127
132
printUsage (console , args [0 ]);
128
133
}
129
134
break ;
135
+ case LIST_FEATURES :
136
+ if (args .length == 1 ) {
137
+ listFeatures (console );
138
+ } else {
139
+ printUsage (console , args [0 ]);
140
+ }
141
+ break ;
142
+ case LIST_PRODUCT_DATA :
143
+ if (args .length == 1 ) {
144
+ listProductData (console );
145
+ } else {
146
+ printUsage (console , args [0 ]);
147
+ }
148
+ break ;
130
149
case RELOAD_DATABASE :
131
150
if (args .length == 1 ) {
132
151
reloadDatabase (console );
@@ -323,6 +342,32 @@ private void listDatabaseChanges(Console console) {
323
342
}
324
343
}
325
344
345
+ private void listFeatures (Console console ) {
346
+ InsteonAddress address = getModem ().getAddress ();
347
+ List <String > features = getModem ().getFeatures ().stream ()
348
+ .filter (feature -> !feature .isEventFeature () && !feature .isGroupFeature ())
349
+ .map (feature -> String .format ("%s: type=%s state=%s isHidden=%s" , feature .getName (), feature .getType (),
350
+ feature .getState ().toFullString (), feature .isHiddenFeature ()))
351
+ .sorted ().toList ();
352
+ if (features .isEmpty ()) {
353
+ console .println ("The features for modem " + address + " are not defined" );
354
+ } else {
355
+ console .println ("The features for modem " + address + " are:" );
356
+ print (console , features );
357
+ }
358
+ }
359
+
360
+ private void listProductData (Console console ) {
361
+ InsteonAddress address = getModem ().getAddress ();
362
+ ProductData productData = getModem ().getProductData ();
363
+ if (productData == null ) {
364
+ console .println ("The product data for modem " + address + " is not defined" );
365
+ } else {
366
+ console .println ("The product data for modem " + address + " is:" );
367
+ console .println (productData .toString ().replace ("|" , "\n " ));
368
+ }
369
+ }
370
+
326
371
private void reloadDatabase (Console console ) {
327
372
InsteonAddress address = getModem ().getAddress ();
328
373
InsteonBridgeHandler handler = getBridgeHandler ();
0 commit comments