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.freeboxos.internal.api.rest;
15 import java.util.List;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.freeboxos.internal.api.FreeboxException;
19 import org.openhab.binding.freeboxos.internal.api.Response;
20 import org.openhab.binding.freeboxos.internal.api.rest.FreeboxOsSession.BoxModel;
22 import inet.ipaddr.mac.MACAddress;
25 * The {@link SystemManager} is the Java class used to handle api requests related to system
27 * @author Gaƫl L'hopital - Initial contribution
30 public class SystemManager extends ConfigurableRest<SystemManager.Config, SystemManager.ConfigurationResponse> {
32 protected static class ConfigurationResponse extends Response<Config> {
35 public static record Sensor(String id, String name, int value) {
36 public enum SensorKind {
42 public SensorKind getKind() {
43 String[] elements = id.split("_");
44 if (elements.length > 0) {
45 String kind = elements[0].replaceAll("\\d", "").toUpperCase();
47 return SensorKind.valueOf(kind);
48 } catch (IllegalArgumentException ignore) { // returning UNKNOWN
51 return SensorKind.UNKNOWN;
55 private static record Expansion(int slot, boolean probeDone, boolean present, boolean supported, String bundle,
58 UNKNOWN, // unknown module
59 DSL_LTE, // xDSL + LTE
60 DSL_LTE_EXTERNAL_ANTENNAS, // xDSL + LTE with external antennas switch
63 SECURITY // Security module
67 public static record ModelInfo(BoxModel name, String prettyName, boolean hasExpansions, boolean hasLanSfp,
68 boolean hasDect, boolean hasHomeAutomation, boolean hasFemtocellExp, boolean hasFixedFemtocell,
72 public static record Config(String firmwareVersion, MACAddress mac, String serial, String uptime, long uptimeVal,
73 String boardName, boolean boxAuthenticated, DiskStatus diskStatus, String userMainStorage,
74 List<Sensor> sensors, ModelInfo modelInfo, List<Sensor> fans, List<Expansion> expansions) {
75 private enum DiskStatus {
85 public SystemManager(FreeboxOsSession session) throws FreeboxException {
86 super(session, LoginManager.Permission.NONE, ConfigurationResponse.class,
87 session.getUriBuilder().path(SYSTEM_PATH), null);
90 public void reboot() throws FreeboxException {