2 * Copyright (c) 2010-2022 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.tado.internal.handler;
15 import org.openhab.binding.tado.internal.api.client.HomeApi;
16 import org.openhab.core.thing.Bridge;
17 import org.openhab.core.thing.Thing;
18 import org.openhab.core.thing.ThingStatus;
19 import org.openhab.core.thing.binding.BaseThingHandler;
22 * Common base class for home-based thing-handler.
24 * @author Dennis Frommknecht - Initial contribution
26 public abstract class BaseHomeThingHandler extends BaseThingHandler {
28 public BaseHomeThingHandler(Thing thing) {
32 public Long getHomeId() {
33 TadoHomeHandler handler = getHomeHandler();
34 return handler != null ? handler.getHomeId() : Long.valueOf(0);
37 protected TadoHomeHandler getHomeHandler() {
38 Bridge bridge = getBridge();
39 return bridge != null ? (TadoHomeHandler) bridge.getHandler() : null;
42 protected HomeApi getApi() {
43 TadoHomeHandler handler = getHomeHandler();
44 return handler != null ? handler.getApi() : null;
47 protected void onSuccessfulOperation() {
48 // update without error -> we're back online
49 if (getThing().getStatus() == ThingStatus.OFFLINE) {
50 updateStatus(ThingStatus.ONLINE);