]> git.basschouten.com Git - openhab-addons.git/blob
002b37e458a3d05e7a61860a9847a48fa0770d1d
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.shelly.internal.handler;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.shelly.internal.util.ShellyUtils;
20
21 /***
22  * {@link ShellyDeviceStats} some statistical values for the thing
23  *
24  * @author Markus Michels - Initial contribution
25  */
26 @NonNullByDefault
27 public class ShellyDeviceStats {
28     public long lastUptime = 0;
29     public long restarts = 0;
30     public long timeoutErrors = 0;
31     public long timeoutsRecorvered = 0;
32     public long remainingWatchdog = 0;
33     public long alarms = 0;
34     public String lastAlarm = "";
35     public long lastAlarmTs = 0;
36     public long coiotMessages = 0;
37     public long coiotErrors = 0;
38     public int wifiRssi = 0;
39     public int maxInternalTemp = 0;
40
41     public Map<String, String> asProperties() {
42         Map<String, String> prop = new HashMap<>();
43         prop.put("lastUptime", String.valueOf(lastUptime));
44         prop.put("deviceRestarts", String.valueOf(restarts));
45         prop.put("timeoutErrors", String.valueOf(timeoutErrors));
46         prop.put("timeoutsRecovered", String.valueOf(timeoutsRecorvered));
47         prop.put("remainingWatchdog", String.valueOf(remainingWatchdog));
48         prop.put("alarmCount", String.valueOf(alarms));
49         prop.put("lastAlarm", lastAlarm);
50         prop.put("lastAlarmTs", ShellyUtils.convertTimestamp(lastAlarmTs));
51         prop.put("coiotMessages", String.valueOf(coiotMessages));
52         prop.put("coiotErrors", String.valueOf(coiotErrors));
53         prop.put("wifiRssi", String.valueOf(wifiRssi));
54         return prop;
55     }
56 }