Skip to content

Commit

Permalink
[nikohomecontrol] Removed dead code (#7314)
Browse files Browse the repository at this point in the history
* [nikohomecontrol] Small README updates.
* Remove obsolete profiles list as these cannot be retrieved with hobby
API.
* Fix timezone property.
* Removed acting on public messages as not available in hobby API.

Signed-off-by: Mark Herwege <[email protected]>
  • Loading branch information
mherwege authored Apr 6, 2020
1 parent 5673628 commit 45cf759
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ protected void updateProperties() {
if (!waterTariff.isEmpty()) {
properties.put("waterTariff", waterTariff);
}
String timeZone = comm.getTimeInfo().getTimeZone();
if (!timeZone.isEmpty()) {
properties.put("timeZone", timeZone);
String timezone = comm.getTimeInfo().getTimezone();
if (!timezone.isEmpty()) {
properties.put("timezone", timezone);
}
String isDst = comm.getTimeInfo().getIsDst();
if (!isDst.isEmpty()) {
Expand All @@ -154,10 +154,6 @@ protected void updateProperties() {
if (!services.isEmpty()) {
properties.put("services", services);
}
String profiles = comm.getProfiles();
if (!profiles.isEmpty()) {
properties.put("profiles", profiles);
}

thing.setProperties(properties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ static class NhcMessageParam {
@Nullable
List<NhcSystemInfo2> systemInfo;
@Nullable
List<NhcProfile2> profiles;
@Nullable
List<NhcService2> services;
@Nullable
List<NhcDevice2> devices;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class NhcTimeInfo2 {
@SerializedName(value = "GMTOffset")
String gmtOffset = "";
String timeZone = "";
String timezone = "";
String isDST = "";
@SerializedName(value = "UTCTime")
String utcTime = "";
Expand All @@ -40,8 +40,8 @@ public String getGMTOffset() {
/**
* @return the timeZone
*/
public String getTimeZone() {
return timeZone;
public String getTimezone() {
return timezone;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication

private final NhcMqttConnection2 mqttConnection;

private final List<NhcProfile2> profiles = new CopyOnWriteArrayList<>();
private final List<NhcService2> services = new CopyOnWriteArrayList<>();

private volatile String profile = "";
Expand Down Expand Up @@ -168,9 +167,6 @@ private void initialize() throws MqttException {
message.method = "systeminfo.publish";
mqttConnection.connectionPublish(profile + "/system/cmd", gson.toJson(message));

message.method = "profiles.list";
mqttConnection.connectionPublish("public/authentication/cmd", gson.toJson(message));

message.method = "services.list";
mqttConnection.connectionPublish(profile + "/authentication/cmd", gson.toJson(message));

Expand Down Expand Up @@ -233,27 +229,6 @@ private void systeminfoPublishRsp(String response) {
}
}

private void profilesListRsp(String response) {
Type messageType = new TypeToken<NhcMessage2>() {
}.getType();
List<NhcProfile2> profileList = null;
try {
NhcMessage2 message = gson.fromJson(response, messageType);
List<NhcMessageParam> messageParams = message.params;
if (messageParams != null) {
profileList = messageParams.stream().filter(p -> (p.profiles != null)).findFirst().get().profiles;
}
} catch (JsonSyntaxException e) {
logger.debug("Niko Home Control: unexpected json {}", response);
} catch (NoSuchElementException ignore) {
// Ignore if profiles not present in response, this should not happen in a profiles response
}
profiles.clear();
if (profileList != null) {
profiles.addAll(profileList);
}
}

private void servicesListRsp(String response) {
Type messageType = new TypeToken<NhcMessage2>() {
}.getType();
Expand Down Expand Up @@ -791,14 +766,11 @@ private void sendDeviceMessage(String topic, String gsonMessage) {
@Override
public void processMessage(String topic, byte[] payload) {
String message = new String(payload);
if ("public/system/evt".equals(topic) || (profile + "/system/evt").equals(topic)) {
if ((profile + "/system/evt").equals(topic)) {
systemEvt(message);
} else if ((profile + "/system/rsp").equals(topic)) {
logger.debug("Niko Home Control: received topic {}, payload {}", topic, message);
systeminfoPublishRsp(message);
} else if ("public/authentication/rsp".equals(topic)) {
logger.debug("Niko Home Control: received topic {}, payload {}", topic, message);
profilesListRsp(message);
} else if ((profile + "/notification/evt").equals(topic)) {
logger.debug("Niko Home Control: received topic {}, payload {}", topic, message);
notificationEvt(message);
Expand All @@ -811,7 +783,7 @@ public void processMessage(String topic, byte[] payload) {
} else if ((profile + "/authentication/rsp").equals(topic)) {
logger.debug("Niko Home Control: received topic {}, payload {}", topic, message);
servicesListRsp(message);
} else if ("public/control/devices.error".equals(topic) || (profile + "/control/devices.error").equals(topic)) {
} else if ((profile + "/control/devices.error").equals(topic)) {
logger.warn("Niko Home Control: received error {}", message);
} else {
logger.trace("Niko Home Control: not acted on received message topic {}, payload {}", topic, message);
Expand Down Expand Up @@ -840,13 +812,6 @@ public NhcTimeInfo2 getTimeInfo() {
return timeInfo;
}

/**
* @return comma separated list of profiles with uuid's retrieved from Connected Controller
*/
public String getProfiles() {
return profiles.stream().map(NhcProfile2::profile).collect(Collectors.joining(", "));
}

/**
* @return comma separated list of services retrieved from Connected Controller
*/
Expand Down

0 comments on commit 45cf759

Please sign in to comment.