]> git.basschouten.com Git - openhab-addons.git/blob
739315c6a12fde8a44299703afb39189569a16ca
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.tplinksmarthome.internal.device;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.tplinksmarthome.internal.Commands;
17 import org.openhab.binding.tplinksmarthome.internal.model.Realtime;
18 import org.openhab.binding.tplinksmarthome.internal.model.Sysinfo;
19
20 /**
21  * Data class to store device state.
22  *
23  * @author Hilbrand Bouwkamp - Initial contribution
24  */
25 @NonNullByDefault
26 public class DeviceState {
27
28     private final Commands commands = new Commands();
29     private final Realtime realtime;
30     private final Sysinfo sysinfo;
31
32     /**
33      * Initializes the device state given the json response from the device.
34      *
35      * @param state device state as json string
36      */
37     public DeviceState(String state) {
38         sysinfo = commands.getSysinfoReponse(state);
39         realtime = commands.getRealtimeResponse(state);
40     }
41
42     /**
43      * @return returns the device energy data (if present)
44      */
45     public Realtime getRealtime() {
46         return realtime;
47     }
48
49     /**
50      * @return returns the device state
51      */
52     public Sysinfo getSysinfo() {
53         return sysinfo;
54     }
55 }