]> git.basschouten.com Git - openhab-addons.git/blob
187f041436d91a0c58e486d24079d25de6fccf4f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13
14 package org.openhab.binding.nanoleaf.internal.layout;
15
16 import org.eclipse.jdt.annotation.NonNullByDefault;
17 import org.openhab.binding.nanoleaf.internal.colors.NanoleafPanelColors;
18 import org.openhab.core.library.types.HSBType;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 /**
23  * Stores the state of the panels.
24  *
25  * @author Jørgen Austvik - Initial contribution
26  */
27 @NonNullByDefault
28 public class LivePanelState implements PanelState {
29
30     private static final Logger logger = LoggerFactory.getLogger(LivePanelState.class);
31     private final NanoleafPanelColors panelColors;
32
33     public LivePanelState(NanoleafPanelColors panelColors) {
34         this.panelColors = panelColors;
35     }
36
37     @Override
38     public HSBType getHSBForPanel(Integer panelId) {
39         if (logger.isTraceEnabled()) {
40             if (!panelColors.hasColor(panelId)) {
41                 logger.trace("Failed to get color for panel {}, falling back to black", panelId);
42             }
43         }
44
45         return panelColors.getColor(panelId, HSBType.BLACK);
46     }
47 }