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