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.FreeboxException;
19 import org.openhab.binding.freeboxos.internal.api.rest.HomeManager;
20 import org.openhab.binding.freeboxos.internal.api.rest.HomeManager.EndpointState;
21 import org.openhab.core.config.core.Configuration;
22 import org.openhab.core.library.types.DecimalType;
23 import org.openhab.core.library.types.OnOffType;
24 import org.openhab.core.thing.Thing;
25 import org.openhab.core.types.Command;
26 import org.openhab.core.types.State;
27 import org.openhab.core.types.UnDefType;
30 * The {@link KeyfobHandler} is responsible for handling everything associated to
31 * any Freebox Home keyfob thing type.
33 * @author Gaƫl L'hopital - Initial contribution
36 public class KeyfobHandler extends HomeNodeHandler {
38 public KeyfobHandler(Thing thing) {
43 protected State getChannelState(HomeManager homeManager, String channelId, EndpointState state) {
44 String value = state.value();
48 return OnOffType.from(state.asBoolean());
50 return DecimalType.valueOf(value);
53 return UnDefType.NULL;
57 protected boolean executeSlotCommand(HomeManager homeManager, String channelId, Command command,
58 Configuration config, int intValue) throws FreeboxException {
59 if (KEYFOB_ENABLE.equals(channelId) && command instanceof OnOffType onOff) {
60 return getManager(HomeManager.class).putCommand(getClientId(), intValue, onOff);