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.handler;
15 import static org.openhab.binding.freeboxos.internal.FreeboxOsBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.freeboxos.internal.api.rest.HomeManager;
19 import org.openhab.binding.freeboxos.internal.api.rest.HomeManager.EndpointState;
20 import org.openhab.core.library.types.DecimalType;
21 import org.openhab.core.library.types.QuantityType;
22 import org.openhab.core.library.types.StringType;
23 import org.openhab.core.thing.Thing;
24 import org.openhab.core.types.State;
25 import org.openhab.core.types.UnDefType;
28 * The {@link AlarmHandler} is responsible for handling everything associated to
29 * any Freebox Home Alarm thing type.
31 * @author Gaƫl L'hopital - Initial contribution
34 public class AlarmHandler extends HomeNodeHandler {
36 public AlarmHandler(Thing thing) {
41 protected State getChannelState(HomeManager homeManager, String channelId, EndpointState state) {
42 String value = state.value();
45 return UnDefType.NULL;
48 return switch (channelId) {
49 case NODE_BATTERY -> DecimalType.valueOf(value);
50 case ALARM_PIN -> StringType.valueOf(value);
51 case ALARM_SOUND, ALARM_VOLUME -> QuantityType.valueOf(value + " %");
52 case ALARM_TIMEOUT1, ALARM_TIMEOUT2, ALARM_TIMEOUT3 -> QuantityType.valueOf(value + " s");
53 default -> UnDefType.NULL;