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.max.internal.device;
15 import java.util.HashMap;
18 import org.openhab.binding.max.internal.message.CMessage;
19 import org.openhab.binding.max.internal.message.Message;
22 * Base class for configuration provided by the MAX! Cube C Message.
24 * @author Andreas Heil - Initial contribution
26 public final class DeviceConfiguration {
28 private DeviceType deviceType;
29 private String rfAddress;
30 private String serialNumber;
32 private int roomId = -1;
33 private String roomName;
35 /** Extended configuration properties **/
36 private Map<String, Object> properties = new HashMap<>();
38 private DeviceConfiguration() {
41 public static DeviceConfiguration create(Message message) {
42 final DeviceConfiguration configuration = new DeviceConfiguration();
43 configuration.setValues((CMessage) message);
48 public static DeviceConfiguration create(DeviceInformation di) {
49 DeviceConfiguration configuration = new DeviceConfiguration();
50 configuration.setValues(di.getRFAddress(), di.getDeviceType(), di.getSerialNumber(), di.getRoomId(),
55 public void setValues(CMessage message) {
56 setValues(message.getRFAddress(), message.getDeviceType(), message.getSerialNumber(), message.getRoomID());
57 properties = new HashMap<>(message.getProperties());
60 private void setValues(String rfAddress, DeviceType deviceType, String serialNumber, int roomId, String name) {
61 setValues(rfAddress, deviceType, serialNumber, roomId);
65 private void setValues(String rfAddress, DeviceType deviceType, String serialNumber, int roomId) {
66 this.rfAddress = rfAddress;
67 this.deviceType = deviceType;
68 this.serialNumber = serialNumber;
72 public String getRFAddress() {
76 public DeviceType getDeviceType() {
80 public String getSerialNumber() {
84 public String getName() {
92 public void setName(String name) {
96 public int getRoomId() {
100 public void setRoomId(int roomId) {
101 this.roomId = roomId;
104 public String getRoomName() {
105 if (roomName == null) {
112 public void setRoomName(String roomName) {
113 this.roomName = roomName;
117 * @return the properties
119 public Map<String, Object> getProperties() {
124 * @param properties the properties to set
126 public void setProperties(HashMap<String, Object> properties) {
127 this.properties = properties;