Skip to content

Commit

Permalink
update format
Browse files Browse the repository at this point in the history
  • Loading branch information
lewei50 committed Sep 6, 2020
1 parent e59269a commit b7519ad
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
*/
package org.openhab.binding.iammeter.internal;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -49,7 +46,7 @@
*/

@NonNullByDefault
public class IammeterBaseHandler extends BaseThingHandler {
public abstract class IammeterBaseHandler extends BaseThingHandler {

private final Logger logger = LoggerFactory.getLogger(IammeterBaseHandler.class);
private @Nullable ScheduledFuture<?> refreshJob;
Expand Down Expand Up @@ -80,9 +77,7 @@ public void initialize() {
}
}

protected void resolveData(String response) {

}
protected abstract void resolveData(String response);

@SuppressWarnings("null")
private boolean refresh() {
Expand All @@ -92,33 +87,8 @@ private boolean refresh() {
String httpMethod = "GET";
String url = "http://" + config.username + ":" + config.password + "@" + config.host + ":" + config.port
+ "/monitorjson";
String content = "";
InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));

String response = HttpUtil.executeUrl(httpMethod, url, TIMEOUT_MS);

resolveData(response);

// JsonElement iammeterDataElement = new JsonParser().parse(response);
// JsonObject iammeterData = iammeterDataElement.getAsJsonObject();
// String keyWord = "Datas";
// if (iammeterData.has("Datas") && iammeterData.has("SN")) {
// String groups[] = { "powerPhaseA", "powerPhaseB", "powerPhaseC" };
// for (int row = 0; row < groups.length; row++) {
// String gpName = groups[row];
// List<Channel> chnList = getThing().getChannelsOfGroup(gpName);
// for (IammeterWEM3080Channel channelConfig : IammeterWEM3080Channel.values()) {
// Channel chnl = chnList.get(channelConfig.ordinal());
// if (chnl != null) {
// State state = getQuantityState(iammeterData.get(keyWord).getAsJsonArray().get(row)
// .getAsJsonArray().get(channelConfig.ordinal()).toString(), channelConfig.getUnit());
// updateState(chnl.getUID(), state);
// }
// }
// updateStatus(ThingStatus.ONLINE);
// }
// }
stream.close();
updateStatus(ThingStatus.ONLINE);
return true;
// Very rudimentary Exception differentiation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:config-description="https://openhab.org/schemas/config-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0 https://openhab.org/schemas/config-description-1.0.0.xsd">

<config-description uri="thing-type:iammeter:powermeter">
<parameter name="host" type="text" required="true">
<label>Device's IP Address</label>
Expand Down Expand Up @@ -32,5 +32,5 @@
<default>60</default>
</parameter>
</config-description>

</config-description:config-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

<thing-type id="powermeter">
<label>Iammeter Power Meter 3162/3080</label>
<description>Single phase PowerMeter for Iammeter Binding</description>
Expand All @@ -15,7 +16,7 @@
</channels>
<config-description-ref uri="thing-type:iammeter:powermeter"/>
</thing-type>

<channel-type id="voltage">
<item-type>Number:ElectricPotential</item-type>
<label>Voltage</label>
Expand Down Expand Up @@ -46,4 +47,5 @@
<description>exportgrid for phase A</description>
<state pattern="%.2f %unit%" readOnly="true"></state>
</channel-type>

</thing:thing-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

<thing-type id="powermeter3080T">
<label>Iammeter Power Meter 3080T</label>
<description>3 phases PowerMeter for Iammeter 3080T Binding</description>
Expand Down Expand Up @@ -76,4 +77,5 @@
<description>power factor for phase A</description>
<state pattern="%.2f" readOnly="true"></state>
</channel-type>

</thing:thing-descriptions>

0 comments on commit b7519ad

Please sign in to comment.