2 * Copyright (c) 2010-2021 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.somfytahoma.internal.handler;
15 import static org.openhab.core.thing.Thing.PROPERTY_FIRMWARE_VERSION;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.somfytahoma.internal.model.SomfyTahomaStatus;
19 import org.openhab.core.library.types.StringType;
20 import org.openhab.core.thing.Channel;
21 import org.openhab.core.thing.Thing;
22 import org.openhab.core.thing.ThingStatus;
25 * The {@link SomfyTahomaGatewayHandler} is responsible for handling commands,
26 * which are sent to one of the channels of the gateway thing.
28 * @author Ondrej Pecta - Initial contribution
31 public class SomfyTahomaGatewayHandler extends SomfyTahomaBaseThingHandler {
33 public SomfyTahomaGatewayHandler(Thing thing) {
38 public void refresh(String channel) {
39 String id = getGateWayId();
40 SomfyTahomaStatus status = getTahomaStatus(id);
41 String tahomaStatus = status.getStatus();
42 Channel ch = thing.getChannel(channel);
44 updateState(ch.getUID(), new StringType(tahomaStatus));
46 // update the firmware property
47 String fw = status.getProtocolVersion();
48 updateProperty(PROPERTY_FIRMWARE_VERSION, fw);
50 updateStatus("DISCONNECTED".equals(tahomaStatus) ? ThingStatus.OFFLINE : ThingStatus.ONLINE);
53 public String getGateWayId() {
54 return getThing().getConfiguration().get("id").toString();