use of org.openhab.binding.myq.internal.dto.AccountsDTO in project openhab-addons by openhab.
the class MyQAccountHandler method getDevices.
private void getDevices() throws InterruptedException, MyQCommunicationException, MyQAuthenticationException {
AccountsDTO localAccounts = accounts;
if (localAccounts == null) {
return;
}
List<DeviceDTO> currentDevices = new ArrayList<DeviceDTO>();
for (AccountDTO account : localAccounts.accounts) {
ContentResponse response = sendRequest(String.format(DEVICES_URL, account.id), HttpMethod.GET, null, null);
DevicesDTO devices = parseResultAndUpdateStatus(response, gsonLowerCase, DevicesDTO.class);
currentDevices.addAll(devices.items);
devices.items.forEach(device -> {
ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID, device.deviceFamily);
if (SUPPORTED_DISCOVERY_THING_TYPES_UIDS.contains(thingTypeUID)) {
for (Thing thing : getThing().getThings()) {
ThingHandler handler = thing.getHandler();
if (handler != null && ((MyQDeviceHandler) handler).getSerialNumber().equalsIgnoreCase(device.serialNumber)) {
((MyQDeviceHandler) handler).handleDeviceUpdate(device);
}
}
}
});
}
devicesCache = currentDevices;
}
Aggregations