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.verisure.internal.handler;
15 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.verisure.internal.dto.VerisureBroadbandConnectionsDTO;
21 import org.openhab.core.library.types.OnOffType;
22 import org.openhab.core.thing.ChannelUID;
23 import org.openhab.core.thing.Thing;
24 import org.openhab.core.thing.ThingStatus;
25 import org.openhab.core.thing.ThingTypeUID;
28 * Handler for the Broadband COnnection thing type that Verisure provides.
30 * @author Jan Gustafsson - Initial contribution
34 public class VerisureBroadbandConnectionThingHandler extends VerisureThingHandler<VerisureBroadbandConnectionsDTO> {
36 public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BROADBAND_CONNECTION);
38 public VerisureBroadbandConnectionThingHandler(Thing thing) {
43 public Class<VerisureBroadbandConnectionsDTO> getVerisureThingClass() {
44 return VerisureBroadbandConnectionsDTO.class;
48 public synchronized void update(VerisureBroadbandConnectionsDTO thing) {
49 updateBroadbandConnection(thing);
50 updateStatus(ThingStatus.ONLINE);
53 private void updateBroadbandConnection(VerisureBroadbandConnectionsDTO vbcJSON) {
54 String testDate = vbcJSON.getData().getInstallation().getBroadband().getTestDate();
55 if (testDate != null) {
56 updateTimeStamp(testDate);
57 ChannelUID cuid = new ChannelUID(getThing().getUID(), CHANNEL_CONNECTED);
58 boolean broadbandConnected = vbcJSON.getData().getInstallation().getBroadband().isBroadbandConnected();
59 updateState(cuid, OnOffType.from(broadbandConnected));
60 updateInstallationChannels(vbcJSON);
65 public void updateTriggerChannel(String event) {