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.pilight.internal.handler;
15 import static org.openhab.binding.pilight.internal.PilightBindingConstants.CHANNEL_STATE;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.pilight.internal.dto.Action;
20 import org.openhab.binding.pilight.internal.dto.Device;
21 import org.openhab.binding.pilight.internal.dto.Status;
22 import org.openhab.binding.pilight.internal.types.PilightContactType;
23 import org.openhab.core.thing.ChannelUID;
24 import org.openhab.core.thing.Thing;
25 import org.openhab.core.types.Command;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
30 * The {@link PilightContactHandler} is responsible for handling a pilight contact.
32 * @author Stefan Röllin - Initial contribution
33 * @author Niklas Dörfler - Port pilight binding to openHAB 3 + add device discovery
36 public class PilightContactHandler extends PilightBaseHandler {
38 private final Logger logger = LoggerFactory.getLogger(PilightContactHandler.class);
40 public PilightContactHandler(Thing thing) {
45 protected void updateFromStatus(Status status) {
46 String state = status.getValues().get("state");
48 updateState(CHANNEL_STATE, PilightContactType.valueOf(state.toUpperCase()).toOpenClosedType());
53 void updateFromConfigDevice(Device device) {
57 protected @Nullable Action createUpdateCommand(ChannelUID channelUID, Command command) {
58 logger.warn("A contact is a read only device");