2 * Copyright (c) 2010-2021 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.mqtt.homeassistant.internal;
15 import java.util.Collections;
16 import java.util.List;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.mqtt.homeassistant.internal.handler.HomeAssistantThingHandler;
23 * The {@link HomeAssistantThingHandler} manages Things that are responsible for
24 * HomeAssistant MQTT components.
25 * This class contains the necessary configuration for such a Thing handler.
27 * @author David Graeff - Initial contribution
30 public class HandlerConfiguration {
32 * hint: cannot be final, or <code>getConfigAs</code> will not work.
33 * The MQTT prefix topic
35 public String basetopic;
38 * hint: cannot be final, or <code>getConfigAs</code> will not work.
39 * List of configuration topics.
42 * Each topic is gets the base topic prepended.
48 * <code>component</code> (e.g. "switch", "light", ...)
51 * <code>node_id</code> (optional)
54 * <code>object_id</code> This is only to allow for separate topics for each device
64 public List<String> topics;
66 public HandlerConfiguration() {
67 this("homeassistant", Collections.emptyList());
70 public HandlerConfiguration(String basetopic, List<String> topics) {
72 this.basetopic = basetopic;
77 * Add the <code>basetopic</code> and <code>objectid</code> to the properties.
80 * @return the modified properties
82 public <T extends Map<String, Object>> T appendToProperties(T properties) {
83 properties.put("basetopic", basetopic);
84 properties.put("topics", topics);