[miio] allow for device remarks in the readme from json db (#8676)

* [miio] allow for device remarks in the readme from json db
* Update bundles/org.openhab.binding.miio/src/test/java/org/openhab/binding/miio/internal/ReadmeHelper.java

Signed-off-by: Marcel Verpaalen marcel@verpaalen.com
This commit is contained in:
Marcel
2020-10-07 00:04:36 +02:00
committed by GitHub
parent 3403216154
commit 782a4210a4
5 changed files with 113 additions and 74 deletions

View File

@@ -42,6 +42,12 @@ public class DeviceMapping {
@SerializedName("channels")
@Expose
private List<MiIoBasicChannel> miIoBasicChannels = new ArrayList<>();
@SerializedName("readmeComment")
@Expose
private @Nullable String readmeComment;
@SerializedName("experimental")
@Expose
private @Nullable Boolean experimental;
public List<String> getId() {
return id;
@@ -76,4 +82,21 @@ public class DeviceMapping {
public void setChannels(List<MiIoBasicChannel> miIoBasicChannels) {
this.miIoBasicChannels = miIoBasicChannels;
}
public String getReadmeComment() {
final String readmeComment = this.readmeComment;
return (readmeComment != null) ? readmeComment : "";
}
public void setReadmeComment(String readmeComment) {
this.readmeComment = readmeComment;
}
public @Nullable Boolean getExperimental() {
return experimental;
}
public void setExperimental(Boolean experimental) {
this.experimental = experimental;
}
}

View File

@@ -24,58 +24,59 @@
]
},
{
"property": "doorbell_volume",
"friendlyName": "Doorbell Volume",
"channel": "doorbellVol",
"type": "Number",
"refresh": true,
"actions": [
{
"command": "set_doorbell_volume",
"parameterType": "NUMBER"
}
]
},
{
"property": "gateway_volume",
"friendlyName": "Gateway Volume",
"channel": "gatewayVol",
"type": "Number",
"refresh": true,
"actions": [
{
"command": "set_gateway_volume",
"parameterType": "NUMBER"
}
]
},
{
"property": "alarming_volume",
"friendlyName": "Alarming Volume",
"channel": "alarmingVol",
"type": "Number",
"refresh": true,
"actions": [
{
"command": "set_alarming_volume",
"parameterType": "NUMBER"
}
]
},
{
"property": "doorbell_push",
"friendlyName": "Doorbell Push",
"channel": "doorbellPush",
"type": "String",
"refresh": true,
"actions": [
{
"command": "set_doorbell_push",
"parameterType": "STRING"
}
]
}
]
"property": "doorbell_volume",
"friendlyName": "Doorbell Volume",
"channel": "doorbellVol",
"type": "Number",
"refresh": true,
"actions": [
{
"command": "set_doorbell_volume",
"parameterType": "NUMBER"
}
]
},
{
"property": "gateway_volume",
"friendlyName": "Gateway Volume",
"channel": "gatewayVol",
"type": "Number",
"refresh": true,
"actions": [
{
"command": "set_gateway_volume",
"parameterType": "NUMBER"
}
]
},
{
"property": "alarming_volume",
"friendlyName": "Alarming Volume",
"channel": "alarmingVol",
"type": "Number",
"refresh": true,
"actions": [
{
"command": "set_alarming_volume",
"parameterType": "NUMBER"
}
]
},
{
"property": "doorbell_push",
"friendlyName": "Doorbell Push",
"channel": "doorbellPush",
"type": "String",
"refresh": true,
"actions": [
{
"command": "set_doorbell_push",
"parameterType": "STRING"
}
]
}
],
"readmeComment": "Used to control the gateway itself. Use the mihome binding to control devices connected to the Xiaomi gateway.",
"experimental": true
}
}

View File

@@ -167,6 +167,7 @@
"refresh": true,
"actions": []
}
]
],
"experimental": true
}
}

View File

@@ -90,6 +90,18 @@ public class ReadmeHelper {
if (!device.getModel().equals("unknown")) {
String link = device.getModel().replace(".", "-");
boolean isSupported = device.getThingType().equals(MiIoBindingConstants.THING_TYPE_UNSUPPORTED);
String remark = "";
if (device.getThingType().equals(MiIoBindingConstants.THING_TYPE_BASIC)) {
MiIoBasicDevice dev = findDatabaseEntry(device.getModel());
if (dev != null) {
remark = dev.getDevice().getReadmeComment();
final Boolean experimental = dev.getDevice().getExperimental();
if (experimental != null && experimental.booleanValue()) {
remark += (remark.isBlank() ? "" : " ")
+ "Experimental support. Please report back if all channels are functional. Preferably share the debug log of property refresh and command responses";
}
}
}
sw.write("| ");
sw.write(minLengthString(device.getDescription(), 28));
sw.write(" | ");
@@ -99,7 +111,9 @@ public class ReadmeHelper {
sw.write(minLengthString(model, 22));
sw.write(" | ");
sw.write(isSupported ? "No " : "Yes ");
sw.write(" | |\r\n");
sw.write(" | ");
sw.write(minLengthString(remark, 10));
sw.write(" |\r\n");
}
});
return sw;