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.verisure.internal.handler;
15 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
17 import java.util.Collections;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.verisure.internal.dto.VerisureBroadbandConnectionsDTO;
22 import org.openhab.core.library.types.OnOffType;
23 import org.openhab.core.thing.ChannelUID;
24 import org.openhab.core.thing.Thing;
25 import org.openhab.core.thing.ThingStatus;
26 import org.openhab.core.thing.ThingTypeUID;
29 * Handler for the Broadband COnnection thing type that Verisure provides.
31 * @author Jan Gustafsson - Initial contribution
35 public class VerisureBroadbandConnectionThingHandler extends VerisureThingHandler<VerisureBroadbandConnectionsDTO> {
37 public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections
38 .singleton(THING_TYPE_BROADBAND_CONNECTION);
40 public VerisureBroadbandConnectionThingHandler(Thing thing) {
45 public Class<VerisureBroadbandConnectionsDTO> getVerisureThingClass() {
46 return VerisureBroadbandConnectionsDTO.class;
50 public synchronized void update(VerisureBroadbandConnectionsDTO thing) {
51 updateBroadbandConnection(thing);
52 updateStatus(ThingStatus.ONLINE);
55 private void updateBroadbandConnection(VerisureBroadbandConnectionsDTO vbcJSON) {
56 String testDate = vbcJSON.getData().getInstallation().getBroadband().getTestDate();
57 if (testDate != null) {
58 updateTimeStamp(testDate);
59 ChannelUID cuid = new ChannelUID(getThing().getUID(), CHANNEL_CONNECTED);
60 boolean broadbandConnected = vbcJSON.getData().getInstallation().getBroadband().isBroadbandConnected();
61 updateState(cuid, OnOffType.from(broadbandConnected));
62 updateInstallationChannels(vbcJSON);
67 public void updateTriggerChannel(String event) {