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.liquidcheck.internal.json;
15 import static org.openhab.binding.liquidcheck.internal.LiquidCheckBindingConstants.PROPERTY_HOSTNAME;
16 import static org.openhab.binding.liquidcheck.internal.LiquidCheckBindingConstants.PROPERTY_IP;
17 import static org.openhab.binding.liquidcheck.internal.LiquidCheckBindingConstants.PROPERTY_NAME;
18 import static org.openhab.binding.liquidcheck.internal.LiquidCheckBindingConstants.PROPERTY_SECURITY_CODE;
19 import static org.openhab.binding.liquidcheck.internal.LiquidCheckBindingConstants.PROPERTY_SSID;
21 import java.util.HashMap;
24 import org.eclipse.jdt.annotation.NonNullByDefault;
25 import org.openhab.core.thing.Thing;
28 * The {@link CommData} is used for serializing and deserializing of JSONs.
29 * It contains the complete communication data with header and payload or context.
31 * @author Marcel Goerentz - Initial contribution
35 public class CommData {
37 public Header header = new Header();
38 public Payload payload = new Payload();
39 public Context context = new Context();
41 public Map<String, String> createPropertyMap() {
42 Map<String, String> properties = new HashMap<>();
43 properties.put(Thing.PROPERTY_FIRMWARE_VERSION, payload.device.firmware);
44 properties.put(Thing.PROPERTY_HARDWARE_VERSION, payload.device.hardware);
45 properties.put(PROPERTY_NAME, payload.device.name);
46 properties.put(Thing.PROPERTY_VENDOR, payload.device.manufacturer);
47 properties.put(Thing.PROPERTY_SERIAL_NUMBER, payload.device.uuid);
48 properties.put(PROPERTY_SECURITY_CODE, payload.device.security.code);
49 properties.put(PROPERTY_IP, payload.wifi.station.ip);
50 properties.put(Thing.PROPERTY_MAC_ADDRESS, payload.wifi.station.mac);
51 properties.put(PROPERTY_SSID, payload.wifi.accessPoint.ssid);
55 public Map<String, Object> createPropertyMap(boolean isHostname) {
56 Map<String, Object> properties = new HashMap<>(createPropertyMap());
58 properties.put(PROPERTY_HOSTNAME, payload.wifi.station.hostname);
60 properties.put(PROPERTY_HOSTNAME, payload.wifi.station.ip);