2 * Copyright (c) 2010-2024 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.netatmo.internal.handler;
15 import java.util.concurrent.ScheduledExecutorService;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.netatmo.internal.handler.capability.CapabilityMap;
20 import org.openhab.core.thing.Bridge;
21 import org.openhab.core.thing.ChannelUID;
22 import org.openhab.core.thing.Thing;
23 import org.openhab.core.thing.ThingStatus;
24 import org.openhab.core.thing.ThingStatusDetail;
25 import org.openhab.core.thing.ThingStatusInfo;
26 import org.openhab.core.thing.binding.BaseBridgeHandler;
27 import org.openhab.core.thing.binding.builder.BridgeBuilder;
28 import org.openhab.core.types.Command;
29 import org.openhab.core.types.State;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
34 * {@link DeviceHandler} is the base class for all Netatmo bridges
36 * @author Gaƫl L'hopital - Initial contribution
40 public class DeviceHandler extends BaseBridgeHandler implements CommonInterface {
41 private final Logger logger = LoggerFactory.getLogger(DeviceHandler.class);
42 private CapabilityMap capabilities = new CapabilityMap();
44 public DeviceHandler(Bridge bridge) {
49 public void initialize() {
50 logger.debug("Initializing handler for bridge {}", getThing().getUID());
55 public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) {
56 logger.debug("bridgeStatusChanged for bridge {} to {}", getThing().getUID(), bridgeStatusInfo);
61 public void dispose() {
67 public void handleCommand(ChannelUID channelUID, Command command) {
68 commonHandleCommand(channelUID, command);
72 public void setThingStatus(ThingStatus thingStatus, ThingStatusDetail thingStatusDetail,
73 @Nullable String thingStatusReason) {
74 updateStatus(thingStatus, thingStatusDetail, thingStatusReason);
78 public CapabilityMap getCapabilities() {
83 public BridgeBuilder editThing() {
84 return super.editThing();
88 public void updateThing(Thing thing) {
89 super.updateThing(thing);
93 public void updateState(ChannelUID channelUID, State state) {
94 super.updateState(channelUID, state);
98 public boolean isLinked(ChannelUID channelUID) {
99 return super.isLinked(channelUID);
103 public @Nullable Bridge getBridge() {
104 return super.getBridge();
108 public void triggerChannel(String channelID, String event) {
109 super.triggerChannel(channelID, event);
113 public Logger getLogger() {
118 public ScheduledExecutorService getScheduler() {