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.nikobus.internal.handler;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.nikobus.internal.NikobusBindingConstants;
18 import org.openhab.core.thing.Bridge;
19 import org.openhab.core.thing.Thing;
20 import org.openhab.core.thing.ThingStatus;
21 import org.openhab.core.thing.ThingStatusDetail;
22 import org.openhab.core.thing.binding.BaseThingHandler;
25 * The {@link NikobusBaseThingHandler} class defines utility logic to be consumed by Nikobus thing(s).
27 * @author Boris Krivonog - Initial contribution
30 abstract class NikobusBaseThingHandler extends BaseThingHandler {
31 private @Nullable String address;
33 protected NikobusBaseThingHandler(Thing thing) {
38 public void initialize() {
39 address = (String) getConfig().get(NikobusBindingConstants.CONFIG_ADDRESS);
40 if (address == null) {
41 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, "Address must be set!");
45 updateStatus(ThingStatus.UNKNOWN);
48 protected @Nullable NikobusPcLinkHandler getPcLink() {
49 Bridge bridge = getBridge();
51 return (NikobusPcLinkHandler) bridge.getHandler();
56 protected String getAddress() {
57 String address = this.address;
58 if (address == null) {
59 throw new IllegalStateException();