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.concurrent.Callable;
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;
22 * The {@link LcdManager} is the Java class used to handle api requests related to lcd screen of the server
23 * https://dev.freebox.fr/sdk/os/system/#
25 * @author Gaƫl L'hopital - Initial contribution
28 public class LcdManager extends ConfigurableRest<LcdManager.Config, LcdManager.ConfigResponse> {
29 private static final String PATH = "lcd";
31 protected static class ConfigResponse extends Response<Config> {
34 public static record Config(int brightness, int orientation, boolean orientationForced) {
37 public LcdManager(FreeboxOsSession session) throws FreeboxException {
38 super(session, LoginManager.Permission.NONE, ConfigResponse.class, session.getUriBuilder().path(PATH),
42 private void setBrightness(int brightness) throws FreeboxException {
43 Config oldConfig = getConfig();
44 setConfig(new Config(brightness, oldConfig.orientation, oldConfig.orientationForced));
47 public void setOrientation(int orientation) throws FreeboxException {
48 Config oldConfig = getConfig();
49 setConfig(new Config(oldConfig.brightness, orientation, oldConfig.orientationForced));
52 public void setOrientationForced(boolean forced) throws FreeboxException {
53 Config oldConfig = getConfig();
54 setConfig(new Config(oldConfig.brightness, oldConfig.orientation, forced));
57 public void setBrightness(Callable<Integer> function) throws FreeboxException {
59 setBrightness(function.call());
60 } catch (Exception e) {
61 throw new FreeboxException(e, "Error setting brightness");