Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
  • Loading branch information
Hilbrand committed Apr 8, 2021
1 parent d814d2f commit 5de779a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public String getLastKnownHostAddress(final String serialNumber) {
if (getServiceType().equals(info.getType())) {
final String serial = info.getPropertyString(DISCOVERY_SERIAL);

logger.debug("Discovered an Envoy with id '{}'", serial);
logger.debug("Discovered an Envoy with serial number '{}'", serial);
return new ThingUID(THING_TYPE_ENPHASE_ENVOY, serial);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
*/
package org.openhab.binding.enphase.internal.handler;

import static org.openhab.binding.enphase.internal.EnphaseBindingConstants.*;
import static org.openhab.binding.enphase.internal.EnphaseBindingConstants.CONFIG_HOSTNAME;
import static org.openhab.binding.enphase.internal.EnphaseBindingConstants.ENVOY_CHANNELGROUP_CONSUMPTION;
import static org.openhab.binding.enphase.internal.EnphaseBindingConstants.ENVOY_WATTS_NOW;
import static org.openhab.binding.enphase.internal.EnphaseBindingConstants.ENVOY_WATT_HOURS_LIFETIME;
import static org.openhab.binding.enphase.internal.EnphaseBindingConstants.ENVOY_WATT_HOURS_SEVEN_DAYS;
import static org.openhab.binding.enphase.internal.EnphaseBindingConstants.ENVOY_WATT_HOURS_TODAY;

import java.time.Duration;
import java.time.temporal.ChronoUnit;
Expand Down Expand Up @@ -77,7 +82,7 @@ private enum FeatureStatus {
private final EnvoyConnector connector;
private final EnvoyHostAddressCache envoyHostnameCache;

private @NonNullByDefault({}) EnvoyConfiguration configuration;
private EnvoyConfiguration configuration = new EnvoyConfiguration();
private @Nullable ScheduledFuture<?> updataDataFuture;
private @Nullable ScheduledFuture<?> updateHostnameFuture;
private @Nullable ExpiringCache<Map<String, @Nullable InverterDTO>> invertersCache;
Expand Down Expand Up @@ -134,12 +139,11 @@ public Collection<Class<? extends ThingHandlerService>> getServices() {
public void initialize() {
configuration = getConfigAs(EnvoyConfiguration.class);
if (!EnphaseBindingConstants.isValidSerial(configuration.serialNumber)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Serial Number is not valid");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Serial number is not valid");
return;
}
if (configuration.hostname.isEmpty()) {
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.CONFIGURATION_PENDING,
"Waiting to retrieve ip address of the envoy gateway. Can take up to a minute.");
updateStatus(ThingStatus.UNKNOWN);
} else {
updateStatus(ThingStatus.ONLINE);
}
Expand Down Expand Up @@ -367,6 +371,8 @@ private void updateHostname() {
final String lastKnownHostname = envoyHostnameCache.getLastKnownHostAddress(configuration.serialNumber);

if (lastKnownHostname.isEmpty()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"No ip address known of the envoy gateway. If this isn't updated in a few minutes check your connection.");
scheduleHostnameUpdate(true);
} else {
final Configuration config = editConfiguration();
Expand Down Expand Up @@ -399,8 +405,7 @@ public void dispose() {
* @return Returns true if the bridge is online and not has an configuration pending.
*/
public boolean isOnline() {
return getThing().getStatus() == ThingStatus.ONLINE
&& getThing().getStatusInfo().getStatusDetail() == ThingStatusDetail.NONE;
return getThing().getStatus() == ThingStatus.ONLINE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ envoy.cond_flags.pcu_ctrl.pwrgenoffbycmd=Power generation off by command
envoy.cond_flags.pcu_ctrl.runningonac=Running on AC
envoy.cond_flags.pcu_ctrl.tpmtest=Transient Grid Profile
envoy.cond_flags.pcu_ctrl.unexpectedreset=Unexpected Reset
envoy.cond_flags.pcu_ctrl.watchdogreset=Watchdog Reset"
envoy.cond_flags.pcu_ctrl.watchdogreset=Watchdog Reset
envoy.cond_flags.rgm_chan.check_meter=Meter Error
envoy.cond_flags.rgm_chan.power_quality=Poor Power Quality"
envoy.cond_flags.rgm_chan.power_quality=Poor Power Quality

0 comments on commit 5de779a

Please sign in to comment.