2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.solarwatt.internal.domain;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.solarwatt.internal.domain.dto.EnergyManagerDTO;
20 import org.openhab.binding.solarwatt.internal.domain.model.Device;
21 import org.openhab.binding.solarwatt.internal.factory.EnergyManagerDevicesFactory;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * Collection of all devices known to the energy manager including the energy manager itself.
28 * The {@link Device}s are generated from the {@link org.openhab.binding.solarwatt.internal.domain.dto.DeviceDTO}s
29 * inside of the {@link org.openhab.binding.solarwatt.internal.domain.dto.EnergyManagerDTO}
31 * @author Sven Carstens - Initial contribution
34 public class EnergyManagerCollection {
35 private Logger logger = LoggerFactory.getLogger(EnergyManagerCollection.class);
37 private Map<String, Device> devices;
39 public EnergyManagerCollection(EnergyManagerDTO energyManagerDTO) {
40 this.devices = new HashMap<>();
42 energyManagerDTO.getItems().forEach(deviceDTO -> {
44 Device device = EnergyManagerDevicesFactory.getEnergyManagerDevice(deviceDTO);
47 this.devices.put(device.getGuid(), device);
49 } catch (Exception ex) {
50 this.logger.error("Error setting up initial device {}: {}", deviceDTO.getGuid(),
51 deviceDTO.getDeviceModel(), ex);
56 public Map<String, Device> getDevices() {