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.shelly.internal.handler;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.shelly.internal.util.ShellyUtils;
22 * {@link ShellyDeviceStats} some statistical values for the thing
24 * @author Markus Michels - Initial contribution
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 protocolMessages = 0;
37 public long protocolErrors = 0;
38 public int wifiRssi = 0;
39 public int maxInternalTemp = 0;
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("protocolMessages", String.valueOf(protocolMessages));
52 prop.put("protocolErrors", String.valueOf(protocolErrors));
53 prop.put("wifiRssi", String.valueOf(wifiRssi));