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.sensibo.internal.model;
15 import java.util.ArrayList;
16 import java.util.List;
17 import java.util.Optional;
19 import org.apache.commons.lang3.StringUtils;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
23 * The {@link SensiboModel} represents the home structure as designed by the user in the Sensibo app.
25 * @author Arne Seime - Initial contribution
28 public class SensiboModel {
29 private final long lastUpdated;
30 private final List<SensiboSky> pods = new ArrayList<>();
32 public SensiboModel(final long lastUpdated) {
33 this.lastUpdated = lastUpdated;
36 public void addPod(final SensiboSky pod) {
40 public List<SensiboSky> getPods() {
44 public long getLastUpdated() {
48 public Optional<SensiboSky> findSensiboSkyByMacAddress(final String macAddress) {
49 final String macAddressWithoutColons = StringUtils.remove(macAddress, ':');
50 return pods.stream().filter(pod -> macAddressWithoutColons.equals(pod.getMacAddress())).findFirst();
57 public void updateAcState(String macAddress, AcState acState) {
58 findSensiboSkyByMacAddress(macAddress).ifPresent(sky -> sky.updateAcState(acState));