Skip to content

Commit

Permalink
feat: use retry logic on device fetch (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigboxer23 authored Mar 29, 2024
1 parent f6ff8a4 commit 9afaf3e
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ public void closeCurtains() throws IOException {
private String getDeviceName(String deviceId) throws IOException {
if (deviceIdToName == null || !deviceIdToName.containsKey(deviceId)) {
logger.info("refreshing device id to name map");
deviceIdToName = getSwitchbotAPI().getDeviceApi().getDevices().stream()
.collect(Collectors.toMap(Device::getDeviceId, Device::getDeviceName));
deviceIdToName = RetryingCommand.execute(
() -> getSwitchbotAPI().getDeviceApi().getDevices().stream()
.collect(Collectors.toMap(Device::getDeviceId, Device::getDeviceName)),
"list devices");
}
return deviceIdToName.get(deviceId);
}
Expand Down

0 comments on commit 9afaf3e

Please sign in to comment.