2 * Copyright (c) 2010-2021 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 unexpectedRestarts = 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;
39 public Map<String, String> asProperties(String timeZone) {
40 Map<String, String> prop = new HashMap<>();
41 prop.put("lastUptime", String.valueOf(lastUptime));
42 prop.put("unexpectedRestarts", String.valueOf(unexpectedRestarts));
43 prop.put("timeoutErrors", String.valueOf(timeoutErrors));
44 prop.put("timeoutsRecovered", String.valueOf(timeoutsRecorvered));
45 prop.put("remainingWatchdog", String.valueOf(remainingWatchdog));
46 prop.put("alarmCount", String.valueOf(alarms));
47 prop.put("lastAlarm", lastAlarm);
48 prop.put("lastAlarmTs",
49 lastAlarmTs != 0 ? ShellyUtils.getTimestamp(timeZone, lastAlarmTs).format(null).replace('T', ' ') : "");
50 prop.put("coiotMessages", String.valueOf(coiotMessages));
51 prop.put("coiotErrors", String.valueOf(coiotErrors));