Skip to content

Commit

Permalink
[enphase] Some small improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
  • Loading branch information
Hilbrand committed Jan 23, 2021
1 parent 4412b0e commit 7a2f122
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ private void refreshProperties(@Nullable final DeviceDTO deviceDTO) {
@Override
public void initialize() {
serialNumber = (String) getConfig().get(EnphaseBindingConstants.CONFIG_SERIAL_NUMBER);
updateStatus(ThingStatus.UNKNOWN);
if (!EnphaseBindingConstants.isValidSerial(serialNumber)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Serial Number is not valid");
} else {
updateStatus(ThingStatus.UNKNOWN);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,9 @@ private void updateInverter(final @Nullable Map<String, @Nullable InverterDTO> i
private void updateDevices() {
final Map<String, @Nullable DeviceDTO> devices = getDevices(false);

if (devices != null) {
getThing().getThings().stream().map(Thing::getHandler).filter(h -> h instanceof EnphaseDeviceHandler)
.map(EnphaseDeviceHandler.class::cast)
.forEach(invHandler -> invHandler.refreshDeviceState(devices.get(invHandler.getSerialNumber())));
}
getThing().getThings().stream().map(Thing::getHandler).filter(h -> h instanceof EnphaseDeviceHandler)
.map(EnphaseDeviceHandler.class::cast).forEach(invHandler -> invHandler
.refreshDeviceState(devices == null ? null : devices.get(invHandler.getSerialNumber())));
}

/**
Expand Down

0 comments on commit 7a2f122

Please sign in to comment.