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.homie.internal.handler;
15 import static org.openhab.binding.mqtt.homie.generic.internal.MqttBindingConstants.*;
17 import java.math.BigDecimal;
18 import java.util.ArrayList;
19 import java.util.HashMap;
20 import java.util.List;
23 import org.openhab.core.config.core.Configuration;
24 import org.openhab.core.thing.Channel;
25 import org.openhab.core.thing.ThingUID;
26 import org.openhab.core.thing.type.ChannelTypeUID;
29 * Static test definitions, like thing, bridge and channel definitions
31 * @author David Graeff - Initial contribution
33 public class ThingChannelConstants {
34 // Common ThingUID and ChannelUIDs
35 public static final ThingUID TEST_HOMIE_THING = new ThingUID(HOMIE300_MQTT_THING, "device123");
37 public static final ChannelTypeUID UNKNOWN_CHANNEL = new ChannelTypeUID(BINDING_ID, "unknown");
39 public static final String JSON_PATH_JSON = "{ \"device\": { \"status\": { \"temperature\": 23.2 }}}";
40 public static final String JSON_PATH_PATTERN = "$.device.status.temperature";
42 public static final List<Channel> THING_CHANNEL_LIST = new ArrayList<>();
43 public static final List<Channel> THING_CHANNEL_LIST_WITH_JSON = new ArrayList<>();
45 static Configuration textConfiguration() {
46 Map<String, Object> data = new HashMap<>();
47 data.put("stateTopic", "test/state");
48 data.put("commandTopic", "test/command");
49 return new Configuration(data);
52 static Configuration textConfigurationWithJson() {
53 Map<String, Object> data = new HashMap<>();
54 data.put("stateTopic", "test/state");
55 data.put("commandTopic", "test/command");
56 data.put("transformationPattern", "JSONPATH:" + JSON_PATH_PATTERN);
57 return new Configuration(data);
60 private static Configuration numberConfiguration() {
61 Map<String, Object> data = new HashMap<>();
62 data.put("stateTopic", "test/state");
63 data.put("commandTopic", "test/command");
64 data.put("min", BigDecimal.valueOf(1));
65 data.put("max", BigDecimal.valueOf(99));
66 data.put("step", BigDecimal.valueOf(2));
67 data.put("isDecimal", true);
68 return new Configuration(data);
71 private static Configuration percentageConfiguration() {
72 Map<String, Object> data = new HashMap<>();
73 data.put("stateTopic", "test/state");
74 data.put("commandTopic", "test/command");
76 data.put("off", "OFF");
77 return new Configuration(data);
80 private static Configuration onoffConfiguration() {
81 Map<String, Object> data = new HashMap<>();
82 data.put("stateTopic", "test/state");
83 data.put("commandTopic", "test/command");
85 data.put("off", "OFF");
86 data.put("inverse", true);
87 return new Configuration(data);