Skip to content

Commit 0788d47

Browse files
authored
Merge pull request #65 from ccutrer/streamlining2
Some streamlining
2 parents e449fcf + b6501cc commit 0788d47

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/main/java/com/beowulfe/hap/characteristics/BaseCharacteristic.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public abstract class BaseCharacteristic<T> implements Characteristic {
2222
private final Logger logger = LoggerFactory.getLogger(BaseCharacteristic.class);
2323

2424
private final String type;
25+
private final String shortType;
2526
private final String format;
2627
private final boolean isWritable;
2728
private final boolean isReadable;
@@ -46,6 +47,7 @@ public BaseCharacteristic(
4647
}
4748

4849
this.type = type;
50+
this.shortType = this.type.replaceAll("^0*([0-9a-fA-F]+)-0000-1000-8000-0026BB765291$", "$1");
4951
this.format = format;
5052
this.isWritable = isWritable;
5153
this.isReadable = isReadable;
@@ -94,11 +96,10 @@ protected CompletableFuture<JsonObjectBuilder> makeBuilder(int instanceId) {
9496
JsonObjectBuilder builder =
9597
Json.createObjectBuilder()
9698
.add("iid", instanceId)
97-
.add("type", type)
99+
.add("type", shortType)
98100
.add("perms", perms.build())
99101
.add("format", format)
100-
.add("events", false)
101-
.add("bonjour", false)
102+
.add("ev", false)
102103
.add("description", description);
103104
setJsonValue(builder, value);
104105
return builder;

src/main/java/com/beowulfe/hap/impl/json/AccessoryController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ public HttpResponse listing() throws Exception {
6565
}
6666

6767
private CompletableFuture<JsonObject> toJson(Service service, int interfaceId) throws Exception {
68+
String shortType =
69+
service.getType().replaceAll("^0*([0-9a-fA-F]+)-0000-1000-8000-0026BB765291$", "$1");
6870
JsonObjectBuilder builder =
69-
Json.createObjectBuilder().add("iid", ++interfaceId).add("type", service.getType());
71+
Json.createObjectBuilder().add("iid", ++interfaceId).add("type", shortType);
7072
List<Characteristic> characteristics = service.getCharacteristics();
7173
Collection<CompletableFuture<JsonObject>> characteristicFutures =
7274
new ArrayList<>(characteristics.size());

0 commit comments

Comments
 (0)