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.boschshc.internal.devices.windowcontact;
15 import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.CHANNEL_BYPASS_STATE;
16 import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.CHANNEL_SIGNAL_STRENGTH;
18 import java.util.List;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.boschshc.internal.exceptions.BoschSHCException;
22 import org.openhab.binding.boschshc.internal.services.bypass.BypassService;
23 import org.openhab.binding.boschshc.internal.services.bypass.dto.BypassServiceState;
24 import org.openhab.binding.boschshc.internal.services.communicationquality.CommunicationQualityService;
25 import org.openhab.binding.boschshc.internal.services.communicationquality.dto.CommunicationQualityServiceState;
26 import org.openhab.core.thing.Thing;
29 * Handler for Door/Window Contact II
31 * @author David Pace - Initial contribution
35 public class WindowContact2Handler extends WindowContactHandler {
37 public WindowContact2Handler(Thing thing) {
42 protected void initializeServices() throws BoschSHCException {
43 super.initializeServices();
45 this.createService(BypassService::new, this::updateChannels, List.of(CHANNEL_BYPASS_STATE), true);
46 this.createService(CommunicationQualityService::new, this::updateChannels, List.of(CHANNEL_SIGNAL_STRENGTH),
50 private void updateChannels(BypassServiceState bypassServiceState) {
51 updateState(CHANNEL_BYPASS_STATE, bypassServiceState.state.toOnOffTypeOrUndef());
54 private void updateChannels(CommunicationQualityServiceState communicationQualityServiceState) {
55 updateState(CHANNEL_SIGNAL_STRENGTH, communicationQualityServiceState.quality.toSystemSignalStrength());