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.io.hueemulation.internal.dto;
15 import java.util.Collections;
17 import java.util.TreeMap;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
22 * Hue data store object. Contains all lights, configuration, user whitelist etc.
23 * Is used as a data store but also as API DTO.
25 * @author Dan Cunningham - Initial contribution
26 * @author David Graeff - Add groups,scenes,rules,sensors,resourcelinks and config entries
30 public class HueDataStore {
31 public HueAuthorizedConfig config = new HueAuthorizedConfig();
32 public TreeMap<String, HueLightEntry> lights = new TreeMap<>();
33 public TreeMap<String, HueGroupEntry> groups = new TreeMap<>();
34 public Map<String, HueSceneEntry> scenes = new TreeMap<>();
35 public Map<String, HueRuleEntry> rules = new TreeMap<>();
36 public Map<String, HueSensorEntry> sensors = new TreeMap<>();
37 public Map<String, HueScheduleEntry> schedules = new TreeMap<>();
38 public Map<Integer, Dummy> resourcelinks = Collections.emptyMap();
39 public Map<String, HueCapability> capabilities = new TreeMap<>();
41 public HueDataStore() {
42 resetGroupsAndLights();
43 capabilities.put("lights", new HueCapability());
44 capabilities.put("groups", new HueCapability());
45 capabilities.put("scenes", new HueCapability());
46 capabilities.put("rules", new HueCapability());
47 capabilities.put("sensors", new HueCapability());
48 capabilities.put("schedules", new HueCapability());
49 capabilities.put("resourcelinks", new HueCapability());
52 public void resetGroupsAndLights() {
55 // There must be a group 0 all the time!
56 groups.put("0", new HueGroupEntry("All lights", null, null));
59 public void resetSensors() {
63 public static class Dummy {
67 * Return a unique group id.
69 public String nextGroupID() {
70 int nextId = groups.size();
72 String id = "hueemulation" + nextId;
73 if (!groups.containsKey(id)) {