Skip to content

Commit c86d231

Browse files
committed
[ddwrt] Add semantic tags and keywords, rename assoclist channel, clean up discovery logging
- Add semantic equipment tags to all thing types (Router, NetworkAppliance, WirelessAccessPoint, Firewall) - Add semantic tags to channels (Status, Measurement, Control, Switch, Timestamp, Temperature, Level, RSSI, SignalStrength, Speed) - Add keywords to addon.xml for better discoverability - Rename assoclist channel to assoc-list for consistency with other channel IDs - Simplify discovery service: only include hostname and mac in properties, remove redundant debug logging PR #20505 Assisted-by: Windsurf:SWE-1.6 Signed-off-by: Lee Ballard <ballle98@gmail.com>
1 parent cdbf285 commit c86d231

5 files changed

Lines changed: 100 additions & 18 deletions

File tree

bundles/org.openhab.binding.ddwrt/src/main/java/org/openhab/binding/ddwrt/internal/DDWRTBindingConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private DDWRTBindingConstants() {
7373
public static final String CHANNEL_SSID = "ssid";
7474
public static final String CHANNEL_MODE = "mode";
7575
public static final String CHANNEL_CLIENT_COUNT = "client-count";
76-
public static final String CHANNEL_ASSOCLIST = "assoclist";
76+
public static final String CHANNEL_ASSOCLIST = "assoc-list";
7777

7878
// List of wireless client channel ids
7979
public static final String CHANNEL_MAC_ADDRESS = "mac-address";

bundles/org.openhab.binding.ddwrt/src/main/java/org/openhab/binding/ddwrt/internal/DDWRTDiscoveryService.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,9 @@ private void discoverWirelessClients(DDWRTNetwork net) {
201201

202202
final Map<String, Object> props = new java.util.HashMap<>();
203203
props.put("hostname", client.getHostname());
204-
props.put("mac", client.getMac());
205-
props.put("apMac", client.getApMac());
206-
props.put("ssid", client.getSsid());
207-
props.put("iface", client.getIface());
208-
props.put("radioName", client.getRadioName());
209-
props.put("ipAddress", client.getIpAddress());
210-
props.put("channel", client.getChannel());
211-
props.put("signal", client.getSignalDbm());
212-
props.put("snr", client.getSnr());
204+
if (!client.getMac().isEmpty()) {
205+
props.put("mac", client.getMac());
206+
}
213207

214208
final DiscoveryResult result = DiscoveryResultBuilder.create(thingUID).withBridge(bridgeUID)
215209
.withLabel(client.getHostname()).withProperties(props).withRepresentationProperty("hostname")
@@ -219,11 +213,7 @@ private void discoverWirelessClients(DDWRTNetwork net) {
219213
"Submitting discovery result for wireless client: {} ({}) - AP: {}, SSID: {}, Channel: {}, Signal: {}dBm, SNR: {}",
220214
thingUID, client.getHostname(), client.getApMac(), client.getSsid(), client.getChannel(),
221215
client.getSignalDbm(), client.getSnr());
222-
logger.debug("Wireless client properties: MAC={}, IP={}, Hostname={}, Interface={}, Radio={}",
223-
client.getMac(), client.getIpAddress(), client.getHostname(), client.getIface(),
224-
client.getRadioName());
225216
thingDiscovered(result);
226-
logger.debug("Submitted discovery result for wireless client: {}", thingUID);
227217
});
228218
}
229219

bundles/org.openhab.binding.ddwrt/src/main/resources/OH-INF/addon/addon.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<type>binding</type>
77
<name>DD-WRT Binding</name>
88
<description>Monitors and manages DD-WRT, OpenWrt, Tomato routers, and Linux devices via SSH.</description>
9+
<keywords>DD-WRT,DDWRT,OpenWrt,OpenWRT,Tomato,SSH,RaspberryPi,Router,Network,Linux,Syslog,Wireless,Firewall</keywords>
910
<connection>local</connection>
1011

1112
</addon:addon>

bundles/org.openhab.binding.ddwrt/src/main/resources/OH-INF/i18n/ddwrt.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ channel-type.ddwrt.ap-mac.label = AP MAC Address
7171
channel-type.ddwrt.ap-mac.description = MAC address of the access point the client is associated with
7272
channel-type.ddwrt.ap.label = Access Point
7373
channel-type.ddwrt.ap.description = Name of the radio the client is associated with (hostname-interface)
74-
channel-type.ddwrt.assoclist.label = Associated Clients
75-
channel-type.ddwrt.assoclist.description = Comma-separated list of MAC addresses of associated wireless clients
74+
channel-type.ddwrt.assoc-list.label = Associated Clients
75+
channel-type.ddwrt.assoc-list.description = Comma-separated list of MAC addresses of associated wireless clients
7676
channel-type.ddwrt.channel.label = Channel
7777
channel-type.ddwrt.channel.description = Wireless channel number
7878
channel-type.ddwrt.client-count.label = Client Count

bundles/org.openhab.binding.ddwrt/src/main/resources/OH-INF/thing/thing-types.xml

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<label>DD-WRT Network</label>
1212
<description>A network of DD-WRT compatible devices managed via SSH</description>
1313
<category>Network</category>
14+
<semantic-equipment-tag>Router</semantic-equipment-tag>
1415

1516
<channels>
1617
<channel id="total-clients" typeId="total-clients"/>
@@ -68,6 +69,7 @@
6869
<label>DD-WRT Device</label>
6970
<description>A DD-WRT, OpenWrt, or compatible Linux device managed via SSH</description>
7071
<category>NetworkAppliance</category>
72+
<semantic-equipment-tag>NetworkAppliance</semantic-equipment-tag>
7173

7274
<channels>
7375
<channel id="online" typeId="online"/>
@@ -173,14 +175,15 @@
173175
<label>Wireless Radio</label>
174176
<description>A wireless radio interface on a DD-WRT device</description>
175177
<category>Network</category>
178+
<semantic-equipment-tag>WirelessAccessPoint</semantic-equipment-tag>
176179

177180
<channels>
178181
<channel id="enabled" typeId="enabled"/>
179182
<channel id="ssid" typeId="ssid"/>
180183
<channel id="channel" typeId="channel"/>
181184
<channel id="mode" typeId="mode"/>
182185
<channel id="client-count" typeId="client-count"/>
183-
<channel id="assoclist" typeId="assoclist"/>
186+
<channel id="assoc-list" typeId="assoc-list"/>
184187
</channels>
185188

186189
<representation-property>interfaceId</representation-property>
@@ -209,6 +212,7 @@
209212
<label>Wireless Client</label>
210213
<description>A wireless client associated with a DD-WRT network device</description>
211214
<category>Network</category>
215+
<semantic-equipment-tag>NetworkAppliance</semantic-equipment-tag>
212216

213217
<channels>
214218
<channel id="online" typeId="online"/>
@@ -251,6 +255,7 @@
251255
<label>Firewall Rule</label>
252256
<description>A GUI-configured firewall filter rule from nvram</description>
253257
<category>Shield</category>
258+
<semantic-equipment-tag>Firewall</semantic-equipment-tag>
254259

255260
<channels>
256261
<channel id="enabled" typeId="enabled"/>
@@ -277,6 +282,9 @@
277282
<label>Online</label>
278283
<description>Whether the device or client is currently online</description>
279284
<category>Status</category>
285+
<tags>
286+
<tag>Status</tag>
287+
</tags>
280288
<state readOnly="true"/>
281289
</channel-type>
282290

@@ -285,6 +293,10 @@
285293
<label>Uptime Since</label>
286294
<description>System boot time (updates only on reboot)</description>
287295
<category>Time</category>
296+
<tags>
297+
<tag>Status</tag>
298+
<tag>Timestamp</tag>
299+
</tags>
288300
<state readOnly="true"/>
289301
</channel-type>
290302

@@ -294,20 +306,29 @@
294306
<item-type>Number</item-type>
295307
<label>Total Clients</label>
296308
<description>Total number of clients connected across all devices</description>
309+
<tags>
310+
<tag>Measurement</tag>
311+
</tags>
297312
<state readOnly="true"/>
298313
</channel-type>
299314

300315
<channel-type id="wireless-clients">
301316
<item-type>Number</item-type>
302317
<label>Wireless Clients</label>
303318
<description>Number of wireless clients connected across all devices</description>
319+
<tags>
320+
<tag>Measurement</tag>
321+
</tags>
304322
<state readOnly="true"/>
305323
</channel-type>
306324

307325
<channel-type id="wired-clients">
308326
<item-type>Number</item-type>
309327
<label>Wired Clients</label>
310328
<description>Number of wired clients connected across all devices</description>
329+
<tags>
330+
<tag>Measurement</tag>
331+
</tags>
311332
<state readOnly="true"/>
312333
</channel-type>
313334

@@ -318,6 +339,10 @@
318339
<label>CPU Load</label>
319340
<description>1-minute load average</description>
320341
<category>Number</category>
342+
<tags>
343+
<tag>Measurement</tag>
344+
<tag>Level</tag>
345+
</tags>
321346
<state readOnly="true" pattern="%.2f"/>
322347
</channel-type>
323348

@@ -326,6 +351,10 @@
326351
<label>CPU Temperature</label>
327352
<description>CPU temperature in degrees Celsius</description>
328353
<category>Temperature</category>
354+
<tags>
355+
<tag>Measurement</tag>
356+
<tag>Temperature</tag>
357+
</tags>
329358
<state readOnly="true" pattern="%.1f %unit%"/>
330359
</channel-type>
331360

@@ -342,6 +371,9 @@
342371
<label>WAN In</label>
343372
<description>Total bytes received on the WAN interface (only available on gateway devices)</description>
344373
<category>Network</category>
374+
<tags>
375+
<tag>Measurement</tag>
376+
</tags>
345377
<state readOnly="true"/>
346378
</channel-type>
347379

@@ -350,6 +382,9 @@
350382
<label>WAN Out</label>
351383
<description>Total bytes sent on the WAN interface (only available on gateway devices)</description>
352384
<category>Network</category>
385+
<tags>
386+
<tag>Measurement</tag>
387+
</tags>
353388
<state readOnly="true"/>
354389
</channel-type>
355390

@@ -358,6 +393,9 @@
358393
<label>LAN In</label>
359394
<description>Total bytes received on the LAN bridge interface (br0)</description>
360395
<category>Network</category>
396+
<tags>
397+
<tag>Measurement</tag>
398+
</tags>
361399
<state readOnly="true"/>
362400
</channel-type>
363401

@@ -366,6 +404,9 @@
366404
<label>LAN Out</label>
367405
<description>Total bytes sent on the LAN bridge interface (br0)</description>
368406
<category>Network</category>
407+
<tags>
408+
<tag>Measurement</tag>
409+
</tags>
369410
<state readOnly="true"/>
370411
</channel-type>
371412

@@ -374,6 +415,9 @@
374415
<label>Reboot</label>
375416
<description>Turn ON to reboot the device; automatically resets to OFF</description>
376417
<category>Switch</category>
418+
<tags>
419+
<tag>Control</tag>
420+
</tags>
377421
</channel-type>
378422

379423
<!-- Radio -->
@@ -383,6 +427,9 @@
383427
<label>Enabled</label>
384428
<description>Whether the radio or rule is enabled</description>
385429
<category>Switch</category>
430+
<tags>
431+
<tag>Switch</tag>
432+
</tags>
386433
</channel-type>
387434

388435
<channel-type id="ssid">
@@ -398,6 +445,9 @@
398445
<label>Channel</label>
399446
<description>Wireless channel number</description>
400447
<category>Number</category>
448+
<tags>
449+
<tag>Measurement</tag>
450+
</tags>
401451
<state readOnly="true"/>
402452
</channel-type>
403453

@@ -413,10 +463,13 @@
413463
<label>Client Count</label>
414464
<description>Number of clients associated with this radio</description>
415465
<category>Number</category>
466+
<tags>
467+
<tag>Measurement</tag>
468+
</tags>
416469
<state readOnly="true"/>
417470
</channel-type>
418471

419-
<channel-type id="assoclist">
472+
<channel-type id="assoc-list">
420473
<item-type>String</item-type>
421474
<label>Associated Clients</label>
422475
<description>Comma-separated list of MAC addresses of associated wireless clients</description>
@@ -465,6 +518,10 @@
465518
<label>Signal</label>
466519
<description>Signal strength in dBm</description>
467520
<category>QualityOfService</category>
521+
<tags>
522+
<tag>Measurement</tag>
523+
<tag>RSSI</tag>
524+
</tags>
468525
<state readOnly="true" pattern="%d dBm"/>
469526
</channel-type>
470527

@@ -473,20 +530,32 @@
473530
<label>Signal-to-Noise Ratio</label>
474531
<description>Signal-to-noise ratio in dB</description>
475532
<category>QualityOfService</category>
533+
<tags>
534+
<tag>Measurement</tag>
535+
<tag>SignalStrength</tag>
536+
</tags>
476537
<state readOnly="true" pattern="%d dB"/>
477538
</channel-type>
478539

479540
<channel-type id="rx-rate">
480541
<item-type>Number</item-type>
481542
<label>RX Rate</label>
482543
<description>Receive rate in Mbit/s</description>
544+
<tags>
545+
<tag>Measurement</tag>
546+
<tag>Speed</tag>
547+
</tags>
483548
<state readOnly="true" pattern="%.1f Mbit/s"/>
484549
</channel-type>
485550

486551
<channel-type id="tx-rate">
487552
<item-type>Number</item-type>
488553
<label>TX Rate</label>
489554
<description>Transmit rate in Mbit/s</description>
555+
<tags>
556+
<tag>Measurement</tag>
557+
<tag>Speed</tag>
558+
</tags>
490559
<state readOnly="true" pattern="%.1f Mbit/s"/>
491560
</channel-type>
492561

@@ -495,6 +564,10 @@
495564
<label>Last Seen</label>
496565
<description>Timestamp when the client was last seen online</description>
497566
<category>Time</category>
567+
<tags>
568+
<tag>Status</tag>
569+
<tag>Timestamp</tag>
570+
</tags>
498571
<state readOnly="true"/>
499572
</channel-type>
500573

@@ -513,41 +586,59 @@
513586
<item-type>String</item-type>
514587
<label>Last Warning Event</label>
515588
<description>Last warning-level syslog line</description>
589+
<tags>
590+
<tag>Status</tag>
591+
</tags>
516592
<state readOnly="true"/>
517593
</channel-type>
518594

519595
<channel-type id="last-error-event">
520596
<item-type>String</item-type>
521597
<label>Last Error Event</label>
522598
<description>Last error-level syslog line</description>
599+
<tags>
600+
<tag>Status</tag>
601+
</tags>
523602
<state readOnly="true"/>
524603
</channel-type>
525604

526605
<channel-type id="warning-events">
527606
<item-type>Number</item-type>
528607
<label>Warning Events</label>
529608
<description>Number of warning-level syslog events since startup</description>
609+
<tags>
610+
<tag>Measurement</tag>
611+
</tags>
530612
<state readOnly="true"/>
531613
</channel-type>
532614

533615
<channel-type id="error-events">
534616
<item-type>Number</item-type>
535617
<label>Error Events</label>
536618
<description>Number of error-level syslog events since startup</description>
619+
<tags>
620+
<tag>Measurement</tag>
621+
</tags>
537622
<state readOnly="true"/>
538623
</channel-type>
539624

540625
<channel-type id="last-dhcp-event">
541626
<item-type>String</item-type>
542627
<label>Last DHCP Event</label>
543628
<description>Last DHCP lease, renewal, or release event</description>
629+
<tags>
630+
<tag>Status</tag>
631+
</tags>
544632
<state readOnly="true"/>
545633
</channel-type>
546634

547635
<channel-type id="last-wireless-event">
548636
<item-type>String</item-type>
549637
<label>Last Wireless Event</label>
550638
<description>Last wireless association or deassociation event</description>
639+
<tags>
640+
<tag>Status</tag>
641+
</tags>
551642
<state readOnly="true"/>
552643
</channel-type>
553644

0 commit comments

Comments
 (0)