]> git.basschouten.com Git - openhab-addons.git/blob
845d2af72474f2c3e6e7625587e34e0b5ef9be9b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.boschshc.internal.devices.bridge.dto;
14
15 import java.util.List;
16
17 import com.google.gson.annotations.SerializedName;
18
19 /**
20  * Represents a single devices connected to the Bosch Smart Home Controller.
21  *
22  * Example from Json:
23  *
24  * {
25  * "@type":"device",
26  * "rootDeviceId":"64-da-a0-02-14-9b",
27  * "id":"hdm:HomeMaticIP:3014F711A00004953859F31B",
28  * "deviceServiceIds":["PowerMeter","PowerSwitch","PowerSwitchProgram","Routing"],
29  * "manufacturer":"BOSCH",
30  * "roomId":"hz_3",
31  * "deviceModel":"PSM",
32  * "serial":"3014F711A00004953859F31B",
33  * "profile":"GENERIC",
34  * "name":"Coffee Machine",
35  * "status":"AVAILABLE",
36  * "childDeviceIds":[]
37  * }
38  *
39  * @author Stefan Kästle - Initial contribution
40  */
41 public class Device {
42
43     @SerializedName("@type")
44     public String type;
45
46     public String rootDeviceId;
47     public String id;
48     public List<String> deviceServiceIds;
49     public String manufacturer;
50     public String roomId;
51     public String deviceModel;
52     public String serial;
53     public String profile;
54     public String name;
55     public String status;
56     public List<String> childDeviceIds;
57
58     public static Boolean isValid(Device obj) {
59         return obj != null && obj.id != null;
60     }
61
62     @Override
63     public String toString() {
64         return String.format(
65                 "Type %s; RootDeviceId: %s; Id: %s; Device Service Ids: %s; Manufacturer: %s; Room Id: %s; Device Model: %s; Serial: %s; Profile: %s; Name: %s; Status: %s; Child Device Ids: %s ",
66                 this.type, this.rootDeviceId, this.id,
67                 this.deviceServiceIds != null ? String.join(", ", this.deviceServiceIds) : "null", this.manufacturer,
68                 this.roomId, this.deviceModel, this.serial, this.profile, this.name, this.status,
69                 this.childDeviceIds != null ? String.join(", ", this.childDeviceIds) : "null");
70     }
71 }